Here I have collected the information to tuning your Nginx Web Server for better performance. Now of course you can tune your operating system, or purchase better hardware.
So you need to tune Nginx for your server. Example: how many CPU cores do you have on your server. So you need to setup Nginx to use them.
Of course if you find a good tuning option, feel free to leave a comment.
Will will start by editing the nginx.conf file. On Centos it is /etc/nginx/nginx.conf
Worker_processes = how many CPU cores you have on your web server.
# cat /proc/cpuinfo| grep processor|wc -l (Put this number as your worker_processes)
worker_processes 2; (This is on my VPS server)
Worker_connections = is for the maximum clients the server can handle.
max_clients = worker_processes * worker_connections
Default is 768, but most documentation I have read seems to put it at 1024 (Thats 1024 connections per second on 1 core CPU). I read on the internet, if you want to hit 100k connections a minute, you would set this at 19000 on a 2 CPU core, 2G of ram server.
Worker_rlimit_nofile is for how many files can be opened. So far the best information I have found here is to use 2 for each connection and 3 if using with a proxy. Make sure and check how many open files you have on the server # sysctl fs.file-max, make sure you have enough. On my server I had 98911. You can't exceed this amount.
Gzip on the server to help with how much data is transfered.
gzip_buffers 16 8k;