Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 29 '11 at 6:56

This question came from our site for professional and enthusiast programmers.

    
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 '11 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 '11 at 7:43

1 Answer 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?

share|improve this answer
1  
Nginx will automatically choose the best even polling option, you don't actually need to set it unless you want to downgrade it. –  Martin Fjordvald Aug 29 '11 at 8:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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