New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
what happens when TCP is over localhost?
Hi,
Often TCP is run across localhost (for example between an app server and a database). I don't think that localhost actually does any network call. So, what happens? Is TCP on localhost really even IO in linux, or does the OS just transfer memory buffers from one program to another.
Comments
That depends on the OS and on certain details such as: is it purely internal communication or is it e.g. forwarding.
Keep in mind that the localport system has been expressly created for the purpose of (at least one) local endpoint(s) communicating through the network stack. Otherwise it wouldn't be needed; all unices have other mechanisms already for IPC.
Hits networking stack. Use Unix sockets
It actually does run through the network. There is utility in this though. Some programs optionally run in a chroot jail (Postfox, Apache, PHP-FPM); in such circumstances accessing unix sockets to communicate with other applications wouldn't work, whereas localhost will.
If there's no jail situation to worry about unix sockets can be marginally faster, but probably not enough to make a difference. Sockets also impact filesystem IO so it's not unheard of for that to create issues (e.g. a massive spike in visitors to a site running PHP-FPM through sockets).