Skip to content

lghuy05/distributed-rate-limiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Rate Limiter Demo

Overview

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.

Requirements

  • JDK 17 (for local builds)
  • Redis (local or via Docker)
  • Docker + Docker Compose (for containerized runs)

Install / Build

Build the application JAR with the Maven wrapper:

./mvnw clean package

Run Locally

Start Redis (example using Docker):

docker run --rm -p 6379:6379 redis

Run the app:

./mvnw spring-boot:run

The app listens on http://localhost:8080.

Run with Docker

The Docker image expects the JAR to exist under target/.

./mvnw clean package
docker compose up --build

Endpoints

  • GET /health returns OK and is publicly accessible.
  • All requests include X-RateLimit-Remaining and are rate-limited.
  • Non-/health endpoints require HTTP Basic auth (Spring Security defaults). Check the app logs for the generated password or configure your own credentials.

Configuration

Rate limit defaults are in src/main/resources/application.properties:

ratelimit.limit=5
ratelimit.windowSeconds=60

Redis connection defaults to the redis hostname for Docker Compose.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors