Changelog
Version v1.1.0
β‘ distlimit v1.1.0 β Pluggable Architecture & Enterprise Security Hardening
We are thrilled to announce the official release of distlimit v1.1.0! This milestone update transforms distlimit into a fully modular, enterprise-grade distributed rate limiter for Go, featuring pluggable strategy algorithms, security-hardened middlewares, 64-sharded memory management, and dual-tier circuit breaker resilience.
π 1. Pluggable Strategy Architecture
- 5 Standard Algorithms Included:
- Token Bucket: Burst-friendly rate limiting.
- Leaky Bucket: Smooth traffic shaping for third-party integrations.
- Fixed Window: Ultra-fast counter reset protection.
- Sliding Window Log: 100% exact precision for strict quotas.
- Sliding Window Counter: $O(1)$ memory weighted moving average precision.
- 100% Backward Compatible: Existing
v1.0.0users can upgrade seamlessly without breaking API changes via Go type aliases and automatic default fallback algorithm configurations.
π‘οΈ 2. Security & QA Audit Remediation (P0 & P1 Fixes)
Following a comprehensive QA & Security Engineering audit, the following critical issues have been remediated and verified:
- [P0 - Security] Anti-IP Spoofing Shield:
- Native CIDR-validated
WithTrustedProxiesinspection implemented across all HTTP (net/http,gin,echo,fiber) andgRPCmiddleware adapters. - Headers
X-Forwarded-ForandX-Real-IPare strictly ignored unless the direct connection (RemoteAddr/PeerAddr) originates from a verified trusted proxy subnet.
- Native CIDR-validated
- [P0 - Redis Cluster] CROSSSLOT Compatibility:
- Wrapped key generation with Redis Hash Tags
{}(distlimit:{key}) indriver/redis. - Guarantees that dynamic window/sequence keys land on the exact same Redis Hash Slot in clustered environments, preventing
CROSSSLOTexecution errors.
- Wrapped key generation with Redis Hash Tags
- [P0 - Race Condition] Atomic ZSET Member Uniqueness:
- Integrated an atomic Redis
INCRsequence generator (key .. ":seq") in the Sliding Window Log Lua. - Eliminates member overwrites during high-concurrency requests landing on the exact same millisecond score.
- Integrated an atomic Redis
- [P1 - Memory] 64-Sharded In-Memory Map Architecture:
- Converted
driver/memoryto a 64-sharded lock architecture using FNV-1a key hashing. - Eliminates global mutex lock contention during high-throughput requests and background cleanup runs.
- Converted
- [P1 - Memory] Heap Retention Truncation:
- Added active slice re-allocation buffer logic in
slidinglogin-memory state when array capacity waste exceeds 50%. - Prevents gradual RAM bloat and allows Go Garbage Collector to reclaim unused memory.
- Added active slice re-allocation buffer logic in
- [P1 - Resilience] Half-Open Circuit Breaker Probing:
- Implemented an atomic
CAS(Compare-And-Swap) single-request probing mechanism indriver/hybrid. - Prevents Thundering Herd request stampedes against Redis during recovery after an outage cool-off period.
- Implemented an atomic
- [P2 - Context] Context Cancellation Check:
- Added early
select <-ctx.Done()checks in the in-memory driver to avoid mutating state if the callerβs request context was canceled.
- Added early
π 3. Framework Middlewares & Runnable Examples
Complete, production-ready middleware adapters and runnable examples included in examples/:
- β‘ Fiber v3 (
middleware/fiber,examples/fiber-slidingcounter) - πΈ Gin Framework (
middleware/gin,examples/gin-hybrid) - π Echo v4 & v5 (
middleware/echo,middleware/echov5,examples/echo,examples/echov5) - π Standard net/http & Chi (
middleware/nethttp,examples/nethttp) - π‘ gRPC Unary & Streaming Interceptors (
middleware/grpc,examples/grpc)
π 4. Performance & Benchmarks
Benchmarked on AMD 3020e Linux x86_64:
| Algorithm | Performance | Memory Overhead | Allocations |
|---|---|---|---|
| Sliding Log | 20.36 ns/op |
0 B/op | 0 allocs/op |
| Token Bucket | 46.18 ns/op |
0 B/op | 0 allocs/op |
| Leaky Bucket | 47.76 ns/op |
0 B/op | 0 allocs/op |
| Fixed Window | 77.27 ns/op |
0 B/op | 0 allocs/op |
| Sliding Counter | 129.10 ns/op |
0 B/op | 0 allocs/op |
π 5. Installation & Upgrade
To update your Go project to v1.1.0:
go get github.com/balramadan/distlimit@v1.1.0Whatβs Changed
- Release/v1.1.0 by @balramadan in https://github.com/balramadan/distlimit/pull/1
New Contributors
- @balramadan made their first contribution in https://github.com/balramadan/distlimit/pull/1
Full Changelog: https://github.com/balramadan/distlimit/compare/v1.0.1...v1.1.0