Cheat sheet + 20 flashcards covering REST, SQL vs NoSQL, caching, load balancing, CAP theorem, message queues, CDNs, and microservices.
Clients request resources; servers respond. Clear separation: clients handle UI/UX, servers handle data and business logic.
HTTP is stateless — each request is self-contained. State must be stored server-side (DB, session) or client-side (JWT, cookies).
GET read · POST create · PUT replace · PATCH partial update · DELETE remove
Idempotent: GET, PUT, DELETE (same result if repeated). POST is not.
RESTful: stateless, resource URLs, standard verbs, uniform interface.
2xx Success: 200 OK, 201 Created, 204 No Content
3xx Redirect: 301 Moved, 304 Not Modified
4xx Client Error: 400 Bad Request, 401 Unauth, 403 Forbidden, 404 Not Found, 429 Rate Limited
5xx Server Error: 500 Internal, 503 Unavailable
SQL: structured schema, ACID transactions, complex joins. Use for: financials, e-commerce, anything with relationships.
NoSQL: flexible schema, horizontal scale, high write throughput. Use for: logs, social feeds, catalogs, real-time data. Types: document, key-value, column, graph.
Store frequently accessed data in fast storage (Redis, Memcached) to reduce DB load and latency.
Cache-aside: check cache → miss → read DB → populate cache
Write-through: write to cache + DB simultaneously
Eviction: LRU (least recently used), LFU, TTL
Distributes traffic across servers to prevent overload.
Round-robin: equal turns
Least connections: send to least busy server
Consistent hashing: same client → same server (good for sessions & caches)
Horizontal scale requires stateless services.
A distributed system can guarantee only 2 of 3:
Consistency — all nodes see same data
Availability — every request gets a response
Partition Tolerance — works despite network splits
P is required in practice → choose CP or AP.
Decouples producers from consumers asynchronously.
Queue: one message → one consumer (task distribution)
Pub/Sub: one message → all subscribers (fan-out/broadcasting)
Benefits: absorbs traffic spikes, retries on failure, enables parallelism. Tools: Kafka, RabbitMQ, AWS SQS.
A CDN distributes static assets (images, JS, CSS, video) to edge servers geographically close to users.
Reduces latency, offloads the origin server, and improves availability.
Examples: Cloudflare, AWS CloudFront, Akamai, Fastly.
An index (usually a B-tree) lets the DB find rows without scanning the full table.
Read: O(log n) with index vs O(n) without.
Trade-off: faster reads, slower writes, extra storage.
Index columns you frequently filter or sort by — not every column.
Caps the number of requests a client can make per time window.
Prevents abuse, DoS attacks, and protects server capacity.
Return 429 Too Many Requests when limit exceeded.
Algorithms: token bucket (bursty allowed), leaky bucket (smooth output).
Monolith: single deployable unit. Simpler to build, test, debug. Start here.
Microservices: small, independent services with own data stores, communicating via APIs/messages. Benefits: independent scaling, team autonomy. Cost: distributed complexity, latency.
Space flip · → next · ← prev · G got it · R review