Nginx设置问题 [英] nginx setup question

查看:57
本文介绍了Nginx设置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这不是直接的编程问题,但是stackoverflow上的人们似乎能够回答任何问题.

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

我有一台运行Centos 5.2 64位的服务器.具有4GB内存的功能强大的双核2服务器.它主要提供静态文件,Flash和图片.当我使用lighttpd时,它的速度很容易超过80 MB/秒,但是当我使用nginx进行测试时,它的速度降到了20 MB/秒以下.

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

我认为nginx应该至少具有同样的功能,所以我一定不做任何事情.

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

推荐答案

重新加载nginx(kiil -HUP)时,您会在错误日志中得到类似的东西

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

您的nginx编译使用哪种事件方法?

What event method is your nginx compiled to use?

您正在执行任何access_log'ing吗?考虑添加buffer = 32k,这将减少日志文件的写锁争用.

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

考虑减少工作程序的数量,这听起来很直观,但是工作程序需要彼此同步以进行诸如accept()之类的系统调用.尝试减少工人的数量,理想情况下,我建议1.

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.

您可以尝试在侦听套接字上显式设置读写套接字缓冲区,请参见 http://wiki .codemongers.com/NginxHttpCoreModule#listen

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

这篇关于Nginx设置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