Interview Q&A / System Design

INTERVIEW Q&A · 70 QUESTIONS

System Design interview questions

Caching, scaling, databases and classic design problems for beginners.

  1. How would you design a URL shortener like bit.ly?

    Store a mapping from a short code to the long URL. Generate codes with a counter encoded in base62 (or random codes with a collision check), keep the mapping in a key-value store, put a cache in front for fast redirects, and return a 301 or 302 redirect. Add rate limits, expiry and analytics as extras.

    IntermediateIn-depth3 min read
  2. Why is returning a total count with every page expensive, and what are the alternatives?

    COUNT(*) over a large filtered table scans many rows on every request. Alternatives are returning only has_next, using approximate counts, caching the count, or showing 'more than 1,000' instead of an exact total.

    IntermediateQuick answer1 min read