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 Limit By Applying Backpressure and Buffering #34

Open
adisoluto opened this issue May 2, 2022 · 4 comments
Open

Rate Limit By Applying Backpressure and Buffering #34

adisoluto opened this issue May 2, 2022 · 4 comments
Labels

Comments

@adisoluto
Copy link

adisoluto commented May 2, 2022

Some consumers have a limited ability to handle incoming requests. We would like to be able to protect these consumers from traffic spikes, thus, rate limiting DQD and applying backpressure.
We would like to have the ability to control how many requests are consumed and processed per time unit, while buffering the events in the queue.

The offered solution is to consume the messages at a fixed rate. For example - is the rate is 1request/second, dqd will sleep for 1 sec and consume 1 message.

Note that this solution might delay the consumption and even if the limit hasn't been exceeded.

This use case is intended to handle traffic spikes only.
If the producer is producing a higher rate of events regularly (for example 40requests/second), the buffer will never finish. Using this feature requires monitoring on the source.

Points to consider: multiple DQD instances that need to share the load.

@CHarnel
Copy link
Member

CHarnel commented May 3, 2022

A concrete use case is: events coming in batches via queue and we want to pipe them to an http endpoint which is rate limited. So we want to consume messages from the queue at a specified rate (e.g. 20 per second).

@Yshayy
Copy link
Contributor

Yshayy commented May 3, 2022

There's a support for fixed rate:
https://github.com/Soluto/dqd/blob/master/config/config.go#L124
It limits the amount of concurrency for maximum amount of processing units. (for example, only one processing unit).
Of course, it won't solve the problem if even a single processing unit is too fast.

In that case, it can be slowed by better error back off policy (which can be error based, like for 503), or alternatively, set minimum time to processing job (which is similar to rps per processing unit)

Fixed the link

@Yshayy
Copy link
Contributor

Yshayy commented May 3, 2022

Another way to implement it, is creating input/output source that does rate-limiting and create a more complex pipe, but scaling processing unit can be a bit tricky

@adisoluto
Copy link
Author

I updated the proposed solution to fixed rate consumption.

@CHarnel CHarnel added the large label May 30, 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

3 participants