Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js nginx nodejs faye性能问题_Node.js_Nginx_Benchmarking_Faye - Fatal编程技术网

Node.js nginx nodejs faye性能问题

Node.js nginx nodejs faye性能问题,node.js,nginx,benchmarking,faye,Node.js,Nginx,Benchmarking,Faye,我正在为多个Faye聊天服务器进行nginx负载平衡。 我能够看到正常http请求的显著性能。但是,当比较没有nginx的结果时,websocket连接性能非常低 这是我的nginx配置 upstream backend { server 127.0.0.1:4000; server 127.0.0.1:4002; server 127.0.0.1:4003; server 127.0.0.1:4004; } server { listen 4001

我正在为多个Faye聊天服务器进行nginx负载平衡。 我能够看到正常http请求的显著性能。但是,当比较没有nginx的结果时,websocket连接性能非常低

这是我的nginx配置

upstream backend {
    server 127.0.0.1:4000;
    server 127.0.0.1:4002;
    server 127.0.0.1:4003;
    server 127.0.0.1:4004;
}

server {
    listen   4001;

    root /var/www/html/laughing-robot;
    index index.html index.htm;

    server_name backend;

    location /faye {
            proxy_pass http://backend;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }

        location / {
            proxy_http_version 1.1;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   X-NginX-Proxy    true;
            proxy_set_header   Host             $http_host;
            proxy_set_header   Upgrade          $http_upgrade;
            proxy_redirect     off;
            proxy_pass         http://backend;
        }
}
我正在使用Faye connections(websocket)进行基准测试

以下是不带nginx的结果: 总持续时间低于
6000 ms

以下是nginx负载平衡器的结果: 对于总共2000个连接和500个并发连接,nginx loadbalancer的性能非常低

我还配置了
nofile
file max

/etc/security/limits.conf /etc/sysctl.conf 在Fedora上,我在
/var/log/nginx/error.log
上遇到了很多连接被拒绝的错误。但是在Ubuntu 13.04上没有错误

如果有人能把我引向正确的方向,这将是非常值得赞赏的

谢谢

你知道吗

如果你在ubuntu上没有收到错误,那么性能如何? (希望这些系统在性能上具有可比性)

无论如何,看看内核调优部分,您也可以尝试他们在测试中使用的nginx.conf,看看是否会得到相同的结果

如果可能,您还应该尝试多个负载测试。您所做的测试是在运行nginx的服务器上进行的,这些测试与您域上的acutal外部ip相比如何

我建议在dev机器上而不是在实际服务器上运行负载测试。 另外,对于nginx和节点进程,top表示cpu/内存方面的问题是什么? nginx是否正在使您的某个进程和/或测试本身处于饥饿状态

Websockets在ssl上更稳定,这可能也值得进行测试

他们用thor做测试,结果也一样吗?

我看不出您在哪里定义了
$connection\u upgrade
变量。另外,您在nginx上使用的是什么版本?@alexeyten:它在
/etc/nginx/nginx.conf
文件中定义。在我看来,
websocket bench
刚刚坏了。@VBart:您为什么会这样?你能解释更多吗?即使没有nginx,它显示的数字也是荒谬的。在本地主机上打开2000个连接不是什么大问题,应该不会超过10毫秒。事实上,nginx可以毫无问题地为数十万个连接提供服务。
user@machine:/etc/nginx/sites-enabled$ websocket-bench -a 2000 -c 500 -t faye http://127.0.0.1:4000/faye
Launch bench with 2000 total connection, 500 concurent connection
0 message(s) send by client
1 worker(s)
WS server : faye
trying : 500 ...
trying : 1000 ...
trying : 1500 ...
trying : 2000 ...

#### steps report ####
┌────────┬─────────────┬────────┬──────────────┐
│ Number │ Connections │ Errors │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┤
│ 500    │ 500         │ 0      │ 2488         │
├────────┼─────────────┼────────┼──────────────┤
│ 1000   │ 500         │ 0      │ 2830         │
├────────┼─────────────┼────────┼──────────────┤
│ 1500   │ 500         │ 0      │ 2769         │
├────────┼─────────────┼────────┼──────────────┤
│ 2000   │ 500         │ 0      │ 2144         │
└────────┴─────────────┴────────┴──────────────┘
#### total report ####
┌────────┬─────────────┬────────┬──────────────┬──────────────┬──────────────┐
│ Number │ Connections │ Errors │ Message Send │ Message Fail │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┼──────────────┼──────────────┤
│ 2000   │ 2000        │ 0      │ 0            │ 0            │ 5150         │
└────────┴─────────────┴────────┴──────────────┴──────────────┴──────────────┘
user@machine:/etc/nginx/sites-enabled$ websocket-bench -a 2000 -c 500 -t faye http://127.0.0.1:4001/faye
Launch bench with 2000 total connection, 500 concurent connection
0 message(s) send by client
1 worker(s)
WS server : faye
trying : 500 ...
trying : 1000 ...
trying : 1500 ...
trying : 2000 ...

#### steps report ####
┌────────┬─────────────┬────────┬──────────────┐
│ Number │ Connections │ Errors │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┤
│ 500    │ 500         │ 0      │ 6452         │
├────────┼─────────────┼────────┼──────────────┤
│ 1000   │ 500         │ 0      │ 9394         │
├────────┼─────────────┼────────┼──────────────┤
│ 1500   │ 500         │ 0      │ 12772        │
├────────┼─────────────┼────────┼──────────────┤
│ 2000   │ 500         │ 0      │ 16163        │
└────────┴─────────────┴────────┴──────────────┘
#### total report ####
┌────────┬─────────────┬────────┬──────────────┬──────────────┬──────────────┐
│ Number │ Connections │ Errors │ Message Send │ Message Fail │ Duration(ms) │
├────────┼─────────────┼────────┼──────────────┼──────────────┼──────────────┤
│ 2000   │ 2000        │ 0      │ 0            │ 0            │ 19173        │
└────────┴─────────────┴────────┴──────────────┴──────────────┴──────────────┘
*       soft    nofile  2048
*       hard    nofile  65536
fs.file-max = 100000