Skip to content

Design a rate limiter using Go and Redis to deny requests when they go over the threshold.

Notifications You must be signed in to change notification settings

lowc1012/rate-limiter-with-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rate-limiter-with-go

Rate limiting strategies

This implementation supports the following rate limiting strategies:

  • Token bucket
  • Leaky bucket
  • Fixed window (TODO)
  • Sliding window (TODO)

Run this example

By default, this implementation is used a fixed-window strategy. Clients are allowed to make 10 requests every minute. Once they go over 10 requests, application start denying the requests letting them know they’re over their quota and need to wait.

go run main.go

# execute this instruction many times
curl --header "X-Forwarded-For: 127.0.0.1" localhost:8080/api/v1/hello

About

Design a rate limiter using Go and Redis to deny requests when they go over the threshold.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages