對於python的web,比如flask使用的werkzeug,首先找到wsgi的請求和響應的代碼,使用算法實現大文件的小速率上傳和下載
考慮python實現socket限流
關於限速的討論:https://www.v2ex.com/t/142992
前端限速:比如瀏覽器就可以模擬各類速度;https://github.com/tjgq/node-stream-throttle;https://keelii.github.io/2016/06/11/javascript-throttle/
服務器限速:利用tcp滑動窗口和tcp的擁塞算法
網關nginx限流:可以限制訪問頻率和數據傳輸速度。http://nginx.org/en/docs/http/ngx_http_limit_req_module.html;http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
參考:
1、https://github.com/titan-web/rate-limit
2、https://github.com/rbarrois/throttle
3、https://caden16.github.io/python/python%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6/
4、http://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/
5、https://github.com/shengulong/socket-throttle
6、http://itindex.net/detail/54592-nginx
7、https://www.zhihu.com/question/32255109