A collection of rate limiting implementations in Go, demonstrating different approaches to throttling HTTP requests.
This repository showcases three different rate limiting strategies for HTTP APIs:
- tollbooth - Third-party library implementation using didip/tollbooth
- tokenbucket - Custom fixed-window rate limiter implementation
- clientlim - Per-client IP-based rate limiter with automatic cleanup
- Simple HTTP server examples with
/pingendpoint - JSON response formatting
- Configurable rate limits and time windows
- HTTP 429 (Too Many Requests) responses when limits exceeded
- Go 1.24.4 or later
git clone https://github.com/senutpal/snailtrail.git
cd snailtrail
go mod downloadcd tollbooth
go run .cd tokenbucket
go run .cd clientlim
go run .Each server runs on http://localhost:8080. Test the /ping endpoint:
curl http://localhost:8080/ping- tokenbucket: 2 requests per second
- clientlim: 2 requests per second per IP address
- tollbooth: 1 request per second