RecapsKayavak

Kayavak / Recaps / Learning Sequence

Recaps · Volume 18

Learning Sequence

The revision sheet of every chapter, on one page: the key ideas, the numbers worth knowing, the pitfalls and the words. Use it before an interview, after a chapter, or to find which chapter to reread. Each title opens its chapter; below each sheet are its exercises, companion and TiffinBox stage, and the misconceptions the companion corrects.

Open the volume

197

Phase 1 — CS Foundations

Key ideas

  • Sequence: programming → DSA → discrete maths → architecture → operating systems → networking; each step uses the previous one.
  • Exit at L2–L3: build and explain, not yet debug production systems.
  • Projects prove the phase: C programs, a shell, an HTTP server, a data-structures library, networking tools.
  • Build before reading further; measure before believing big-O alone.

Numbers to remember

  • Lab: C fork-per-connection server ~118,000 req/s with 50 clients on 2 CPUs; iterative server starved the second client.
  • Lab: Python http.server 43.6 ms per request on keep-alive: Nagle + delayed ACK (~40 ms).
  • Budget: ~45 study hours + 4–6 project weeks ≈ 3 months at 8 h/week.

Pitfalls

  • Reading without building.
  • Skipping C and system calls.
  • Ignoring constant factors and memory layout.
  • Assuming one recv returns one whole request.

Glossary

  • System call: a request from a program to the operating system kernel.
  • File descriptor: the kernel handle for an open file, pipe or socket.
  • fork/exec: create a process / replace its program.
  • Nagle's algorithm: coalescing small TCP writes until earlier data is acknowledged.
  • Event loop: one thread watching many sockets and handling whichever is ready.

198

Phase 2 — Java and Backend Foundation

Key ideas

  • Sequence: Java → OOP → collections → generics → exceptions → JVM → concurrency → build tools → HTTP.
  • The project is a REST service without Spring, to learn what frameworks do.
  • Throughput ≈ concurrency ÷ time per request (until the next bottleneck); Little's law checks latency.
  • Validate at the edge; map errors to correct HTTP status codes with safe messages.
  • Exit at L2–L3: build, test and explain; deep JVM debugging comes later.

Numbers to remember

  • Lab: 20 ms handler: 1 thread 48 req/s; 16 threads 780; virtual threads 1,534 (next bottleneck: dispatcher and CPU).
  • Budget: ~28 study hours + 2–3 project weeks ≈ 2 months at 8 h/week.

Pitfalls

  • Learning Spring before HTTP and threads.
  • The default single-thread executor in production.
  • 500 for client errors; stack traces in responses.
  • Shared mutable state without synchronisation.

Glossary

  • Executor: a service that runs tasks on threads.
  • Virtual thread: a lightweight JVM-scheduled thread.
  • Type erasure: generics checked at compile time and removed at run time.
  • Idempotent method: one whose repeated calls have the same effect (GET, PUT, DELETE).
  • Location header: the URI of a newly created resource.

199

Phase 3 — Spring Production Backend

Key ideas

  • Sequence: Core → Boot → Web → Validation → Data/JPA → Transactions → Security → Testing → Observability.
  • Know the mechanism behind each annotation: proxies (transactions, caching, async, security), filter chains, auto-configuration conditions.
  • Production-style means concurrency-safe: atomic updates, locks or versions, idempotency keys, per-owner authorisation.
  • Test against the real database; observe every endpoint.

Numbers to remember

  • Lab: load-change-save recorded 56 of 400 updates; atomic, locked and versioned approaches all 400.
  • Lab: optimistic locking on one hot row needed 2,121 retries for 400 updates.
  • Budget: ~32 study hours + 3–4 project weeks ≈ 2.5 months at 8 h/week.

Pitfalls

  • Lost updates from load-change-save.
  • Self-invocation bypassing proxies.
  • N+1 queries from lazy loading.
  • H2-only tests.
  • URL-only security without object-level checks.

Glossary

  • Proxy: a wrapper object adding behaviour around method calls.
  • Lost update: a write overwritten by a concurrent write based on stale data.
  • Optimistic / pessimistic locking: detect conflicts at write time / prevent them with locks.
  • Problem details: RFC 9457 standard JSON error format.
  • Testcontainers: a library running real dependencies in containers for tests.

200

Phase 4 — Data

Key ideas

  • Sequence: SQL → PostgreSQL → transactions → indexes → optimisation → Redis → NoSQL → search.
  • Indexes must match the query's filter and order; functions on columns hide indexes.
  • Read plans before changing anything; measure before and after.
  • Keyset pagination for deep pages; batch or join instead of N+1.
  • Other stores are chosen by access pattern, with a consistency and invalidation story.

