question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provides a throttling strategy based on the number of pending blocking tasks.

See original GitHub issue

If 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:open
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ikhooncommented, Jan 17, 2022

What about serving throttling strategy with the mutable limiting size?

Sounds good to me. I think we can take the IntSupplier style we did in https://github.com/line/armeria/pull/3985.

1reaction
ikhooncommented, Oct 21, 2021

Thank you, can I try it?

I’m looking forward to your PR. 😆

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found