Skip to content

Commit 7034acc

Browse files
readme updated
1 parent aedb1bc commit 7034acc

4 files changed

Lines changed: 196 additions & 8 deletions

File tree

README.md

-1.57 KB

🔮 Future Additions

  • Sliding Window Log algorithm
  • Load balancing layer
  • API Keys & RBAC (Redis-only possible)
  • Middleware-level caching
  • Gateway features:
    • rate limiting
    • authentication
    • load balancingload balancing
    • circuit breaking
  • Prometheus/Grafana dashboards
  • Distributed tracing (OpenTelemetry)

🧩 Architecture Overview

Client → API Gateway (future) → Rate Limiter Service → Redis / Redis Cluster

markdown Copy code

  • Each algorithm uses:
    • Dedicated Redis keys
    • Atomic Lua scripts
    • Isolated logic for dashboard comparison

🔥 API Endpoints

POST /api/limiter/test → Fixed Window

POST /api/limiter/sliding → Sliding Window

POST /api/limiter/tokenbucket → Token Bucket

POST /api/limiter/leakybucket → Leaky Bucket

POST /api/limiter/all → Run all algorithms together

  • POST /api/limiter/test → Fixed Window
  • POST /api/limiter/sliding → Sliding Window
  • POST /api/limiter/tokenbucket → Token Bucket
  • POST /api/limiter/leakybucket → Leaky Bucket
  • POST /api/limiter/all → Run all algorithms together

📦 Example Response

{
  "activeKeys": 1,
  "response": { ... },
  "blockedRequests": 27,
  "allowedRequests": 67,
  "totalRequests": 94
}
🐳 Setup & Installation
bash
Copy code
git clone [<repo-url>](https://github.com/Anshikakalpana/rate-limiter)
docker compose up --build
Starts: Redis Cluster, Node server, Lua scripts

🧪 Testing & Load Scenarios
Test bursts, allowed vs blocked, algorithm comparison via /metrics

Tools: Postman Runner, k6, Artillery, JMeter

📬 Postman Collection
[ Postman collection to test all endpoints:](https://app.getpostman.com/join-team?invite_code=13841166f45640e9b8c8e3a36a9cfc49afed7ac4d4cf1a0be867b7b82d1d0ed8&target_code=bc4d4f0c1c320a256972bc868580defb)

Open Postman Collection

🧭 Roadmap
Sliding Window Log algorithm

API Keys & RBAC (Redis-only)

Middleware caching

Load balancing

Circuit breaking



📄 License
MIT License — free for personal & commercial use.
{
  "activeKeys": 1,
  "response": { ... },
  "blockedRequests": 27,
  "allowedRequests": 67,
  "totalRequests": 94
}
Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
11
{
22
"info": {
3-
"_postman_id": "09c1580a-e498-4bc3-8eb1-69cdb91d38a7",
4-
"name": "New Collection",
3+
"_postman_id": "a6a1204e-2383-4a6d-a4fc-e2da2dfec7a3",
4+
"name": "job-scheduler",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
66
},
7-
"item": []
7+
"item": [
8+
{
9+
"name": "health-check",
10+
"id": "8b5d9338-8e59-4ba3-9354-e09b55618139",
11+
"request": {
12+
"method": "GET",
13+
"header": [],
14+
"url": {
15+
"raw": ""
16+
}
17+
},
18+
"response": []
19+
},
20+
{
21+
"name": "New Request",
22+
"id": "33b35cb3-ecae-47ac-987b-dfbe32754769",
23+
"request": {
24+
"method": "GET",
25+
"header": [],
26+
"url": {
27+
"raw": ""
28+
}
29+
},
30+
"response": []
31+
}
32+
]
833
}

postman/collections/ecommerce.postman_collection.json

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"id": "a62c581c-8440-4733-9683-5b4944677fb2",
1111
"request": {
1212
"method": "GET",
13-
"header": []
13+
"header": [],
14+
"url": {
15+
"raw": ""
16+
}
1417
},
1518
"response": []
1619
},
@@ -19,7 +22,10 @@
1922
"id": "5af3c128-8b2e-4e3b-ad34-f16d72d1bce7",
2023
"request": {
2124
"method": "GET",
22-
"header": []
25+
"header": [],
26+
"url": {
27+
"raw": ""
28+
}
2329
},
2430
"response": []
2531
},
@@ -28,7 +34,10 @@
2834
"id": "e50eeeee-f6ac-40ae-bed4-5d937a3e8662",
2935
"request": {
3036
"method": "GET",
31-
"header": []
37+
"header": [],
38+
"url": {
39+
"raw": ""
40+
}
3241
},
3342
"response": []
3443
},
@@ -37,7 +46,10 @@
3746
"id": "a8a18323-8f50-4aac-92c7-1cdcd7854afa",
3847
"request": {
3948
"method": "GET",
40-
"header": []
49+
"header": [],
50+
"url": {
51+
"raw": ""
52+
}
4153
},
4254
"response": []
4355
},
@@ -46,7 +58,10 @@
4658
"id": "d297a1b2-574d-4247-b81f-593d217928a4",
4759
"request": {
4860
"method": "GET",
49-
"header": []
61+
"header": [],
62+
"url": {
63+
"raw": ""
64+
}
5065
},
5166
"response": []
5267
},
@@ -210,6 +225,18 @@
210225
}
211226
},
212227
"response": []
228+
},
229+
{
230+
"name": "New Request",
231+
"id": "9a0cc40a-f98b-4e66-94b1-3fdd720d5110",
232+
"request": {
233+
"method": "GET",
234+
"header": [],
235+
"url": {
236+
"raw": ""
237+
}
238+
},
239+
"response": []
213240
}
214241
]
215242
}

