Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Dec 3 '09 at 2:08

This question came from our site for professional and enthusiast programmers.

3 Answers 3

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?

share|improve this answer
    
DNS record for an IP address? Surely you mean ARP? –  Jacob Krall Dec 1 '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. –  Eloff Dec 1 '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 3 '09 at 2:41

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

http://en.wikipedia.org/wiki/Unix%5Fdomain%5Fsocket

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.