Roadmap › System Design — High-Level Design (HLD) from Basics to Case Studies › Module: Building Blocks
Lessons in this course (14)
9. Rate limiting, search, storage and CDNs
IntermediateMediumLesson 9 of 14
Rate limiting algorithms:
| Algorithm | Idea |
|---|---|
| Fixed window | Count requests per minute window — simple, bursty at edges |
| Sliding window log/counter | Smoother limit over a moving window |
| Token bucket | Tokens refill at a rate; each request takes one; allows short bursts — most common |
| Leaky bucket | Requests leave at a constant rate — smooths traffic |
Distributed rate limiting keeps counters in Redis (atomic INCR with expiry or Lua scripts). ASP.NET Core has AddRateLimiter with fixed window, sliding window, token bucket and concurrency limiters; return 429 with Retry-After.
Search: an inverted index (word → documents) in Elasticsearch/Azure AI Search, fed asynchronously from the database (change events); supports full text, typo tolerance, facets and ranking.
Files and media: store in object storage (Blob/S3), keep only metadata + URL in the database, upload directly from the client with pre-signed/SAS URLs, serve through a CDN, process asynchronously (thumbnails, virus scan, transcoding) via a queue.