Numbers to remember

  • Lab: 62 ms → 0.12 ms with (customer_id, created DESC); 263 ms → 3.8 ms with a range; OFFSET page 50,000 80 ms vs keyset 0.15 ms; N+1 16.8 ms vs 4.8 ms.
  • Budget: ~20 study hours + 2–3 project weeks ≈ 6–7 weeks at 8 h/week.

Pitfalls

  • Over-indexing; never reading ORM-generated SQL.
  • OFFSET on big tables.
  • Caching without invalidation.
  • NoSQL for vague "flexibility".

Glossary

  • Composite index: an index on several columns in order.
  • Expression index: an index on a computed expression.
  • Keyset pagination: seeking by the last seen key.
  • Covering index: an index containing all columns a query needs.
  • Cache-aside: the application reads the cache, falls back to the database and fills the cache.

201

Phase 5 — Frontend

Key ideas

  • Sequence: HTML → CSS → JS → browser → HTTP → TypeScript → React → Angular awareness → testing → accessibility → performance → security.
  • Platform first; frameworks second.
  • Fetch in parallel or aggregate; avoid waterfalls; isolate failures per widget.
  • Production quality: loading/error states, accessibility, budgets, security, RUM.

Numbers to remember

  • Lab: four 150 ms requests: sequential ~620 ms, parallel ~160 ms, aggregated ~156 ms.
  • Lab: Promise.all failed the whole page on one 500; allSettled kept 3 of 4 widgets.
  • Budget: ~48 study hours + 3–4 project weeks ≈ 3.5 months at 8 h/week.

Pitfalls

  • Hidden waterfalls in component trees.
  • All-or-nothing error handling.
  • Inaccessible custom controls.
  • Tokens in localStorage, no CSP.

Glossary

  • Waterfall: requests that wait for each other unnecessarily.
  • BFF: backend for frontend.
  • Error boundary: a React component that catches rendering errors in its subtree.
  • RUM: real-user monitoring.
  • CSP: Content Security Policy.

202

Phase 6 — Infrastructure

Key ideas

  • Sequence: Linux → Docker → networking → reverse proxy → Kubernetes.
  • Containers = processes + namespaces (visibility) + cgroups (limits) + an image filesystem.
  • Images: multi-stage, small, non-root, pinned by digest.
  • Kubernetes: declarative desired state; pods, deployments, services, ingress, probes, resources.

Numbers to remember

  • Lab: PID namespace showed 4 processes vs 76 on the host; net namespace refused the host's 127.0.0.1 server; 150 MB in a 100 MB cgroup was OOM-killed.
  • OOMKilled exit code: 137 (128 + SIGKILL 9).
  • Budget: ~12 study hours + 2–3 project weeks ≈ 5–6 weeks at 8 h/week.

Pitfalls

  • Kubernetes before Linux.
  • Apps listening on 127.0.0.1 inside containers.
  • Root containers, fat images, latest tags.
  • Missing probes and resource requests.

Glossary

  • Namespace: a kernel feature isolating a view of a resource.
  • cgroup: a kernel feature limiting and accounting resources.
  • Multi-stage build: building in one image stage and copying artefacts into a minimal runtime stage.
  • Ingress: Kubernetes routing of external HTTP traffic to services.
  • Probe: a check Kubernetes runs to decide readiness, liveness or startup.

203

Phase 7 — Cloud and DevOps

Key ideas

  • Sequence: fundamentals → IAM → network → managed DB → object storage → compute/Kubernetes → Terraform → CI/CD → GitOps.
  • One cloud in depth; least privilege everywhere; private by default.
  • IaC: plan compares config, state and reality; idempotent applies; drift visible only through providers.
  • CI/CD with OIDC, signed artefacts and gates; GitOps reconciles continuously from Git.

Numbers to remember

  • Lab: second plan "No changes"; a 2 → 3 change updated state but not the provisioned file; a hand edit wasn't detected.
  • Budget: ~18 study hours + 3–4 project weeks ≈ 6–7 weeks at 8 h/week.

Pitfalls

  • Click-ops and provisioner scripts.
  • Long-lived admin keys, especially in CI.
  • Public databases and buckets.
  • No budget alerts; no teardown.

