Somebody executed a benchmark, which does show still improvements when using keepalive with PHP socket files:
Test case RPS Latency
TCP / fastcgi_keep_conn OFF / keepalive OFF 8791.1 ± 161.45 225µs ± 48µs
TCP / fastcgi_keep_conn ON / keepalive OFF 8514.02 ± 79.07 232µs ± 45µs
TCP / fastcgi_keep_conn ON / keepalive ON 10356.21 ± 115.86 190µs ± 51µs
Unix / fastcgi_keep_conn OFF / keepalive OFF 9571.68 ± 66.48 206µs ± 40µs
Unix / fastcgi_keep_conn ON / keepalive OFF 9376.97 ± 73.16 211µs ± 42µs
Unix / fastcgi_keep_conn ON / keepalive ON 10333 ± 155.5 191µs ± 65µs
With the following additional information:
- Unix sockets are generally a bit faster than TCP sockets.
- Enabling fastcgi_keep_conn and keepalive provides a measurable performance boost.
- This improvement is more noticeable with TCP sockets than with Unix sockets.
See: https://github.com/yegor-usoltsev/nginx-upstream-keepalive/issues/1