Introduction
Modern applications are exposed to high traffic, automation scripts, spikes, and sometimes malicious abuse.
If every request is processed equally, no matter who sends it, the system becomes unstable.
A multi-layered rate limiting architecture prevents overload by enforcing limits at:
IP Layer
User Identity Layer
Endpoint/API Layer
Tenant/Subscription Layer
Global Platform Layer
This ensures fairness, protects critical resources, prevents denial-of-service issues, and aligns system usage with business plans (free users vs enterprise).
The goal is to design an architecture where limits are configurable, enforced with low latency, and flexible enough to support:
Sliding window
Token bucket
Fixed window
Burst handling
Grace periods
Dynamic throttling based on load
This article describes a production-focused implementation using:
SQL for configuration
Redis for fast counters
.NET API enforcement
Angular frontend feedback and retry UI
Architecture Overview
┌───────────────────────────────┐
│ Client │
└───────┬────────┬─────────────┘
│ │
▼ ▼
┌──────────────┐ ┌─────────────────┐
│ Angular UI │ │ Retry/Backoff UI│
└───────┬──────┘ └─────────────────┘
│
▼
┌──────────────────────┐
│ API Gateway / Filter │
└───────────┬──────────┘
│
▼
┌─────────────────────────────────────┐
│ Rate Limit Middleware (Tiered Rules)│
└──────┬─────────────┬───────────────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────────────┐
│ Redis Cache │ │ SQL Metadata Store │
└──────┬──────┘ └─────────────┬───────┘
│ │
└───────────┬────────────┘
▼
┌──────────────┐
│ API Handler │
└──────────────┘
Strategy Layers
1. IP-Based Limits
Purpose: Block bots, scrapers, unknown traffic.
Examples:
100 requests/minute per IP
Stricter rule for anonymous traffic
2. User-Level Limits
Applied after login.
Examples:
Free user: 500 requests/day
Paid license: unlimited except heavy API endpoints
3. API Endpoint-Level Limits
Some operations are costlier than others.
Examples:
| Endpoint | Limit |
|---|---|
/auth/login | 5/minute |
/search/global | 25/minute |
/download/report | 3/hour |
4. Tenant-Level Limits
Multi-tenant applications need business controls.
Example:
SaaS plan limits calls per tenant per day
5. System-Level Safety Throttle
When traffic spike occurs, limits tighten dynamically.
Metadata Model (SQL)
CREATE TABLE RateLimitPolicy (
PolicyId UNIQUEIDENTIFIER PRIMARY KEY,
Scope NVARCHAR(50), -- IP, USER, API, TENANT, GLOBAL
Target NVARCHAR(200), -- endpoint or wildcard
LimitCount INT,
WindowSeconds INT,
BurstAllowed BIT DEFAULT 0
);
Example entries
| Scope | Target | Limit | Window (s) |
|---|---|---|---|
| IP | * | 100/min | 60 |
| USER | /search | 30/min | 60 |
| API | /download/report | 3/hour | 3600 |
| TENANT | * | 10k/day | 86400 |
| GLOBAL | * | 1M/hour | 3600 |

Join the conversation! Your thoughts help the community grow.