jrmccluskey commented on code in PR #40598:
URL: https://github.com/apache/beam/pull/40598#discussion_r4285849527
##########
sdks/python/apache_beam/io/components/adaptive_throttler.py:
##########
@@ -173,14 +185,16 @@ def __init__(
window_ms=window_ms, bucket_ms=bucket_ms,
overload_ratio=overload_ratio)
def throttle(self):
- """ Stops request code from advancing while the underlying
- AdaptiveThrottler is signaling to preemptively throttle the request.
- Automatically handles logging the throttling and signaling to the SDK
- harness that the request is being throttled. This should be called in any
- context where a call to a remote service is being contacted prior to the
- call being performed.
+ """ Delays the request by throttle_delay_secs if the underlying
+ AdaptiveThrottler elects to preemptively throttle it, based on the failure
+ rate of recent requests. Automatically handles logging the throttling and
+ signaling to the SDK harness that the request is being throttled.
+
+ This should be called once for each attempt to contact a remote
+ service (including retries), prior to the call being performed. Each call
+ is recorded as one request attempt, and delays the request at most once.
"""
- while self.throttle_request(time.time() * _SECONDS_TO_MILLISECONDS):
+ if self.throttle_request(time.time() * _SECONDS_TO_MILLISECONDS):
Review Comment:
That is correct, and that is intended. To quote the [overview of the
algorithm](https://sre.google/sre-book/handling-overload/#client-side-throttling-a7sYUg):
"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."
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]