My web and database servers are on the same machine when connecting to the database server I used the internal address assigned by the router

Is there any difference latency-wise compared to using

Is the OS smart enough to know that the 192 address is the same machine? Will the packets even be sent to the router / leave the machine?

  • 1
    Linux is smart enough to not send such packets over the wire. I don't know about Windows. – Michael Hampton Apr 19 '18 at 16:57
  • If you do care about performance, a web site and its database instance should be installed on separate machines (then both of them can make great use of the memory). maps to the loopback interface, and it does not always give you the best performance as you wished. A true network adapter won't slow you down much. – Lex Li Apr 19 '18 at 18:35
  • @MichaelHampton wasn't the original Windows TCP/IP stack taken from one of teh BSDs? In which case it might actually still be sane? :) – ivanivan Apr 19 '18 at 19:16
  • I know most about linux and when you are on the same machine there the third option is usually even better performance wise, namely to use a UNIX domain socket connection and you don’t even have to craft TCP/IP packets – HBruijn Apr 19 '18 at 19:51

The main difference would be what machines beyond that one could access the database. If you wanted to ensure that only the webserver running on that machine was the one to access that database you could have the database server only listen on rather than on all addresses.

But either way if you use the or it's 192.x.x.x address the traffic will not leave the machine and traverse the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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