Scalable Rate Limiter

A professional quality rate limiter that horizontally scales with Redis and eliminates race conditions

Prerequisites

Redis needs to be required in and setup to use the correct host and credentials. https://www.npmjs.com/package/redis

npm install redis

Installing

To install the library from NPM:

npm install scalable-rate-limiter

To instantiate the rate limiter and call it for API requests

let redis = require ( " redis " ) , redisClient = redis . createClient ( ) , limiter = new RateLimiter ( redisClient , false , 5 , 3 , ' .rate.limiter ' ) ;

To use the rate limiter:

limiter . rateLimitFunction ( userID , ( limited ) => { if ( ! limited ) { apiCall ( ) } } )

Contributing

This is licensed under MIT. Please feel free to make pull requests for main features under this license.

Wish list:

1) Allow the rate limiter to have multiple limits or thresholds 2) Use options object to simulate named parameters

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments