Ogeon/rustful

Use the new handler hooks in Hyper for congestion control

Closed this issue · 0 comments

Ogeon commented

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.