Module 10: Simple Services
Welcome to Simple Services. Do not let the name fool you. While the functional requirements of these systems are straightforward (e.g., “shorten a URL”), designing them to handle billions of requests with 99.999% availability is a masterclass in System Design.
These services are the “Hello World” of distributed systems. They are the perfect playground to learn about:
- NoSQL vs SQL trade-offs.
- Consistent Hashing and Partitioning.
- Caching Strategies (Write-through vs Look-aside).
- Concurrency Control in distributed environments.
Module Contents
This module covers four classic design problems that frequently appear in interviews:
1. Design a URL Shortener (TinyURL)
The classic “Design TinyURL” question. Learn about Base62 encoding, Hash Collisions, and how to estimate storage for billions of records. We also dive into the 301 vs 302 redirect debate and its impact on analytics.
2. Design a Pastebin
Similar to TinyURL, but with a twist: Large Data Payloads. Learn why you should never store large text blobs in a relational database and how to design a Hybrid Storage Architecture using Object Storage (S3) and a Metadata DB.
3. Design an API Rate Limiter
A critical component for protecting your services. We compare algorithms like Token Bucket, Leaky Bucket, and Sliding Window Logs. We also explore how to implement this in a distributed environment using Redis and Lua Scripts.
4. Design a Unique ID Generator (Snowflake)
When AUTO_INCREMENT isn’t enough. Learn how Twitter generates sortable, unique 64-bit IDs across thousands of servers using the Snowflake Algorithm. We discuss Clock Synchronization and Bit Manipulation.
[!TIP] Learning Strategy: These problems are often used as “warm-up” questions in senior interviews, or “full” questions in junior/mid-level interviews. Master them, as they provide the building blocks for complex systems like Twitter or Instagram.