Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public Invoke<InputT, OutputT> withThrottleDelaySecs(int throttleDelaySecs) {

/**
* Configures the length of history to consider when setting throttling probability. Defaults to
* a sample period of 1000ms. For more context, see {@link AdaptiveThrottler}
* a sample period of 120000ms. For more context, see {@link AdaptiveThrottler}
*/
public Invoke<InputT, OutputT> withSamplePeriodMs(long samplePeriodMs) {
checkArgument(samplePeriodMs > 0, "samplePeriodMs must be positive");
Expand Down Expand Up @@ -239,7 +239,7 @@ static class RemoteInferenceFn<InputT extends BaseInput, OutputT extends BaseRes
this.handlerClass = spec.handler();
this.parameters = spec.parameters();
this.throttleDelaySecs = spec.throttleDelaySecs() != null ? spec.throttleDelaySecs() : 5;
this.samplePeriodMs = spec.samplePeriodMs() != null ? spec.samplePeriodMs() : 1000L;
this.samplePeriodMs = spec.samplePeriodMs() != null ? spec.samplePeriodMs() : 120000L;
this.sampleUpdateMs = spec.sampleUpdateMs() != null ? spec.sampleUpdateMs() : 1000L;
this.overloadRatio = spec.overloadRatio() != null ? spec.overloadRatio() : 2.0;
retryHandler = RetryHandler.withDefaults();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,6 @@ public void testThrottlingBehavior() {
RemoteInference.<TestInput, TestOutput>invoke()
.handler(MockThrottlingHandler.class)
.withBatchConfig(batchConfig)
// Use large sample periods so the 1s retry delay doesn't flush the history
.withSamplePeriodMs(60000L)
.withSampleUpdateMs(60000L)
// Set to 1 second to minimize test wait time while still verifying throttling
.withThrottleDelaySecs(1)
.withOverloadRatio(1.1)
Expand Down
4 changes: 2 additions & 2 deletions sdks/python/apache_beam/io/components/adaptive_throttler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ class ReactiveThrottler(AdaptiveThrottler):
system recovery. capture the timestamp of the attempted request, then execute
the request code. On a success, call successful_request(timestamp) to report
the success to the throttler. This flow looks like the following:

def remote_call():
throttler.throttle()

try:
timestamp = time.time()
timestamp = time.time() * 1000
result = make_request()
throttler.successful_request(timestamp)
return result
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/ml/inference/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def __init__(
throttle_delay_secs: int = 5,
retry_filter: Callable[[Exception], bool] = lambda x: True,
*,
window_ms: int = 1 * _MILLISECOND_TO_SECOND,
window_ms: int = 120 * _MILLISECOND_TO_SECOND,
bucket_ms: int = 1 * _MILLISECOND_TO_SECOND,
overload_ratio: float = 2,
rate_limiter: Optional[RateLimiter] = None):
Expand Down
Loading