Opened 2 years ago

Closed 2 years ago

#1503 closed defect (worksforme)

10x Massive performance hit on fastcgi_pass

Reported by: jobs-git@… Owned by:
Priority: critical Milestone:
Component: nginx-core Version: 1.12.x
Keywords: Massive performance hit Cc:
uname -a: Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.12.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/opt/rh/rh-nginx112/root/usr/share/nginx --sbin-path=/opt/rh/rh-nginx112/root/usr/sbin/nginx --modules-path=/opt/rh/rh-nginx112/root/usr/lib64/nginx/modules --conf-path=/etc/opt/rh/rh-nginx112/nginx/nginx.conf --error-log-path=/var/opt/rh/rh-nginx112/log/nginx/error.log --http-log-path=/var/opt/rh/rh-nginx112/log/nginx/access.log --http-client-body-temp-path=/var/opt/rh/rh-nginx112/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/opt/rh/rh-nginx112/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/opt/rh/rh-nginx112/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/opt/rh/rh-nginx112/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/opt/rh/rh-nginx112/lib/nginx/tmp/scgi --pid-path=/var/opt/rh/rh-nginx112/run/nginx/ --lock-path=/var/opt/rh/rh-nginx112/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_auth_request_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'


I configured nginx such that it could handle 500k requests/s no sweat. That was benchmarking static html with wrk.

Then, I connected nginx with php-fpm 7.1 via fastcgi_pass to bench the server's performance. No changes from test was necessary, unfortunately, the server can now only do 50k requests/s that was still server a static file with opcache enabled.

I already tested several times and whenever I do fastcgi_pass the sever performance drops about 10x. Maybe 2x performance drop is still difficult to accept but 10x is Massive. I have scoured the web and it seems there was an indeed an issue with nginx connecting to other apps. Hope it gets resolved, I am including a uname -a and nginx -V for reference.

Change History (1)

comment:1 by Maxim Dounin, 2 years ago

Resolution: worksforme
Status: newclosed

Serving requests with passing them to PHP via FastCGI is more costly than returning static files directly by nginx. It is expected that such a configuration will be slower, there is no surprise here.

Moreover, as the actual request is served by PHP in such a configuration, the benchmark result cannot be faster than what PHP can when benchmarked directly. Try comparing PHP serving the file directly with PHP behind nginx with fastcgi_pass. This will show you the actual performance drop introduced by nginx. Everything else is not under nginx's control, and rather a result of your PHP backend performance.

Note well that there are number of FastCGI options that may need tuning if you are looking for peak performance on small requests. In particular, you may need to configure keepalive connections to your backend.

Note: See TracTickets for help on using tickets.