I am pretty much a noobie at nginx and i really need some help.

I am using nginx as a reverse proxy server to serve primarily as a load balancer. I am using almost only dynamic files. The back end servers are apache.

Here are my httperf results:

  • single apache server (1024 mb): 300 requests per second
  • 2x 512 mb apache server, 1 nginx server( 1024 mb) :300 requests per second
  • 2x 1024 mb apache server, 1 nginx server( 1024 mb) :300 requests per second

It seems that my nginx server is the bottleneck but i cant figure out how i can optimize it.

the cpu usage and ram usage on the apache backend server and nginx server is minimal, less than 10%.

My goal is to find a great way to scale up and by using a load balancer, but it seems that if nginx is limited in requests per second as a single apache server, then there is no point....

May i get some help from anyone please?

  • This belongs to serverfault.com
    – Lekensteyn
    Feb 22 '12 at 16:03
  • Did you have a look at varnish? it's normally used as a (very high performance) caching proxy but it can also load-balance. varnish-cache.org. Apologies in advance for not actually answering your question :)
    – roadmr
    Feb 22 '12 at 16:15
  • This question appears to be abandoned, if you are experiencing a similar issue please ask a new question with details pertaining to your problem. If you feel this question is not abandoned, please flag the question explaining that. :)
    – jrg
    Feb 23 '12 at 21:03

Maybe it is not nginx but your kernel configuration limits, did you tried fine tuning the kernel parameters as well?

I've searched for some kind of documentation for this, as far I've found these advices: http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html

  • i cant figure out why i am experiencing this issue: IE, 1gb nginx server handles 300 requests per second but a 2gb nginx server handles 700 requests per second. Everything else is identical in the. The weird is that the ram usage on these tests is very low. Also, no matter how much ram i give my backend servers, the requests per second stays the same. So my question is, why would increasing the total system ram affect the server performance if total ram usage is very low in the first place???
    – jay
    Aug 31 '11 at 4:35

It looks like you need to tune your kernel parameters. I think more memory available system-wide can make several decision making algorithms work different...

  • Please don't add "comments" as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, or to add actual comments when seeking clarification of any issues. Nov 6 '12 at 23:27

What is your worker_processes nginx configuration value set to? It defaults to 1 which would explain this behaviour (you're single threaded so no number of backends will change anything).

Try setting it to 4, or even 8, in the nginx config file. This will allow nginx to call more than one backend at once and should increase throughput proportionately to backends.


Not the answer you're looking for? Browse other questions tagged or ask your own question.