调整nginx worker_process以获得每分钟100k的命中率

时间:2011-09-06 19:38:36

标签: nginx

我们有一台服务器正在提供一个html文件。

现在服务器有2个CPU和2GB内存。从blitz.io开始,我们每分钟可以获得大约12k个连接,并且在60秒内有200个超时,每秒250个并发连接。

worker_processes  2;

events {
 worker_connections 1024;
}

如果我增加超时,响应时间会开始超过一秒钟。

我还能做些什么来挤出更多汁液呢?

1 个答案:

答案 0 :(得分:183)

配置文件:

worker_processes  4;  # 2 * Number of CPUs

events {
    worker_connections  19000;  # It's the key to high performance - have a lot of connections available
}

worker_rlimit_nofile    20000;  # Each connection needs a filehandle (or 2 if you are proxying)


# Total amount of users you can serve = worker_processes * worker_connections

更多信息:Optimizing nginx for high traffic loads