jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.5k stars 132 forks source link

Example usage with limits per api user #7

Closed facultymatt closed 10 years ago

facultymatt commented 10 years ago

I have the following situation,

How would I configure node-rate-limiter for this setup?

jhurliman commented 10 years ago

Just to clarify, are you writing clients for an existing public API and you want to limit your clients, or are you writing a public API that will have multiple clients connecting and you want to rate limit each client?

facultymatt commented 10 years ago

b, Im writing a public API that will have multiple clients connecting and you want to rate limit each client.

jhurliman commented 10 years ago

Apologies for this falling off my plate, but a similar question was just asked in issue #8 where I posted some ideas on getting started. Like I said in that thread, the full implementation of what you're asking for is out of scope for this project but it likely involves a per-IP or per-apiKey expiring cache of rate limiter objects. If your setup involves a cluster of web servers you would need some policy that maps clients with the same apiKey to the same webserver to properly enforce the rate limit.

matejkramny commented 10 years ago

Take a look at https://github.com/visionmedia/node-ratelimiter