Skip to content

Enable throttling logic in RemoteInference. - #40598

Open
tvalentyn wants to merge 2 commits into
apache:masterfrom
tvalentyn:throttler
Open

tvalentyn wants to merge 2 commits into
apache:masterfrom
tvalentyn:throttler

Conversation

@tvalentyn

@tvalentyn tvalentyn commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Change the sample period defaults to 2 min, since the previous 1 second default was to short to register a service outage: a 5 seconds retry delay wiped out the time horizon over which failed requests were collected, so throttling never kicked in.

Note: Python's AdaptiveThrottler checks whether to throttle multiple times per attempt, while the Java ReactiveThrottler seems to only throttle once.

@tvalentyn

Copy link
Copy Markdown
Contributor Author

R: @jrmccluskey

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@tvalentyn tvalentyn changed the title Enable throttling logic. Enable throttling logic in RemoteInference. Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.49%. Comparing base (76f6e6d) to head (5590cee).
⚠️ Report is 200 commits behind head on master.

Files with missing lines Patch % Lines
.../beam/sdk/ml/inference/remote/RemoteInference.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #40598       +/-   ##
=============================================
+ Coverage     56.16%   71.49%   +15.32%     
- Complexity     2288    13992    +11704     
=============================================
  Files          1124     2217     +1093     
  Lines        178336   191033    +12697     
  Branches       1489    11310     +9821     
=============================================
+ Hits         100170   136570    +36400     
+ Misses        75645    50255    -25390     
- Partials       2521     4208     +1687     
Flag Coverage Δ
go ?
java 65.07% <0.00%> (-10.72%) ⬇️
python 79.92% <ø> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrmccluskey
jrmccluskey self-requested a review October 15, 2026 14:25
Comment thread sdks/python/apache_beam/io/components/adaptive_throttler.py Outdated
"""
while self.throttle_request(time.time() * _SECONDS_TO_MILLISECONDS):
if self.throttle_request(time.time() * _SECONDS_TO_MILLISECONDS):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think delaying a request at most one time is the correct behavior here. Each iteration in the while() loop is a separate attempt and the throttling behavior is a local rejection, not just a time delay before forwarding the request to the service. At steady state with a throttle probability of 1.0 you're not really rejecting any requests locally, just delaying them by the throttle delay before sending them to the service anyway. At that point you might as well just fail fast and have the exponential backoff on retries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow why delaying the request each time counts as a separate request - doesn't it artificially inflate the volume of the requests?

@tvalentyn tvalentyn Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it correct to say that with the while loop approach, each decision to throttle (delay) a request during the while loop iteration increases the probability that the attempt on the following iteration of the loop will also be throttled?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, and that is intended. To quote the overview of the algorithm:

"As the client itself starts rejecting requests, requests will continue to exceed accepts. While it may seem counterintuitive, given that locally rejected requests aren't actually propagated to the backend, this is the preferred behavior. As the rate at which the application attempts requests to the client grows (relative to the rate at which the backend accepts them), we want to increase the probability of dropping new requests."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, yes, this is not intuitive. Ok, i reverted this change. Altought seems like we might not be consistent across SDKs on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants