-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for load-shedding. #1616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When the per-connection service is not ready this gives an option of immediately rejecting requests.
Setting @abizjak did you get a chance to work on this issue? |
@@ -73,7 +73,7 @@ h2 = {version = "0.3.17", optional = true} | |||
hyper = {version = "0.14.26", features = ["full"], optional = true} | |||
hyper-timeout = {version = "0.4", optional = true} | |||
tokio-stream = "0.1" | |||
tower = {version = "0.4.7", default-features = false, features = ["balance", "buffer", "discover", "limit", "load", "make", "timeout", "util"], optional = true} | |||
tower = {version = "0.4.7", default-features = false, features = ["balance", "buffer", "discover", "limit", "load", "make", "timeout", "util", "load-shed"], optional = true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the features here in alphabetic order?
let err = match err.downcast::<tower::load_shed::error::Overloaded>() { | ||
Ok(_) => { | ||
return Ok(Status::resource_exhausted( | ||
"Too many active requests for the connection", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the majority of our messages are lowercase, so please match that here.
Add an option to enable load shedding for the service constructed for the connection.
Motivation
In the server we are implementing we want to load-shed when the service is overloaded, and we want to limit the number of concurrent requests per connection. We use tower::load_shed layer for load shedding, but this only applies to the entire service.
If we additionally apply the per-connection concurrency limit the issue is that this limit is typically hit first and so the service responds with "not ready". As a result the load-shed layer of the service is never reached meaning that requests just queue up.
Solution
The solution is to optionally add a load-shed layer to the per-connection service constructed by tonic.