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 smart Rate Limiter #1101

Open
4 of 9 tasks
seratch opened this issue Aug 19, 2021 · 1 comment
Open
4 of 9 tasks

Add smart Rate Limiter #1101

seratch opened this issue Aug 19, 2021 · 1 comment
Labels
Milestone

Comments

@seratch
Copy link
Member

seratch commented Aug 19, 2021

Now that we have a built-in retry handler for rate limited errors in v3.9, retrying a request after getting rate-limited is much easier than before.

However, getting rate-limited results in a much longer execution time as the whole operation. As a solution for this pain point, we will add a built-in traffic control layer like we do in the Java SDK: https://slack.dev/java-slack-sdk/guides/web-api-basics#rate-limits

A few points to consider for implementing this feature:

  • The module manages the amount of requests in the last minute and calculate the interval before the next API call
  • Metrics data can be in memory in most use cases but the part should be extensible to switch to other data storage (e.g., Redis)
  • As we do in the Java SDK, running the same script/app in multiple hosts should be supported.
  • For backward-compatibility, we don't turn the feature on by default. Users can enable it only when they want it.
  • Both sync and async API clients should be supported in a proper way (= don't use time.sleep in asyncio apps)
  • All API clients (Web API, Audit Logs, SCIM, Webhook) should have the functionality.

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.models (UI component builders)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.rtm (RTM client)
  • slack_sdk.signature (Request Signature Verifier)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@seratch seratch modified the milestones: 3.10.0, 3.11.0 Aug 19, 2021
@seratch seratch modified the milestones: 3.11.0, 3.12.0 Sep 9, 2021
@seratch seratch modified the milestones: 3.12.0, 3.13.0 Oct 17, 2021
@seratch seratch modified the milestones: 3.13.0, 3.x Dec 7, 2021
@seratch
Copy link
Member Author

seratch commented Feb 11, 2022

I've implemented a similar thing in the Discovery API SDK: https://github.com/slackapi/python-slack-discovery-sdk/blob/main/slack_discovery_sdk/rate_limit_support.py The ones for the APIs supported by this SDK (especially the Web APIs) would require a bit more complex logic, though.

ErikKalkoken referenced this issue in ErikKalkoken/slackchannel2pdf Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant