nginx - 如何在 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
解决方案
您的配置似乎一切正常。我猜测试过程有问题。尝试执行此代码: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
推荐阅读
- android - 在撰写 UI 测试中添加意图附加功能
- dotenv - 究竟什么是 .env(或 dotenv)文件?
- cassandra - 如何在 Amazon Keyspaces/Cassandra 中列出不同键空间中的可用表?
- php - 如何在简单的 HTML 或 PHP 页面中对图像、css、js 和其他静态文件使用 HTTP2?
- selenium - PyCharm - PyTest 测试发现/显示可用测试而不运行它们
- python - FastAPI 中的返回图
- installation - Prestashop 1.7.7.5 安装问题:ps_facebook1
- gridstack - Gridstack js嵌套无法正常工作
- php - Laravel - 如何在日期字符串中检查当前月份?
- amazon-web-services - AWS EKS 中服务相关角色和 IRSA 之间的访问级别差异