0

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....

2
  • I don't really follow why increasing the memory usage on the apache server should result in more throughput? Is cpu not the bottleneck? You are sure memory is? Can you run the test with say 3 apache servers or more and see what the throughput is?
    – polynomial
    Aug 29, 2011 at 7:07
  • Are you serving static files only ? If you have some dynamic pages (PHP for instance), you should also investigate here...
    – MunsterNet
    Aug 29, 2011 at 7:43

1 Answer 1

1

Firstly set this basic :

worker_processes        2; # put here the number of CPU you got.

Regarding the operating system you use, set the best event engine : use [ kqueue | rtsig | epoll | /dev/poll | select | poll | eventport ].

Then set the number of connection per worker. Be careful here, your system should be limited for the user nginx uses. See the /etc/security/limits.conf to set the best number of file descriptor nginx can open.

events {
        use                     kqueue;  
        worker_connections      4096;
}

Then it's all about your application works. You can enable caching and/or compression to get better results. See this post for caching solutions : How to set up Nginx as a caching reverse proxy?

1
  • 4
    Nginx will automatically choose the best even polling option, you don't actually need to set it unless you want to downgrade it. Aug 29, 2011 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .