Skip to content
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

ConcurrencyLimitLayer that rejects requests instead of queueing it #793

Open
lcmgh opened this issue Sep 2, 2024 · 1 comment
Open

ConcurrencyLimitLayer that rejects requests instead of queueing it #793

lcmgh opened this issue Sep 2, 2024 · 1 comment

Comments

@lcmgh
Copy link

lcmgh commented Sep 2, 2024

https://docs.rs/tower/latest/tower/limit/concurrency/struct.ConcurrencyLimitLayer.html

Does it delay responses or does it return an error in case the concurrency limit is met? And if yes which status code?

Edit: From my observation it delays the req/response processing. How would I reject the request when concurrency limit is met (to protect service from accumulating too many yet unprocessed requests)?

@lcmgh lcmgh changed the title document concrete behavior of ConcurrencyLimitLayer ConcurrencyLimitLayer that rejects requests instead of queueing it Sep 2, 2024
@jlizen
Copy link
Contributor

jlizen commented Dec 24, 2024

The general approach would be to use a load shed layer outside it: https://docs.rs/tower/latest/tower/load_shed/struct.LoadShed.html

However this would also drop requests if any other inner service returned pending on poll_ready().

I think that there is probably a place for adding a knob to the concurrency layer, personally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants