TGViewer
Coding Interview Preparation Coding Interview Preparation @coding_interview_preparation · 5.9K subscribers
Post #1365 351
🏗️ SYSTEM DESIGN MONDAY #2 - Caching 101

Last week: client → server → database. Now let's fix the bottleneck.

Say your database gets hit with the same query a thousand times a second - like fetching a popular product page. Hitting disk every time is wasteful.

Enter the cache: a fast, in-memory layer that sits between your server and database.


[Client] → [Server] → [Cache] → [Database]
↑
(checked first)


Flow:
1️⃣ Server checks cache first
2️⃣ Cache hit → return immediately (fast!)
3️⃣ Cache miss → query database, store result in cache, return it

Popular tools: Redis, Memcached.

Two concepts you MUST be able to explain in an interview:

🔹 Cache eviction (LRU) - cache has limited memory, so when it's full, Least Recently Used items get kicked out to make room for new ones.

🔹 Cache invalidation - the hardest part. If the underlying data changes, how does the cache know to update? (Famous quote: "There are only two hard things in computer science: cache invalidation and naming things.")

Common strategies: TTL (time-to-live expiry), write-through (update cache and DB together), or explicit invalidation on writes.

Next System Design Monday: what happens when ONE server can't handle the traffic anymore - load balancing.

What would you cache first in a system like Instagram? 👇
More from @coding_interview_preparation
  1. Oct 8, 2026If you're prepping for system design interviews, this repo is gold It contains a curated,…
  2. Oct 6, 2026document post
  3. Oct 4, 2026💼 Why Your Resume Gets Rejected Before a Human Reads It You may have good skills and proj…
  4. Oct 2, 2026🧠 Coding Myths You Should Stop Believing There's a lot of advice online about learning to…
  5. Oct 1, 2026Most Asked Topics in AI Engineer Interviews Based on 2026 candidate reports
  6. Sep 30, 2026💼 What Companies Actually Look For in a Fresher Think companies only care about your CGPA…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →