Skip to content

AugustWikdahl/rate-limiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Distributed Rate Limiter

A rate limiter service built with Go. It uses Redis to store data (so it works across multiple servers) and gRPC for internal communication.

How it Works

  1. User sends a request to the HTTP API.
  2. Middleware asks the gRPC Service: "Can this IP pass?"
  3. Service checks the count in Redis using a Lua script.
  4. If allowed, the request goes through. If not, it returns 429 Too Many Requests.

Tech Stack

  • Go (Server & Logic)
  • Redis (Database for counting tokens)
  • gRPC/Protobuf (Communication between services)
  • Docker (To run Redis)

How to Run

  1. Start Redis

    docker run -d -p 6379:6379 redis
  2. Start the Server

    go run cmd/server/main.go
  3. Test it Run this in your terminal to spam requests:

    for i in {1..10}; do curl http://localhost:8080/api/data; echo; done

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages