| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Adaptive Distributed Rate Limiting API Gateway
A high-performance reverse-proxy API Gateway with rate limiting at the network edge. Powered by Redis Lua scripts, two-tier in-memory leasing, and adaptive upstream concurrency control.
ratelimit/ ├── src/ │ ├── config.js # Route costs and cluster configuration │ ├── redis/ │ │ ├── client.js # Redis connection and circuit breaker │ │ ├── luaManager.js # Lua EVALSHA script manager │ │ └── lua/ │ │ ├── token_bucket.lua # Token bucket script │ │ └── sliding_window.lua # Sliding window counter script │ ├── limiter/ │ │ ├── limiterService.js # Limiter coordinator and Pub/Sub listener │ │ ├── memoryLease.js # L1 in-memory lease store │ │ ├── fallbackLimiter.js # In-memory fallback limiter │ │ └── costCalculator.js # Cost evaluation and delta calculator │ ├── adaptive/ │ │ └── healthMonitor.js # Upstream p95 latency and error observer │ ├── gateway/ │ │ ├── server.js # Reverse proxy HTTP and WebSocket server │ │ └── middleware.js # Rate limit middleware and RFC headers │ ├── upstream/ │ │ └── mockUpstream.js # Test upstream services │ ├── metrics/ │ │ └── metricsCollector.js # Metrics aggregation │ └── dashboard/ # Browser dashboard (port 8080/dashboard) ├── tests/ │ ├── verification.js # Automated test suite (10 cases / 33 assertions) │ └── benchmark.js # Throughput benchmark ├── docker-compose.yml # Redis service configuration ├── tech.md # Technical specifications and algorithms ├── test.md # Test execution, debug log, and audit ├── package.json └── README.md
docker run -d --name aegis-redis -p 6379:6379 redis:alpineOr using docker compose:
docker compose up -dnpm installnpm startTo protect the control plane on a non-local deployment, set a shared secret. Without it, /api/control only accepts loopback callers:
AEGIS_ADMIN_TOKEN=your-secret npm startRun the integration test suite:
npm testRun the throughput benchmark:
npm run benchmark| Header | Description | Example |
|---|---|---|
| RateLimit-Limit | Maximum quota for current window | 20 |
| RateLimit-Remaining | Remaining quota | 14 |
| RateLimit-Reset | Seconds until quota is fully refilled | 2 |
| Retry-After | Back-off time sent with 429 and 202 responses | 4 |
| X-RateLimit-Tier | Traffic tier | green | yellow | red |
| X-RateLimit-Algorithm | Active algorithm | token_bucket | sliding_window |
| X-RateLimit-Adaptive-Multiplier | Dynamic upstream health factor | 1.0 |
| X-Graceful-Degradation | Triggered soft degradation method | Served-From-Stale-Cache |
| X-RateLimit-Shadow-Exceeded | Emitted when limit exceeded in Shadow Mode | true |
| Back | FazBrowse Home | New Git URL |