rate-limiting

Timed promise queue / throttle

流过昼夜 提交于 2019-11-29 11:01:05
I have a request-promise function that makes a request to an API. I'm rate-limited by this API and I keep getting the error message: Exceeded 2 calls per second for api client. Reduce request rates to resume uninterrupted service. I'm running a couple of Promise.each loops in parallel which is causing the issue, if I run just one instance of Promise.each everything runs fine. Within these Promise.each calls they lead to the same function a with a request-promise call. I want to wrap this function with another queue function and set the interval to 500 milliseconds so that a request isn't made

How to limit an Akka Stream to execute and send down one message only once per second?

大兔子大兔子 提交于 2019-11-29 10:26:44
I have an Akka Stream and I want the stream to send messages down stream approximately every second. I tried two ways to solve this problem, the first way was to make the producer at the start of the stream only send messages once every second when a Continue messages comes into this actor. // When receive a Continue message in a ActorPublisher // do work then... if (totalDemand > 0) { import scala.concurrent.duration._ context.system.scheduler.scheduleOnce(1 second, self, Continue) } This works for a short while then a flood of Continue messages appear in the ActorPublisher actor, I assume

How to limit rate of requests to web services in Python?

て烟熏妆下的殇ゞ 提交于 2019-11-29 09:03:16
问题 I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit , to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that

How to implement distributed rate limiter?

筅森魡賤 提交于 2019-11-29 06:47:01
问题 Let's say, I have P processes running some business logic on N physical machines. These processes call some web service S, say. I want to ensure that not more than X calls are made to the service S per second by all the P processes combined. How can such a solution be implemented? Google Guava's Rate Limiter works well for processes running on single box, but not in distributed setup. Are there any standard, ready to use, solutions available for JAVA? [may be based on zookeeper] Thanks! 回答1:

What is the best way to implement a rate-limiting algorithm for web requests?

ぃ、小莉子 提交于 2019-11-28 15:49:09
Possible/partial duplicates: What’s a good rate limiting algorithm? Throttling method calls to M requests in N seconds Best way to implement request throttling in ASP.NET MVC? I am looking for the best way to implement a moving time window rate limiting algorithm for a web application to reduce spam or brute force attacks. Examples of use would be "Maximum number of failed login attempts from a given IP in the last 5 minutes", "Maximum number of (posts/votes/etc...) in the last N minutes". I would prefer to use a moving time window algorithm, rather than a hard reset of statistics every X

Timed promise queue / throttle

☆樱花仙子☆ 提交于 2019-11-28 04:27:58
问题 I have a request-promise function that makes a request to an API. I'm rate-limited by this API and I keep getting the error message: Exceeded 2 calls per second for api client. Reduce request rates to resume uninterrupted service. I'm running a couple of Promise.each loops in parallel which is causing the issue, if I run just one instance of Promise.each everything runs fine. Within these Promise.each calls they lead to the same function a with a request-promise call. I want to wrap this

How To Rate-Limit An API [closed]

牧云@^-^@ 提交于 2019-11-28 03:01:54
What is the best way to limit requests for an API? Basically, we want to limit users to 360 API requests an hour (a request every 10 seconds). What comes to mind is tracking every API request and storing: ip-address hourly-requests 1.2.3.4 77 2.3.4.5 34 3.4.5.6 124 If the ip-address requests is greater than 360, simply return a header with: 429 - Too Many Requests Then rollback the counter hourly-requests every hour. This seems like an very inefficient method, since we have to make a MySQL query on every API request to increment the counter. Also, we would need a cron task to reset all

Swing rate limiting

梦想与她 提交于 2019-11-28 02:07:44
问题 I have a long repaint operation that I would like to rate-limit, ie make sure it gets called once every N milliseconds at most. My current solution is somewhat unsatisfactory: I use a Swing Timer with a short duration, which I restart() whenever I get an event. This make sure that a repaint is not triggered if events happen within an N milliseconds window (i.e. the repaint will happen after an event and an N milliseconds "quiet" period has elapsed). What I would like is to make sure the

What is the best way to implement a rate-limiting algorithm for web requests?

我的未来我决定 提交于 2019-11-27 19:52:39
问题 Possible/partial duplicates: What’s a good rate limiting algorithm? Throttling method calls to M requests in N seconds Best way to implement request throttling in ASP.NET MVC? I am looking for the best way to implement a moving time window rate limiting algorithm for a web application to reduce spam or brute force attacks. Examples of use would be "Maximum number of failed login attempts from a given IP in the last 5 minutes", "Maximum number of (posts/votes/etc...) in the last N minutes". I

Firebase rate limiting in security rules?

对着背影说爱祢 提交于 2019-11-26 12:16:46
I launched my first open repository project, EphChat , and people promptly started flooding it with requests. Does Firebase have a way to rate limit requests in the security rules? I assume there's a way to do it using the time of the request and the time of previously written data, but can't find anything in the documentation about how I would do this. The current security rules are as follows. { "rules": { "rooms": { "$RoomId": { "connections": { ".read": true, ".write": "auth.username == newData.child('FBUserId').val()" }, "messages": { "$any": { ".write": "!newData.exists() || root.child(