3

I have application servers with memcached running on them.

What will happen if I make a request to memcached on 10.243.98.5, which just happens to be the originating server? Will it use the same fast-path tcp/ip stack as 127.0.0.1, or would I get better performance by checking if 10.243.98.5 is the same box, and substituting 127.0.0.1?

Normally it wouldn't matter so much, because odds are the item you want is going to be in a memcached on another application server, but in this case the load-balancer divides requests so that it's very likely that most of the memcached requests will resolve to the local memcached instance.

Eloff
  • 137
  • 8

3 Answers3

1

What operating system are you using? I'll hazard a guess and say that it will be about the same level of performance using either method, as the dns record for 10.243.... should be cached. Have you tried timing it both ways?

  • DNS record for an IP address? Surely you mean ARP? – Jacob Krall Dec 01 '09 at 18:52
  • 1
    Linux 2.6, but IIRC there is actually special treatment for 127.0.0.1, where it doesn't go through the tcp/ip stack, it runs at closer to shared memory speeds - so there is the possibility of there being a large difference in performance. –  Dec 01 '09 at 19:18
  • ARP isn't even going to be involved on the same machine, there's no need to ARP for something that isn't transmitted on the wire. – Michael Graff Dec 03 '09 at 02:41
1

Sounds like you already know the answer ;). In many cases UNIX will use:

http://en.wikipedia.org/wiki/Unix_domain_socket

Unix Domain sockets are faster than TCP/IP/UDP because their is no network stack involved. Many UNIX applications will use Unix Domain sockets for local communication, like for instance your database drivers, or memcached. This isn't always the case, and you should be careful not to confuse Unix domain sockets with UDP, which is completely different.

0

Many OSs have optimized the loopback interfaces. Chances are, the packets will hit the routing table, see that it is local, and follow a fast-path routing to the input on the same machine. No ethernet drivers nor ARP nor other things will be touched.

If you look, chances are your MTU will also be much larger on the loopback too.

Michael Graff
  • 6,668
  • 1
  • 24
  • 36