Core Recap
Engineering fundamentals, explained from the start. 81 lessons on system design, databases, algorithms and engineering practice. Each one starts with a plain definition and where the idea came from, explains how it works, walks through a worked example with a picture, and ends with common mistakes and a quick self-check.
Start with lesson 1: Capacity estimation Part 1 System design30 lessons
How large services stay fast, correct and available — from sizing a system to surviving failures.
1 Capacity estimation Capacity estimation is a quick calculation of how much work a system must handle — requests per second, storage and bandwidth — so you can tell whether a design will hold up before you build it. 2 Little’s Law Little’s Law says that the average number of items inside a system equals the rate at which they arrive multiplied by the average time each one stays: L = λ × W. 3 Queueing and saturation Queueing theory is the mathematics of waiting lines. 4 Amdahl’s Law Amdahl’s Law gives the maximum speed-up you can get by spreading a task across more processors or machines, when part of the task can only run one step at a time. 5 Tail latency and fan-out Tail latency is the response time of your slowest requests: p99 is the time that 99% of requests beat and 1% exceed. 6 SLOs and error budgets An SLI (service level indicator) measures what users experience, such as the percentage of requests that succeed quickly. 7 Caching and invalidation A cache is a small, fast store that keeps copies of data that is slow or expensive to fetch, so repeated reads are quick. 8 Cache stampede and hot keys A cache stampede (also called a thundering herd or dog-piling) happens when a popular cache entry expires and many requests miss at the same moment, so they all rush to the database together. 9 Consistent hashing Consistent hashing is a way to assign keys to servers so that when a server is added or removed, only a small fraction of keys move to a new server. 10 Sharding and hot partitions Sharding (horizontal partitioning) splits one large dataset into pieces called shards, each stored on a different server, so no single machine has to hold or serve all of the data. 11 Replication and lag Replication keeps copies of the same data on several machines, so the system survives a machine failure and can serve more reads. 12 CAP and PACELC The CAP theorem says that when a network partition cuts replicas off from each other, a distributed system must choose between Consistency (every read sees the latest write) and Availability (every request still gets a non-error answer). 13 Quorum reads and writes In a quorum system with N copies of each piece of data, a write must be confirmed by W copies and a read must ask R copies. 14 Raft, Paxos and FLP Consensus means getting a group of machines to agree on one value — or on one ordered list of commands — even when some machines crash or messages are delayed. 15 Leases and fencing tokens A lease is a lock that expires on its own after a set time. 16 Idempotency and deduplication An operation is idempotent if doing it twice has the same effect as doing it once. 17 Transactional outbox and CDC The transactional outbox pattern saves a business change and the event announcing it in the same database transaction. 18 Sagas and workflow state A saga is a long business process split into a series of local transactions, each in one service. 19 Change data capture Change data capture (CDC) reads a database’s own change log — every insert, update and delete — and streams those changes to other systems such as search indexes, caches or analytics stores. 20 Timeouts, retry budgets and jitter A timeout is the maximum time you wait for an answer. 21 Circuit breakers and bulkheads A circuit breaker wraps calls to another service and, after too many failures, opens — failing calls immediately for a while instead of waiting on a broken dependency. 22 Backpressure and load shedding Backpressure is a signal that tells a producer to slow down because the consumer is full. 23 Hedged requests A hedged request sends a second copy of a request to another replica if the first hasn’t answered within a short delay, then uses whichever answer arrives first and cancels the other. 24 Rate limiting algorithms Rate limiting caps how many requests a client may make in a period of time — for example 100 per minute — to keep a service fair and protect it from overload or abuse. 25 Message queues versus streams A message queue hands each message to one worker, and the message is deleted once processed. 26 Logical clocks and ordering Logical clocks number events by cause and effect rather than by wall-clock time, because clocks on different computers drift and can’t be trusted to agree. 27 Multi-region design and disaster recovery Multi-region design runs a system in several geographic regions so it survives the loss of a whole data center. 28 Observability and incident diagnosis Observability is how well you can understand what is happening inside a system from what it reports: metrics (numbers over time), logs (records of individual events) and traces (the path of one request across services). 29 Zero-downtime changes A zero-downtime change updates a database schema or an API while the service keeps running, by making every step compatible with both the old and the new code. 30 Security boundaries Security boundaries are the points in a system where you check who someone is (authentication) and what they are allowed to do (authorization), so that one user or one customer organization (a tenant) can never read or change another’s data. Part 2 Databases15 lessons
How databases store, find and protect data: indexes, transactions, isolation and recovery.
1 B-tree and B+ tree A B-tree is a balanced search tree whose nodes are wide — each holds hundreds of sorted keys and has hundreds of children — so any key can be found by reading just a few disk pages. 2 LSM trees A log-structured merge tree (LSM tree) is a storage design that makes writes fast: it collects new writes in memory, writes them to disk in large sorted files, and later merges those files in the background (compaction). 3 Read, write and space amplification Amplification measures how much extra work a storage engine does compared with what you asked for. 4 Bloom filters A Bloom filter is a compact bit array that answers “is this item in the set?” with either “definitely not” or “probably yes”. 5 Composite and covering indexes An index is an extra, sorted data structure (usually a B-tree) that lets the database find rows without scanning the whole table. 6 Query plans and selectivity A query plan is the step-by-step strategy the database chooses to run a SQL query — which indexes to use, in which order to join tables, how to sort. 7 MVCC and snapshots Multi-version concurrency control (MVCC) keeps several versions of each row, so a reader sees a consistent snapshot of the data as of a moment in time while writers create new versions in parallel. 8 Isolation levels and anomalies Isolation levels define how much concurrent transactions can see of each other’s work. 9 Optimistic and pessimistic concurrency Pessimistic concurrency locks a record before changing it, so nobody else can change it at the same time. 10 WAL and crash recovery A write-ahead log (WAL) is an append-only file where a database records every change before changing the data files. 11 ACID and invariants A transaction is a group of database operations that is treated as one unit. 12 Join algorithms A join combines rows from two tables that match on a condition. 13 Cursor pagination Pagination returns a long list in pages. 14 Normalization and denormalization Normalization organizes a database so each fact is stored in exactly one place, which prevents contradictions when data changes. 15 Backups and point-in-time recovery A backup is an independent copy of your data that you can restore after deletion, corruption or disaster. Part 3 Algorithms23 lessons
The core patterns behind efficient programs, each with a worked example and code.
1 Arrays and prefix sums A prefix sum array stores running totals: P[i] is the sum of the first i elements. 2 Hash tables A hash table (hash map, dictionary) stores key–value pairs and finds a key in about constant time on average. 3 Sliding window The sliding window technique processes a contiguous range of an array or string by moving its two ends forward, updating a running summary as elements enter and leave — instead of recomputing every possible range from scratch. 4 Two pointers The two-pointer technique walks two indices through a sequence — often from both ends toward the middle — and at each step uses a comparison to safely rule out a whole group of candidates. 5 Binary search and monotone predicates Binary search finds a target — or a boundary — in a sorted range by checking the middle and discarding the half that can’t contain the answer, so it needs only about log₂(n) steps. 6 Heaps and top K A heap is a tree-shaped structure where every parent is smaller than (min-heap) or larger than (max-heap) its children. 7 Quickselect Quickselect finds the k-th smallest element of an unsorted list (for example the median) without sorting the whole list. 8 Monotonic stack A monotonic stack is a stack whose elements are kept in increasing (or decreasing) order. 9 Intervals and sweep line Interval problems deal with ranges like meetings [start, end). 10 Graph traversal BFS/DFS A graph is a set of nodes (vertices) connected by edges. 11 Topological sorting A topological sort orders the tasks of a dependency graph so that every task comes after everything it depends on. 12 Dijkstra and weighted shortest paths Dijkstra’s algorithm finds the cheapest path from one node to all others in a graph with non-negative edge weights (distances, times, costs). 13 Union-Find Union–Find (disjoint-set union) keeps track of which items belong to the same group. 14 Dynamic programming Dynamic programming (DP) solves a problem by breaking it into smaller overlapping subproblems, solving each one only once, and storing the answers so they can be reused. 15 Greedy algorithms A greedy algorithm builds a solution by repeatedly taking the choice that looks best right now, and never reconsidering it. 16 Backtracking and pruning Backtracking builds solutions one choice at a time; when a partial solution can no longer lead to a valid answer, it undoes the last choice and tries the next option. 17 Tries and string matching A trie (prefix tree) stores strings character by character along paths from a root, so all words sharing a prefix share the same path. 18 Fenwick and segment trees A Fenwick tree (binary indexed tree) and a segment tree let you both update single values and query ranges (sum, minimum, …) of an array in O(log n) each — something a plain prefix-sum array can’t do quickly. 19 Amortized analysis Amortized analysis measures the average cost per operation over a whole sequence of operations, guaranteed in the worst case. 20 Bit manipulation Bit manipulation works directly with the binary digits of integers using operators such as AND (&), OR (|), XOR (^) and shifts (<<, >>), to store sets compactly and compute certain results in constant time. 21 Linked lists and pointer invariants A linked list is a chain of nodes where each node holds a value and a pointer to the next node (in a doubly linked list, also to the previous one). 22 Binary trees and search trees A binary tree is a structure where each node has at most two children, left and right. 23 Two heaps and order statistics The two-heaps technique keeps a running median of a stream of numbers: a max-heap holds the smaller half and a min-heap holds the larger half, so the median is always at the top of one or both heaps. Part 4 Engineering practice13 lessons
What happens inside the machine and the team: memory, concurrency, testing, debugging.
1 Memory locality and false sharing Memory locality means a program accesses data that is close together in memory (spatial locality) or that it used recently (temporal locality). 2 Threads, processes and async A process is a running program with its own private memory. 3 Deadlock and synchronization A lock (mutex) lets only one thread at a time enter a critical section of code. 4 Memory ordering and atomicity A memory model defines when a write made by one thread becomes visible to other threads. 5 Profiling and benchmarking Profiling measures where a running program actually spends its time and memory. 6 API contract and compatibility An API contract is everything clients can rely on: endpoints, fields, types, error codes, pagination, limits and behaviour. 7 Design patterns as tradeoffs Design patterns are named, reusable solutions to common code-design problems — for example Strategy (swap an algorithm), Adapter (translate one interface to another), Decorator (wrap an object to add behaviour) and Factory (hide how objects are created). 8 Testing and property-based checks Testing checks that code does what it should. 9 Code review and maintainability Code review is when another engineer reads a change before it is merged, to catch bugs, improve clarity and share knowledge about the code. 10 Debugging production issues Debugging is finding and fixing the cause of unexpected behaviour. 11 TCP, HTTP and connection reuse TCP delivers a reliable, ordered stream of bytes between two computers over an unreliable network. 12 Virtual memory and scheduling Virtual memory gives each process its own private address space, which the operating system maps onto physical RAM page by page (usually 4 KB pages). 13 Secure coding Secure coding means writing code that resists common attacks: treating every input as untrusted data, never letting it be run as code (SQL, HTML, shell commands), and checking permissions on every action.
After the lessons PracticeCoding problems Try each one first, then reveal a hint, the approach and the code. Design cases Sketch the system yourself, then compare architecture and failure modes. SQL practice Write the query, then check edge cases and the expected result. Behavioral & leadership Honest, structured stories about ownership, conflict and judgment. Portfolio projects Build things that prove the theory, with measurable results. Further reading Back up or move your progress Progress, review schedule, bookmarks and notes stay in this browser and are never sent to a server. Export them as JSON to keep a copy or move to another device.
Export JSON Import JSON