Add support for concurrent request limits and queue size - #43
Conversation
|
Not sure there's a better way to do it. Worker threads are a subtly different way to tune concurrent throughput based on worker availability. |
|
is there any case when you would want more worker threads than concurrent requests, or vice versa? Im thinking to drop the concurrent requests parameter, and set the max concurrent request to worker-threads? (only if queue size set, otherwise no changes to how it is. |
|
I think they're just different ways to do limiting. With max requests you control the queue of requests before you start dropping them, so even if you have a single worker you can limit how many requests you allow to build up. Meanwhile, the worker threads control how many requests you're processing at a time. |
|
Hmm. As an example: |
|
I don't think you'd want to use all of these settings together though. In practice, you'd probably pick one of them based on what you're aiming to limit. So, I think it is about maximizing control for the user where they can choose what knobs they want to tune. I wouldn't conflate different settings implicitly though. I think if the user wants to set |
|
I agree that you want to be able to tune each knob independently. The issue I'm concerned about is exactly that - someone (like me a month ago) wanting to limit the queue, and only setting the Doing some (AI) research, I believe the only way to limit the queue size directly would be to make a completely custom handler. Which seems hard and potentially error prone.. So anyway, as long as we're on the same page about that nastiness with
Please let me know your thoughts |
|
I'm thinking let's document the gotcha, and another option could be to add a new flag that does explicitly set both. We could mention in the docs that that's the sensible default, something like |
|
I like that, maybe just |
|
Sure let's do that, seems reasonable. And if somebody has a use case where they need more freedom can always add more options later. |
This is useful to prevent server overloading, and quickly recover from traffic spikes.
|
Ok, I've updated the PR now. |
|
The readme update looks good thanks, and just pushed out 1.4.4 with the new features. 🎉 |
|
Thanks!!! |
|
Awesome, definitely keep me posted on how things go. Always great to see the libraries actually get used for real world stuff like that. :) |
Fixes #39
Works fine as is, but it seems odd that this kinda but not really duplicates the :worker-threads option. I need to think though, or discuss, how that should work. I feel like there might be an obvious answer.
Also cleaned some minor things, I can split that out into a separate commit, or skip it depending on your thoughts.