-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SessionBase: move to a generalized cost metric
I've long wanted a more generic cost metric for requests than simply bandwidth. SomberNight's kyuupichan/electrumx#785 prompted me to implement something reasonably generic and configurable. Features: - generalized res_usage metric with time decay - bandwidth consumption contributes to the resource consumption - derived classes can add to the resource usage count freely, such as on a per-request basis - derived classes can provide an extra "soft" cost. This could come from IP address bucketing, session grouping, or anything. This is soft because it is not counted as part of the session's recorded resource usage, it is only temporarily added for the purpose of calculating the throttling rate. - soft and hard limits. Once resource usage (including the soft amount) hits the soft limit, request concurrency for the session begins to reduce and each request sleeps a little. As resource usage grows to the hard limit, the sleeps increase and the concurrency reduces further. If the hard limit is exceeded the session is closed - most limits and parameters are configurable
- Loading branch information
Neil Booth
committed
Apr 10, 2019
1 parent
0d96937
commit b227888
Showing
4 changed files
with
173 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters