This project is a Spring Boot service that demonstrates a Redis-backed, fixed-window rate limiter. Every request is checked against a per-client counter stored in Redis and returns an X-RateLimit-Remaining header. When the limit is exceeded, the service responds with HTTP 429.
- JDK 17 (for local builds)
- Redis (local or via Docker)
- Docker + Docker Compose (for containerized runs)
Build the application JAR with the Maven wrapper:
./mvnw clean packageStart Redis (example using Docker):
docker run --rm -p 6379:6379 redisRun the app:
./mvnw spring-boot:runThe app listens on http://localhost:8080.
The Docker image expects the JAR to exist under target/.
./mvnw clean package
docker compose up --buildGET /healthreturnsOKand is publicly accessible.- All requests include
X-RateLimit-Remainingand are rate-limited. - Non-
/healthendpoints require HTTP Basic auth (Spring Security defaults). Check the app logs for the generated password or configure your own credentials.
Rate limit defaults are in src/main/resources/application.properties:
ratelimit.limit=5
ratelimit.windowSeconds=60Redis connection defaults to the redis hostname for Docker Compose.