2

On my Ubuntu 16.04 machine, I've two services A & B. Service A calls Service B using 127.0.0.1:Bport...

Does it change anything, in terms of performance to call <externalIp>:Bport instead ?

Thanks !

2 Answers2

2

You can check with

tcpdump -i lo -n

that connections to local addresses of non-loopback interfaces are handled by the loopback interface.

So no, there would be no performance difference.

Hauke Laging
  • 5,157
  • 2
  • 23
  • 40
1

In both cases, it will only pass through the kernel, since the any of the host's IP addresses can be reached without touching the NIC.

This is defined by the "local" routing table, where traffic will be looped back to the loopback interface, as you can see in Hauke Laging's tcpdump example.

Since both arrive via the loopback interface, performance should be the same.

Check the following links: 1. Routing Tables, 2. What is the local routing table used for?

Am_I_Helpful
  • 499
  • 1
  • 6
  • 17
multithr3at3d
  • 259
  • 2
  • 8
  • Looking for more concrete sources, but there are other similar answers: https://stackoverflow.com/a/10936084/1974978 – multithr3at3d Jan 07 '18 at 16:52
  • The OP asked for external IP Address, and not for the same IP / localhost! I think you're confusing between the two. – Am_I_Helpful Jan 07 '18 at 16:59
  • 1
    @Am_I_Helpful The OP said that his "external" IP address was actually configured on the same machine. So your comments don't make sense here. – Michael Hampton Jan 08 '18 at 08:49
  • @MichaelHampton - OP hadn't clairfied this when I made the comment. Anyway, thanks for informing, I''ll remove my downvote. – Am_I_Helpful Jan 08 '18 at 15:02
  • 1
    @multithr3at3d Some sources for you: https://stackoverflow.com/a/2037389/1754517 https://serverfault.com/a/962579/131635 & https://stackoverflow.com/a/3654623/1754517 – Jimadine Jul 18 '20 at 15:48