tags:

views:

1331

answers:

3

I know this is not directly a programming question, but people on stackoverflow seems to be able to answer any question.

I have a server running Centos 5.2 64 bit. Pretty powerful dual core 2 server with 4GB memory. It mostly serves static files, flash and pictures. When I use lighttpd it easily serves over 80 MB/sec, but when I test with nginx it drops down to less than 20 MB/sec.

My setup is pretty straight forward, uses the default setup file, and I have added the following

user  lighttpd;
worker_processes  8;
worker_rlimit_nofile 206011;
#worker_rlimit_nofile 110240;

error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  4096;
}

http {
....

keepalive_timeout  2;
....
}

And I thought nginx was supposed to be at least as powerful, so I must be not doing something.

+2  A: 

Perhaps lighttpd is using some kind of caching? There's a great article here that describes how to set up memcached with nginx for a reported 400% performance boost.

The nginx doc on the memcached module is here.

Ross
+5  A: 

When you reload your nginx (kiil -HUP) you'll get something like this in your error logs

2008/10/01 03:57:26 [notice] 4563#0: signal 1 (SIGHUP) received, reconfiguring
2008/10/01 03:57:26 [notice] 4563#0: reconfiguring
2008/10/01 03:57:26 [notice] 4563#0: using the "epoll" event method
2008/10/01 03:57:26 [notice] 4563#0: start worker processes
2008/10/01 03:57:26 [notice] 4563#0: start worker process 3870

What event method is your nginx compiled to use?

Are you doing any access_log'ing ? Consider adding buffer=32k, which will reduce the contention on the write lock for the log file.

Consider reducing the number of workers, it sounds counter intuitive, but the workers need to synchronize with each other for sys calls like accept(). Try reducing the number of workers, ideally I would suggest 1.

You might try explicitly setting the read and write socket buffers on the listening socket, see http://wiki.codemongers.com/NginxHttpCoreModule#listen

Dave Cheney
A: 

Suggestions: - Use 1 worker per processor. - Check the various nginx buffer settings

Seun Osewa