A rate limiter service built with Go. It uses Redis to store data (so it works across multiple servers) and gRPC for internal communication.
- User sends a request to the HTTP API.
- Middleware asks the gRPC Service: "Can this IP pass?"
- Service checks the count in Redis using a Lua script.
- If allowed, the request goes through. If not, it returns
429 Too Many Requests.
- Go (Server & Logic)
- Redis (Database for counting tokens)
- gRPC/Protobuf (Communication between services)
- Docker (To run Redis)
-
Start Redis
docker run -d -p 6379:6379 redis
-
Start the Server
go run cmd/server/main.go
-
Test it Run this in your terminal to spam requests:
for i in {1..10}; do curl http://localhost:8080/api/data; echo; done