Ogeon / rustful

[OUTDATED] A light HTTP framework for Rust
https://docs.rs/rustful
Apache License 2.0
862 stars 51 forks source link

Use the new handler hooks in Hyper for congestion control #65

Closed Ogeon closed 9 years ago

Ogeon commented 9 years ago

The Hyper Handler trait has gained pre- and post-connection hooks that can be used to keep track of how many open connections, and thereby occupied threads, there are in the server. This can be used, as a sort of congestion control, to close connections when the number of occupied threads becomes too high. It's not a solution, but it may prevent the servers from freezing under heavy load until async IO is implemented.

Easiest way to do this is to have a counter that counts up when the connection is opened, and down when it's closed. The Connection::Close header when it reaches a maximal value. It's probably best if this value is user defined, ideally as a minimal number of free threads.