1.搭建一個ngx服務器,放置配置文件包,提供給2000+台VPS讀取下載,考慮到帶寬占用的問題,決定在nginx上做下載限速處理。
環境:centos7+nginx1.12
根據官方文檔如下:
2.對nginx.conf進行配置:
http { ... limit_conn_zone $binary_remote_addr zone=addr:10m; # 添加該行 ... include vhost/*.conf; }
3.配置server模塊
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/s
參考和轉載自:https://www.cnblogs.com/hukey/p/6072904.html