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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM