1/10
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
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.
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.
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.
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.
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.
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.
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).
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.
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).
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.