Glossary

  • IaC: infrastructure as code.
  • State file: the IaC tool's record of what it manages.
  • Drift: real infrastructure differing from code.
  • OIDC federation: exchanging a CI identity token for short-lived cloud credentials.
  • GitOps: Git as the source of truth, reconciled by an in-cluster controller.

204

Phase 8 — Distributed Systems

Key ideas

  • Sequence: queues → Kafka → EDA → retries → idempotency → outbox → CDC → consistency → replication → sagas → resilience.
  • No atomic write across a database and a broker: use an outbox (with a relay or CDC).
  • At-least-once delivery + idempotent consumers = effectively once.
  • Events are versioned facts; sagas compensate; resilience patterns contain failures.

Numbers to remember

  • Lab: 29 crashes → dual write lost 29 events; outbox lost 0 and duplicated 20 (one per relay crash).
  • Budget: ~29 study hours + 3–4 project weeks ≈ 7 weeks at 8 h/week.

Pitfalls

  • Dual writes; publish-then-commit.
  • Non-idempotent consumers.
  • Commands disguised as events; unversioned schemas.
  • A distributed monolith.

Glossary

  • Outbox: a table of events written in the business transaction and published later.
  • CDC: change data capture from the database log.
  • Idempotent consumer: processing a message twice has the same effect as once.
  • Dead-letter queue: where messages go after repeated failures.
  • Saga: a sequence of local transactions with compensations.

205

Phase 9 — Observability and SRE

Key ideas

  • Sequence: logs → metrics → traces → OpenTelemetry → SLOs → alerting → incident response → load testing → DR.
  • SLOs define "working" from users' view; error budgets turn reliability into a decision tool.
  • Alert on burn rate with paired long and short windows: page for fast burns, ticket for slow ones.
  • Incidents: roles, mitigation first, blameless postmortems with action items.
  • Prove capacity and recovery with load tests and timed drills.

Numbers to remember

  • 99.9% over 30 days = 43.2 minutes of full downtime, or 0.1% of requests.
  • Burn-rate thresholds: 14.4 (1 h/5 min) and 6 (6 h/30 min) page; 3 (1 d/2 h) and 1 (3 d/6 h) ticket.
  • Lab: threshold rule fired 20 times (18 flaps); burn-rate page once; ticket caught the slow degradation in 7.75 h.
  • Budget: ~21 study hours + 2–3 project weeks ≈ 5–6 weeks at 8 h/week.

Pitfalls

  • Cause-based and threshold alerts that flap.
  • Dashboards with no SLOs.
  • Logs that can't be joined to traces.
  • Untested recovery.

Glossary

  • SLI / SLO / SLA: indicator / objective / contractual agreement.
  • Error budget: allowed unreliability.
  • Burn rate: speed of budget consumption relative to the SLO (1 = exactly on budget).
  • RED / USE: rate-errors-duration for services; utilisation-saturation-errors for resources.
  • Postmortem: a blameless written analysis of an incident.

206

Phase 10 — Security

Key ideas

  • Sequence: web security → OAuth/OIDC → API security → cloud IAM → container security → supply chain → threat modelling.
  • Learn the threat classes layer by layer, then threat-model the whole system; test the classes of flaw; automate the tests so fixes stay fixed.
  • Authorization on the server, on every object, ideally in the query.
  • Secrets in managers; dependencies pinned and scanned; IAM least privilege.

Numbers to remember

  • Lab: audit 0/6 → 6/6; brute force 30 checked → 5 checked, 25 blocked; password hashing (fast SHA-256) still weak.
  • 5 failed logins per 15 minutes ≈ 3 weeks to try 10,000 passwords on one account.
  • Budget: ~15 study hours + 2 project weeks ≈ 4 weeks at 8 h/week.

Pitfalls

  • Frontend-only authorization; missing object-level checks.
  • Verbose errors; permissive CORS.
  • Secrets in repos and images.
  • Security left to the end.

Glossary

  • STRIDE: spoofing, tampering, repudiation, information disclosure, denial of service, elevation of privilege.
  • BOLA / IDOR: broken object-level authorization / insecure direct object reference.
  • OIDC: OpenID Connect, identity on top of OAuth 2.0.
  • SBOM: software bill of materials.
  • CSP: Content Security Policy, a header limiting where scripts and resources can load from.

207

Phase 11 — System Design

Key ideas

  • Sequence: requirements → estimation → architecture → data model → APIs → caching → sharding → consistency → reliability → trade-offs.
  • Numbers first; every choice names the alternative it beat.
  • Practise five simple systems (URL shortener, rate limiter, file storage, notification service, chat), then eight harder ones (ticket booking, payments, collaborative editing, ride matching, social feed, search, recommendation, multi-tenant SaaS), each adding one new difficulty.

