Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

realize feature #1427 #1455

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

zhaxzhax
Copy link
Contributor

@zhaxzhax zhaxzhax commented Aug 7, 2020

Ⅰ. Describe what this PR did

This PR just realize dynamic bandwidth limit, the interpret is as below

cli add

--dynamic which could allow you to open the dynamic bandwidth limit mode.

api add

Add two apis, which used to send bandwidth limit update information from peerserver to supernode.

  • /api/v1/peer/{id}/peerState/{dynamicRate} The 1.0 version api.
  • /peer/dynamicrate The 0.3 version api.

field add

  • Add field DynamicRate in struct PeerState

implement scheme

  • host_bandwidth_listener listen to the host bandwidth, add set the 90% of current available bandwidth
    as totalLimit ,also as dynamicRate be sent to supernode
  • supernode use dynamicRate and ProducerLoad to calculate the priority of peer, the schedule algorithm will schedule the
    peer with higher priority first.

part which haven't implement now

  • host_bandwidth_listener

Ⅱ. Does this pull request fix one issue?

Fixes #1427

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Already added.

Ⅳ. Describe how to verify it

As issue #1427

Ⅴ. Special notes for reviews

Host_bandwidth_listener haven't been completed, which will be finished in next weeks.

@zhaxzhax
Copy link
Contributor Author

I have add the HTBListener implement, which have used Gopacket that based on libpcap.
So may be it's hard to pass the ci test.

@jim3ma
Copy link
Member

jim3ma commented Aug 19, 2020

@starnop PTAL

@zhaxzhax
Copy link
Contributor Author

The final htb-Listener implement is using this formulation (maxRate - currentRate) * 9 / 10 which means the 90% of the usable bandwidth.

  • Because the server bandwidth is limited mainly in the upstream bandwidth, so I only dynamically change the totalLimit which could only limit the server upload rate.
  • The dynamic rate change every 10 seconds, and will report it to supernode in case supernode can schedule peer download task by priority(dynamicRate/producerLoad).
  • I have removed portRate cause Dragonfly can not import too much independents such as gopacket or libpcap.
  • I have removed the maxRate detective scheme, which is replaced by user can configure config file to ensure the DynamicMaxRate. That's due to bandwidth velocity measurement could be resource wasteful. And config DynamicMaxRate by user self could be avoiding resource waste.

@zhaxzhax
Copy link
Contributor Author

Still can not pass the CI check. It seems like I am not allowed to update go.mod and go.sum. What do I be supposed to do?

@zhaxzhax
Copy link
Contributor Author

@garfield009 @ansinlee @starnop PTAL

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: a raw method to realize dynamical rate limiting
3 participants