This is GateKeeper, a distributed Rate Limiting microservice I built in Go.
I created this pet project to dive deeper into backend engineering, specifically focusing on gRPC, Redis, and writing clean, testable code. The service acts as a guard, checking if incoming requests should be allowed or blocked based on predefined limits.
- gRPC API: I went with gRPC instead of standard REST for faster, more modern, strongly-typed communication.
- Two Algorithms:
Fixed Window Counter: A simple, memory-efficient approach using basic RedisINCRandEXPIRE.Sliding Window Log: A more advanced approach. I used Redis Sorted Sets (ZSET) and wrote a simple Lua script to ensure everything executes atomically in one go.
- Clean Architecture: The core business logic is decoupled from the network layer using interfaces and dependency injection.
- Graceful Shutdown: The server catches OS signals (
SIGTERM,SIGINT) to finish processing active requests before shutting down, ensuring connections don't just drop.
- Language: Go
- Database: Redis (with a bit of Lua)
- API: gRPC & Protocol Buffers
- Infrastructure: Docker & Docker Compose
- Testing:
miniredis(in-memory Redis mock) andtestify
You'll need Docker and Docker Compose installed on your machine.
- Clone this repository.
- Start the app and Redis in the background:
docker compose up --build -d- The gRPC server will start listening on port
50051.
To stop and remove the containers:
docker compose downI used miniredis so you don't even need a real Redis instance running to execute the tests. Just run:
go test -v ./...- Making sure git is in order before starting coding. This includes correct name and email.