Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting rate of requests with Reactor

I'm using project reactor to load data from a web service using rest. This is done in parallel with multiple threads. I'm starting to hit rate limits on the web service, so I would like to send at most 10 requests per second to avoid getting these errors. How would I do that using reactor?

Using zipWith(Mono.delayMillis(100))? Or is there some better way?

Thank you

like image 987
Mavo Avatar asked May 05 '17 08:05

Mavo


People also ask

What is rate limiting in spring boot?

2. API Rate Limiting. Rate limiting is a strategy to limit access to APIs. It restricts the number of API calls that a client can make within a certain time frame. This helps defend the API against overuse, both unintentional and malicious.

What is the purpose of rate limiting?

Rate limiting is a strategy for limiting network traffic. It puts a cap on how often someone can repeat an action within a certain timeframe – for instance, trying to log in to an account. Rate limiting can help stop certain kinds of malicious bot activity. It can also reduce strain on web servers.

What are rate limiting types?

LinkedIn's API features three different kinds of rate limiting: application throttle, user throttle, and developer throttle. The documentation also specifies the time zone used to define the beginning and end of the day.


1 Answers

You can use delayElements instead of the whole zipwith.

like image 98
Simon Baslé Avatar answered Oct 24 '22 14:10

Simon Baslé