todo.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
Rate Limiting Microservice - TODO
2+
✅ Completed Features
3+
🎯 Core Rate Limiting Algorithms
4+
5+
✅ Sliding Window Counter - Smooth rate limiting with rolling time windows
6+
✅ Fixed Window Counter - Simple time-bucketed request counting
7+
✅ Leaky Bucket - Constant outflow rate for traffic shaping
8+
✅ Token Bucket - Burst handling with token replenishment
9+
10+
🔴 Redis & Data Layer
11+
12+
✅ Lua Script Atomicity - Race-condition-free operations with Redis Lua
13+
✅ Redis Clustering - Distributed setup for horizontal scaling
14+
✅ Master-Slave Replication - 1 master + 3 slaves for high availability
15+
✅ Connection Management - Optimized Redis client configuration
16+
17+
🐳 Infrastructure & DevOps
18+
19+
✅ Docker Containerization - Multi-stage builds with optimized images
20+
✅ Docker Compose Setup - Local development environment
21+
✅ Basic CI Pipeline - Automated build and test workflows
22+
✅ Environment Configuration - Flexible config management
23+
24+
📖 Documentation Suite
25+
26+
✅ Technical Architecture Docs - System design and algorithm details
27+
✅ API Reference Guide - Complete endpoint documentation
28+
✅ Deployment Guide - Production setup instructions
29+
✅ Developer Setup - Local development and contribution guide
30+
31+
🚀 High Priority
32+
33+
Monitoring & Observability
34+
35+
Prometheus metrics integration
36+
Grafana dashboards for rate limit visualization
37+
Request latency tracking
38+
Rate limit hit/miss ratio metrics
39+
40+
41+
Testing
42+
43+
Unit tests for each algorithm
44+
Integration tests with Redis
45+
Load testing scenarios
46+
Performance benchmarks
47+
48+
49+
API Improvements
50+
51+
RESTful endpoints for rate limit management
52+
Rate limit configuration API
53+
Real-time rate limit status endpoints
54+
Health check endpoints
55+
56+
57+
58+
🔧 Medium Priority
59+
60+
Additional Rate Limiting Algorithms
61+
62+
Sliding Window Log - Precise tracking with timestamp logs
63+
Concurrent Rate Limiter - Limit simultaneous connections
64+
Generic Cell Rate Algorithm (GCRA) - Telecom-grade precision
65+
Adaptive Rate Limiting - Auto-adjust based on system load
66+
67+
68+
Enhanced Features
69+
70+
Custom rate limit rules per user/IP/endpoint
71+
Rate limit tiers (basic, premium, enterprise)
72+
Burst allowance configuration
73+
Rate limit bypass tokens for trusted services
74+
75+
76+
Redis Optimizations
77+
78+
Connection pooling optimization
79+
Redis pipelining for batch operations
80+
Cache warming strategies
81+
82+
83+
Security
84+
85+
Authentication for admin endpoints
86+
IP whitelist/blacklist management
87+
Basic DDoS protection
88+
89+
90+
91+
🔄 CI/CD Enhancements
92+
93+
Pipeline Improvements
94+
95+
Automated testing in CI
96+
Code coverage reporting
97+
Docker image scanning for vulnerabilities
98+
Automated deployment to staging
99+
100+
101+
Quality Gates
102+
103+
Linting and code formatting checks
104+
Dependency vulnerability scanning
105+
106+
107+
108+
🎯 Nice to Have
109+
110+
Advanced Features
111+
112+
Rate limit analytics dashboard
113+
Webhook notifications for rate limit events
114+
Rate limit preview/dry-run mode
115+
Historical rate limit data export
116+
117+
118+
Client Libraries
119+
120+
Python client SDK
121+
Node.js client SDK
122+
Go client SDK
123+
124+
125+
126+
🐛 Known Issues & Technical Debt
127+
128+
Document any current limitations
129+
Clock drift considerations
130+
Memory optimization for high-traffic scenarios
131+
132+
📊 Performance Targets
133+
134+
Sub-10ms p99 latency for rate limit checks
135+
Support 50k+ requests per second
136+
99.9% availability

0 commit comments

Comments
 (0)