Nginx: optimum # of workers

nginx

I just bought a new server which will be running nginx, PHP, MySQL stack that will be serving fully-cached html requests 90% of the time and PHP/mysql requests otherwise through FastCGI.

Stats on the box are:

CentOS 5.x 64-bit

2x Intel Quad Core Xeon E5520 (8 cores/16 threads)

6GB DDR3 @ 800Mhz

Wondering what some nginx pros would generally recommend regarding number of worker processes for a server like this. Am looking for optimum setup here as this is strictly a web server – will ideally be serving a few thousand requests/sec from html cache and a few hundred max from PHP/mysql.

Thanks!

Best Answer

Nginx's resident memory usage is trivial and to the best of my knowledge there is little penalty for having 8 Nginx processes (1 per core) rather than 1.

I would run apache bench or another utiltiy with high concurrency requesting disk heavy objects. Keep increasing the AB tests till you discover the breaking point. Then experiment with the amount of Nginx procs keeping all other tests equal. Report back so we can all be the wiser.