Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nginx Unit + PHP seems to handedly out-perform Nginx + php-fpm[1][2][3].

Also, Docker environments running PHP via Nginx Unit will no longer need separate containers for http + fpm, as it works similar to Apache's mod_php.

1. https://habr.com/en/articles/646397/

2. https://medium.com/@le_moment_it/nginx-unit-discover-and-ben...

3. https://github.com/nginx/unit/issues/6#issuecomment-38407362...



Those benchmark outcomes are ridiculously in nginx-unit’s favor over php-fpm, way more than I would have believed was possible. What is php-fpm doing architecturally that is so different to warrant such poor relative performance?


You see similar performance improvements in bencharmarks of Litespeed & PHP LSAPI [1].

Unfortunately said benchmarks are usually done by the software company making said webserver, so have to be taken with a pinch of salt.

1. https://www.litespeedtech.com/open-source/litespeed-sapi/php


You don't need separate containers to run nginx and php-fpm.


I too would like to see a properly configured php+php-fpm container benchmark. There's a lot of overhead when you link by http instead of a unix socket, in the same container.


Technically, you should be able to share a domain socket via a shared volume too (between an "app" and "web" container) - as with postgres:

https://github.com/sameersbn/docker-postgresql/issues/30#iss...

Curious about benchmarks and tests of TCP vs Unix domain sockets between docker containers.


Another example is API Platform's docker setup:

Volume config: https://github.com/api-platform/api-platform/blob/main/docke...

Caddy config: https://github.com/api-platform/api-platform/blob/main/api/d...

php-fpm config: https://github.com/api-platform/api-platform/blob/main/api/d...

I'm also curious on the performance differences between containers.


I found a simple comparison from 2014 - which shows Unix domain sockets to have a 2-3x advantage over localhost TCP:

"Unix Domain Sockets vs Loopback TCP Sockets"

https://nicisdigital.wordpress.com/2014/03/03/unix-domain-so...

Hn submission: https://news.ycombinator.com/item?id=37466475


Are you implying that docker containers don't run a unikernel that can only run one application at a time? /s


I am happily running Nginx + supervisord + several Python apps in a single Docker container.


Not gonna lie I tend to use docker like minimal disposable VMs from time to time lol


does it involve running supervisor inside the container? that’s fine but it’s definitely not kosher.

in my experience those are the ones that kick and scream when they don’t start as root.


php-fpm & nginx -g "daemon off;"


this is … not how I’d do it


Two questions:

1. Does Unit + PHP doing the typical “initialize & teardown” that PHP is know for?

Or is Unit persisting the initialization/setup, hence why it’s achieving the way faster results?

2. How is Unit/PHP architecturally different than NGX-PHP (an event loop)?

https://github.com/rryqszq4/ngx-php


PHP’s had an opcache and jit for several versions now. Combined with preload options, this means startup time is negligible.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: