system design: infra

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:21 AM on 7/16/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

11 Terms

1
New cards

SD prompt — URL shortener: the core challenge?

NOT scale — it's the encoding scheme + read-heavy caching. Generate short unique key (base62 of an ID counter, or hash+collision-check), cache hot URLs. Redirect choice is a probe: 301 (permanent) is browser-cached → less load but no analytics/remap; 302 keeps every hit on your server → analytics + mutability. Pick 302, say why. Read:write ~100:1 → caching dominates.

2
New cards

SD prompt — Distributed rate limiter: the core challenge?

Counting across many servers. Token bucket (allows bursts up to bucket size, refills at rate) vs sliding-window (smoother, more memory). Store counters in Redis (atomic INCR/Lua) so all app servers share state.

3
New cards

Token bucket vs sliding window (rate limiting)

Token bucket: bucket of N tokens, refill R/s, each request spends one, empty = reject — allows bursts. Sliding window: count requests in the trailing T seconds — smoother, no burst, but more per-key memory/bookkeeping.

4
New cards

SD prompt — News/social feed: the core challenge?

Fan-out-on-write vs -on-read + the celebrity problem. Hybrid: precompute feeds for normal users (write), pull-at-read for high-follower accounts, merge. Cache assembled feeds.

5
New cards

SD prompt — Chat / messaging: the core challenge?

Real-time delivery + ordering + presence. WebSocket (or long-poll) for push, message ordering (per-conversation sequence numbers), delivery guarantees (at-least-once + dedup → exactly-once feel), presence/online status.

6
New cards

SD prompt — Notification service: the core challenge?

Event-driven fan-out across channels. Producers emit events → Kafka → workers → per-channel senders (push/email/SMS) with a template engine and a user-preferences store. Handle retries, rate limits, dedup.

7
New cards

SD prompt — Key-value store / distributed cache: the core challenge?

Consistent hashing (spread keys, minimal reshuffling on node add/remove) + replication (N copies for durability/availability) + partitioning. Tradeoff consistency vs availability (quorum reads/writes).

8
New cards

Consistent hashing — what problem does it solve?

Naive hash(key) % N remaps almost every key when N changes. Consistent hashing maps keys and nodes onto a ring; adding/removing a node only moves keys in one arc (≈1/N of keys). Virtual nodes even out the load.

9
New cards

SD prompt — Web crawler: the core challenge?

Politeness (respect robots.txt + rate-limit per host), dedup (URL + content hashing, Bloom filter for seen-URLs), and the URL frontier (prioritized queue of what to fetch next).

10
New cards

SD infra — caching patterns to know

Cache-aside (app reads cache, on miss reads DB + populates) · write-through (write cache+DB together) · write-back (write cache, flush later — fast but risky) · CDN for static/edge. Plus eviction (LRU/LFU) + TTL for staleness.

11
New cards