Feature #1050
closedAdd a bandwidth throttle that is aware of previous underusage
Description
I would like to see an option where as well as the fixed server-wide bytes/sec bandwidth limit there was a 2nd limit where it ensured the long term average bandwidth did not exceed a predefined limit. This would allow those of us renting dedicated servers to ensure we do not get bandwidth overage charges from the hosting company without restricting peak server bandwidth. They way I'd like it to work is as follows:
1. In the configuration file you supply three configuration options:
a) The day of the month that is your billing day
b) Your monthly transfer allowance in GB.
c) The number of days in the month for billing purposes. This may not be a whole number. If this is not supplied the number of days in the calendar month is used.
The reason for c) is that some hosting providers assume there are 30.5 days in the month, divide your monthly transfer allowance and then bill for a bandwidth overage if your average data rate exceeds the computed rate regardless of how many days there actually were in the month in question.
2. On startup lighttpd calculates an average bandwidth rate per second that corresponds to the monthly allowance GB, using the configuration option in 1c above or the calendar days between the last and the next billing day if the configuration option was not supplied.
3. When sending bytes, lighttpd records how many bytes are sent in the current second.
4. At the end of the second, if the number of bytes sent was less than the average allowed, the remaining bytes are added to a spare bandwidth counter. The bytes sent this second is reset to 0.
5. When sending bytes, if the bytes sent hits the average bandwidth rate and there are bytes in the spare bandwidth counter, allow the data to be sent without throttling and decrease the spare bandwidth counter by the number of bytes sent that were above the average rate. If there are not enough bytes in the spare bandwidth counter, throttle the output till the next second.
You can also still throttle the output for other reasons such as the per connection limit or the current hard server limit being reached.
6. At midnight on the monthly billing day, reset the spare bandwidth counter to 0 and recalculate the average bandwidth rate for the next month.
Ideally I would like to see it measure input bytes as well although I suspect that is more complicated.
-- Jay Rabbit
Updated by gstrauss about 9 years ago
Please close ticket. I do not think this should be implemented. There are too many variables with today's cloud architecture, which can have multiple separate virtual servers running. Along with server restarts losing certain amounts of state, the accuracy of implementing this would be dubious.
As an alternative, you might have a script which periodically queries your provider for your bandwidth usage, and then reconfigures and restarts lighttpd.conf with a new max-rate if you extrapolate bandwidth usage between now and the end of the month.
Updated by stbuehler about 9 years ago
- Description updated (diff)
- Status changed from New to Wontfix
- Assignee deleted (
jan)
Also available in: Atom