offsnore/wundernode

Rate limiting

Opened this issue · 1 comments

The example isn't terribly clear on what the last two parameters in new WunderNodeClient(apikey, debug, 10, 'minute'); mean, but it looks like it's using the limiter library to limit the request rate on API calls.

I've got an app making an identical call to wunder.conditions once a minute. I set rateCount: 10, rateTime: minute, which I assume means it would only make a request every 10 minutes, and then cache the results. However, about 10 hours later I got an email telling me I'd exceeded 500 requests. By my math, I should have only made 60 (every 10 minutes = 6 per hour * 10 hours). Am I misunderstanding those options, or is this a bug? Is it maybe 10 requests per minute?

The underlying rate limiter package doesn't seem to work. I never got around to looking into it/fixing it, but have noticed the same thing in my running production instance. The best I was able to do was assume all requests are 'per minute' limited. I should look into this more and see what can be done, but for now I would work off the assumption of a per/minute limit and then set your request usage to fire every hour (that's how I do it).

I understand the challenge though: per minute limiting plus per day cap limiting in one would be ideal, but it's not there yet.