Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fast fail when token bucket empty #3179

Open
1 of 2 tasks
jamesls opened this issue May 16, 2024 · 0 comments
Open
1 of 2 tasks

Add support for fast fail when token bucket empty #3179

jamesls opened this issue May 16, 2024 · 0 comments
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue

Comments

@jamesls
Copy link
Member

jamesls commented May 16, 2024

Describe the feature

In adaptive mode, acquiring a send token from the token bucket always blocks:

self._token_bucket.acquire()

def acquire(self, amount=1, block=True):

We should also support the fast fail mode (block=False) where we propagate a client exception when the token bucket is empty.

Use Case

This is required behavior for the SDKs to allow the option to fast fail when the token bucket is empty.

The use case here is that propagating the token bucket acquisition failure lets the caller decide what to do. They could then continue to propagate that up the stack until something has enough context to decide the best course of action. With the current behavior of blocking, the caller has to always accept a block.

A concrete scenario of this would be when botocore is being used in the context of a web service. In some cases, the desired behavior when the token bucket is empty is to send back a 429/4xx response back to the caller asking them to slow down instead of the request handler blocking until capacity becomes available.

Proposed Solution

  • Add some config option in the retries dict of the config option. Not sure what to call it, maybe fast_fail, token_bucket_block, etc. Open to ideas.
  • Plumb this through into the retry handler.
  • Add a new exception when this condition is hit, maybe class NoCapacityError(BotoCoreError), class TokenBucketThrottleError(BotoCoreError)?

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

All

Environment details (OS name and version, etc.)

All

@jamesls jamesls added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
@nateprewitt nateprewitt added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants