Provides a throttling strategy based on the number of pending blocking tasks.
See original GitHub issueIf all threads of a BlockingTaskExecutor are busy, a new incoming request is enqueued and will wait until its turn comes.
It will cause GC pressure and a response will be sent when the request is timed out.
Even though the request was timed out, the blocking task executor will execute regardless of the state of the request.
It would be useful to throttle incoming requests based on the queue size of BlockingTaskExecutor
class BlockingTaskLimitingThrottlingStrategy<T extends Request> extends ThrottlingStrategy<T> {
@Override
public CompletionStage<Boolean> accept(ServiceRequestContext ctx, T request) {
var theadPoolExecutor = getTheadPoolExecutor(ctx.blockingTaskExecutor());
if (theadPoolExecutor.getQueue.size() > MAX_QUEUE_SIZE) {
CompletableFuture.completedFuture(false);
} else {
CompletableFuture.completedFuture(true);
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Fix "Throttled by Zapier" or "Zapier has blocked this task ...
SymptomsThis error is most likely to show up in your Zap run details in various forms: "Too much data received for one task...
Read more >Service throttle logic - Amazon Elastic Container Service
The Amazon ECS service scheduler includes logic that throttles how often service tasks are launched if they repeatedly fail to start.
Read more >Throttle Concurrent Builds - Jenkins Plugins
This plugin allows for throttling the number of concurrent builds of a project running per node or globally.
Read more >Throttling pattern - Azure Architecture Center | Microsoft Learn
An alternative strategy to autoscaling is to allow applications to use resources only up to a limit, and then throttle them when this...
Read more >c# - Throttling asynchronous tasks - Stack Overflow
The following simple solution has surfaced many times here on SO. It doesn't use blocking code and doesn't create threads explicitly, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sounds good to me. I think we can take the
IntSupplierstyle we did in https://github.com/line/armeria/pull/3985.I’m looking forward to your PR. 😆