python实现网速控制,限制上传下载速度

  对于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

原文地址:https://www.cnblogs.com/shengulong/p/9030448.html