Skip to content

Latest commit

 

History

History

27

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Challenge 27 - Write Your Own Rate Limiter

This challenge corresponds to the 27th part of the Coding Challenges series by John Crickett https://codingchallenges.fyi/challenges/challenge-rate-limiter.

Description

This is a Node.js implementation of the following Rate limiter algorithms:

All the algorithms are present in algorithms/ directory. They are very well documented with self explanatory code.

Note: All the algorithms support rate limiting based on the client's IP address.

Usage

You can use the ts-node tool to run the NATS server as follows:

npx ts-node <path/to/index.ts> <algorithm>

Possible values for the algorithm are:

  • token-bucket
  • fixed-window-counter
  • sliding-window-log
  • sliding-window-counter
  • redis-sliding-window-counter

The default configurations are present in index.ts for the the command line version of the Rate limiter tool.

You can also use the createRateLimiterServer function defined in server.ts in your code to get total control over the configurations.

Run tests

To run the tests for the Rate Limiter, go to the root directory of this repository and run the following command:

npm test src/27/

TODO

  • Add command line support for rate limiter args.
  • Add Global rate limiting constraints with all algorithms.