Do Phalcon wizards use PHP FPM with a file socket or TCP/IP?

Do Phalcon wizards use PHP FPM with a file socket or TCP/IP?

Originally a about a year ago when I was first playing with things I settled into using TCP/IP for FPM because it seemed to fix some issue but I've learned a lot since then and I'm not sure that its necessary. Does anyone encounter errors with either method? I recall something about how file sockets could perhaps fail under very large load but that they were faster. Is this accurate? In my heart's desire I'd like to use sockets. Any reason not to?

In my personal experience, file sockets starts to fail under high load, TCP/IP seems to respond better and scale better in you want to place a PHP/FPM in a different machine than Nginx.



7.3k

High load via sockets is near 250 connections on linux kernel level.

More you can learn sockets in kernel source.

The kernel source has constant near 250, I don't remember exactly.

The solution FPM with a few FPM processes is well.

This situation is well described in :

http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI#Load-Balancing



11.8k

Like Andrés said TCP/IP is The best way to go

From my expirience, if you're on the same box (web and php), *nix domain sockets are better performing.

Since FastCGI processes use Unix-Domain-Sockets or TCP/IP to talk with the webserver, with internal FIFO, communication is much simpler and better handled than with TCP/IP overhead.

And if you're running separate web and app servers, then, obviously you need to use TCP sockets.



6.0k

to confirm with Andres, Oleg and Max said: Real life experience has shown that unix sockets are a tiny fraction faster than TCP sockets, TCP sockets are more reliable however under high load. So decide depending on your app.

Update on this matter.

Using unix domain sockets is slightly faster since it provides you direct network access without any TCP/IP overhead. That's a fact. On the down side, it is not as scalable as TCP/IP. Nginx/Apache will throw 502 errors when the sockets have been depleted on your host OS. In such a case you can either tweak the OS settings to accommodate the larger connection pool or just switch to switch to TCP/IP, which is probabbly better solution to use that opportunity to off-load web server and to put PHP with FPM on another box. So if you ever see 502 errors generated in your logs, compare the conucrent visitors and do what you have to do..

edited Mar '16

Performance of unix sockets vs TCP ports

http://unix.stackexchange.com/questions/91774/performance-of-unix-sockets-vs-tcp-ports

On most systems today /proc/sys/net/core/somaxconn is set to 128 by default. What happens during spike load, is that max conn number raises while PHP-FPM workers are working hard to produce the output, and if they wait for some result from elsewhere (i.e. database call) then this number can be full very fast. The easiest way to handle it is to increase /proc/sys/net/core/somaxconn system wide in sysctl.conf:

Increase number of incoming connections

net.core.somaxconn = 4096

Another good reference on this topic regarding system settings: https://computing.llnl.gov/linux/slurm/high_throughput.html