Numbers to remember

  • 1 day ≈ 86,400 s ≈ 10⁵ s; 1M/day ≈ 12/s.
  • 7-char base62: 3.5 × 10¹² codes; 13% collision chance at 1M URLs.
  • Zipf(1.1): a 1% cache served 75.5% of reads.
  • Redis: ~110–120k ops/s per instance, ~2M with pipelining (lab).
  • Budget: ~46 study hours + 6 portfolio weeks ≈ 3 months at 8 h/week.

Pitfalls

  • Architecture before requirements; technology name-dropping.
  • Over-scaling; ignoring operations and failure.

Glossary

  • Back-of-the-envelope estimate: a quick order-of-magnitude calculation.
  • Birthday bound: collisions become likely around √N items.
  • Fan-out: delivering one event to many recipients.
  • Sharding: splitting data across nodes by key.
  • ADR: architecture decision record.

208

Phase 12 — AI Foundation

Key ideas

  • Sequence: Python → math → classical ML → deep learning → PyTorch → Transformers → LLMs.
  • Projects: a classifier, a neural network, a tiny Transformer, compared on one task.
  • Baselines first; evaluate on untouched test data; capacity needs data or pre-training.
  • LLMs are pre-trained next-token predictors, then instruction- and preference-tuned.

Numbers to remember

  • Lab (540 test digits): 100 images → LR 0.917, MLP 0.922, Transformer 0.719; 1,257 images → 0.970, 0.976, 0.978.
  • Parameters: 650 / 4,810 / 9,418.
  • Budget: ~28 study hours + 3–4 project weeks ≈ 7 weeks at 8 h/week.

Pitfalls

  • No baseline; tuning on test data; leakage.
  • Deep learning first; skipping the maths.
  • Over-reading tiny differences.

Glossary

  • Baseline: a simple model the real one must beat.
  • Overfitting: learning the training data rather than the pattern.
  • Cross-validation: repeated train/validation splits for more reliable estimates.
  • Attention: mixing positions with weights from query–key similarity.
  • Token: the unit a language model reads and predicts.

209

Phase 13 — AI Application Engineering

Key ideas

  • Sequence: embeddings → vector search → RAG → evaluation → structured output → tool calling → agents → multimodal.
  • Evaluate retrieval and generation separately; build the golden set early.
  • Delegate exact work to tools; validate tool calls.
  • Prefer pipelines; bound agents.

Numbers to remember

  • Lab: recall 0.457 at k=1 (~200 tokens) → 0.819 at k=10 (~2,000 tokens).
  • Digit router 92/100; intent router 100/100 (on a test set it was written for); calculator 40/40.
  • Budget: ~25 study hours + 4 project weeks ≈ 7 weeks at 8 h/week.

Pitfalls

  • No golden set; overfitting the evaluation.
  • Naive chunking; too much context.
  • Model arithmetic; unvalidated tool arguments.
  • Agents where a pipeline would do.

Glossary

  • RAG: retrieval-augmented generation.
  • Recall@k: share of queries whose answer is in the top k.
  • Reranking: re-scoring retrieved candidates with a stronger model.
  • Tool calling: the model emits a structured call; your code executes it.
  • Golden set: questions with known answers for evaluation.

210

Phase 14 — AI Production

Key ideas

  • Sequence: AI APIs → model routing → inference → caching → evaluation → security → tracing → cost → deployment → GPU awareness.
  • Route only on a measured, discriminating confidence signal.
  • Cache with scoping and expiry; trace every call with cost; gate deploys on evaluation and security tests.
  • The project integrates AI with the whole system, the bridge to the capstone.

Numbers to remember

  • Lab: cheap path 0.457; 93% accuracy needed 90% escalation and saved only 10% of cost (assumed large-model prices).
  • Prefill is parallel; decode is one token at a time.
  • Budget: ~12 study hours + 4–6 project weeks ≈ 6–7 weeks at 8 h/week.

Pitfalls

  • Single model, no fallback.
  • Weak routing signals; leaky caches.
  • No cost attribution; unevaluated prompt changes.

Glossary

  • Model gateway: a service that abstracts providers and adds policy.
  • Cascade / routing: send requests to models by difficulty or cost.
  • Semantic cache: reuse answers for similar requests.
  • TTFT: time to first token.
  • KV cache: stored attention keys and values for decoding.