Practice & Assessment
Test your understanding of System Design End-to-End
Multiple Choice Questions
6A URL shortener returns 301 for redirects. A user clicks the short link and never hits the shortener again for that link. Is this a bug or a feature?
A social network uses fan-out on write. A celebrity with 10 million followers posts. What is the main problem?
A distributed cache returns data from a node that missed the latest write due to a network partition. Which CAP trade-off is this system making?
What is the purpose of a correlation ID in a microservices architecture?
You alert on CPU above 80% on your API servers. A database index is dropped causing all queries to slow dramatically. Does your CPU alert fire?
A read-heavy API receives 12,000 reads/sec and each DB query takes 10ms. Can one database server handle this?
Coding Challenges
1Build an observable API with structured logging and correlation IDs
Add observability to an Express API. Implement middleware that generates a UUID requestId for every incoming request and attaches it to the request object. All downstream log statements must include the requestId. Use pino or winston for structured JSON logging with fields: level, timestamp, requestId, method, path, statusCode, durationMs on completion. Expose GET /metrics returning: total request count, error count (4xx plus 5xx), and p50/p95/p99 latency computed from an in-memory histogram of the last 1000 requests. Input: any HTTP request. Output: structured JSON logs to stdout and GET /metrics returning a JSON stats object. Estimated time: 25 minutes.
Mini Project
Production-Ready URL Shortener with Full Observability
Build a complete URL shortener applying every module concept. API: POST /links creates a short code via base62 auto-increment, returns 201 with Location header. GET /:code redirects with 302 for analytics (301 available via query param). Auth: API keys with tiered rate limiting (free: 50 creates/hour, pro: 500/hour) using Redis Lua atomic scripts. Caching: cache all code-to-URL lookups in Redis with 24-hour TTL using cache-aside pattern. Analytics: on each redirect enqueue an async BullMQ job to increment a click counter in Redis, never blocking the redirect response. Status: GET /links/:code/stats returns click count from Redis. Scalability: run as 2 instances behind Nginx round-robin with externalized sessions. Observability: structured JSON logging with requestId correlation and GET /metrics endpoint with error rate and p99 latency. All error responses use RFC 7807 Problem Details format.
