Tuning Nginx as a Load Balancer

W. Andrew Loe III andrew at andrewloe.com
Tue Jul 13 21:13:40 MSD 2010


I'm running the 0.7 branch as the front door to 6 machines running
nginx + passenger. The two workers (two core machine) are using a
modest amount of CPU but I am still seeing spikes in my queue time
metric. I've patched my instance to add a X_REQUEST_START header
similar to this http://gist.github.com/318681

According to my metrics, http://skitch.com/waloeiii/dcj79/queue,
somewhere around 200-250ms of each request is spent in 'queue time'.
My site runs 100% under SSL so a large portion of that is the SSL
negotiation, but I think there is room to improve. These machines are
all in ec2's cloud with latencies < 1ms and plenty of spare capacity
so I'm pretty convinced that my load-balancer just needs some
tweaking. My nginx.conf for the load-balancer is here:
http://gist.github.com/474180

The load-balancing instance has 1.7GB of RAM, however over 1.5GB is
free. Can I change some of the settings to allow nginx to keep more
requests off the disk without opening my self up to possible denial of
service? iostat/vmstat does show pretty consistent writes to the disk,
but nothing like maxing it out. The X-REQUEST-START is only tracked on
GET requests as well so slow client uploads should not be throwing off
the numbers.



More information about the nginx mailing list