首页 > 解决方案 > 如何在 nginx 上配置连接数?

问题描述

limit_conn_zone $binary_remote_addr   zone=perip:10m;    

server {
    listen 80;
    server_name   wx110.cn;
    root /data/www/wx120;

    limit_conn  perip 10;

    location / {
        index  index.html ;
    }
}

ab -n 100 -c 100 http://wx110.cn/test.html


结果:完成请求:100 失败请求:0

标签: nginx

解决方案


您的配置似乎一切正常。我猜测试过程有问题。尝试执行此代码:for i in {0..2000}; do (curl -Is http://wx110.cn/ | head -n1 &) 2>/dev/null; done.

我建议您在配置文件中启用访问日志:access_log /var/log/nginx/wx110.cn.log;. 然后您将能够在测试时监控日志文件:tail -f /var/log/nginx/wx110.cn.log


推荐阅读