Filip Chabik

DevOps Engineer, Husband & Dad.

Load Balancing PHP-FPM with HAProxy and FastCGI →

The better alternative is to run the script in its own process and leave the task of receiving HTTP requests to the web server. FastCGI allows you to separate the web server (or proxy) and the running script by defining the communication protocol between the two. Performance benchmarks indicate that separating scripts into their own process equates to a boost in performance.

That was always one of the key differences between Apache and NGINX. Doesn’t really apply these days, but while mod_php is still doing well, NGINX has never adopted anything like it and kept being simply reverse-proxy and cache things. I much prefer NGINX’s approach and it’s great to see that HAProxy can now be used as a viable alternative.

There’s still value using web server for this kind of task, but now it really depends on the software stack already in place and needs. While caching and additional, web server specific, functionality makes more sense in production environment, for testing or maybe even staging purposes HAProxy may be more than enough.