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

Rate-limiting #8

Closed
Xopherus opened this issue Nov 24, 2017 · 1 comment
Closed

Rate-limiting #8

Xopherus opened this issue Nov 24, 2017 · 1 comment

Comments

@Xopherus
Copy link
Contributor

For some microservices it might be beneficial to rate-limit the number of active goroutines based on time. For example, if I have a Server which interacts with a third-party API and that is limited to 10 calls/sec, I would only want to serve 10 messages/second (assuming each message uses 1 API call).

With the current primitives, this rate limiting would have to be done at the Receiver level, which would introduce blocking by means of mutexes or channels - that's probably not the most efficient. We should consider adding this capability to the Server so we can limit the number of active Receivers based on time.

@Xopherus
Copy link
Contributor Author

One strategy we've tried with #21 is to allow the Receiver to return a specific error message to the Server to indicate when to throttle. This works really well in situations where it's more likely that another resource needs to be rate-limited, such an upstream API, or database. In that scenario it's unlikely that a per-Server throttle will suffice - you need to have a shared throttling mechanism.

For now I think we'll accept #21 as the default mechanism for throttling, though happy to revisit this in the future if necessary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant