Welcome! Log In Create A New Profile

Advanced

Slightly higher latency after switching from Apache to NginX

Posted by dirk_willbrandt 
Slightly higher latency after switching from Apache to NginX
August 23, 2012 07:49AM
Hi All,

I finally migrated all my Apache Web-Servers (9 Web-Servers) to nginx + php-fpm, and it works better now :-). In front of the Web-Servers i have 3 Nginx-Servers as a Reverse-Proxy. I monitor the latency of a page-call using Smokeping with echo-http and send a GET-Request to my index.php.

Since using nginx + php-fpm the latency is slightly higher than with Apache and it "smokes" more. Because of the gathered information, i think there are some more variables i have to optimize, but i don't know which.

I attached my used configuration for a nginx-php-fpm Server.

All Nginx-Servers are running on Freebsd-amd64 (between Version 7.2-RELEASE to 9.0-RELEASE) and is compiled from Ports using gcc 4.7 with optimized CFLAGS, CXXFLAGS and CPPFLAGS. Nginx uses automatically kqueue. The primary work for the Servers is to serve PHP-generated content (99% / 1% is sending static files). Some sysctl variables are optimized according to the "10,000 req/s" articles on the Web (sorry for putting the Code here, but i can't upload more than 3 files :-):

net.inet.ip.portrange.randomized=0
kern.ipc.maxsockets=204800
net.inet.tcp.maxtcptw=163840
kern.maxfiles=204800
kern.ipc.somaxconn=8192
net.inet.tcp.fast_finwait2_recycle=1
net.inet.tcp.finwait2_timeout=5000
net.inet.tcp.msl=5000

Any tips for some more optimizations?

Thanks for you Help :-)
Dirk
Attachments:
open | download - nginx.conf (1.7 KB)
open | download - fastcgi.conf (177 bytes)
open | download - php.conf (1.1 KB)
Re: Slightly higher latency after switching from Apache to NginX
December 07, 2012 03:32AM
Create a static HTML file and test the speed to that and see what latency you get. if it is the php-fpm try
playing around with pm = static and how meny pm.max_children you need. In events just to be safe add use kqueue;
add worker_rlimit_nofile 4096;
also check the error.log for nginx and see if you have a problem there. also you might like to checkout php-apc too to cache your php files.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready