1.搭建一个ngx服务器,放置配置文件包,提供给2000+台VPS读取下载,考虑到带宽占用的问题,决定在nginx上作下载限速处理。html
环境:centos7+nginx1.12nginx
根据官方文档以下:centos
2.对nginx.conf进行配置:服务器
http { ... limit_conn_zone $binary_remote_addr zone=addr:10m; # 添加该行 ... include vhost/*.conf; }
3.配置server模块centos7
server { listen *:8080; server_name localhost; location / { root /usr/local/test; index index.html; limit_conn addr 1; # 每一个客户端只容许一个线程。 limit_rate 100k; # 每一个线程最大下载速度100k } }
每一个客户端最终的下载速度 = limit_conn * limit_rate 我这里很明显是100kb/sspa
参考和转载自:https://www.cnblogs.com/hukey/p/6072904.html线程