Simulators

Each simulator is a small working model of a system or an algorithm. You change the inputs (add a key, cut a network link, send a burst of requests) and the diagram and the numbers change with it. There are 87 of them, they run in your browser, and many link to an article that covers the same topic in more depth.

Five to start with Each comes with a full article: how it works, its history and where it is used.
  1. B-tree Why a database index is only three or four levels deep.
  2. CAP theorem What a replicated database does when the network splits.
  3. Consistent hashing Adding a server without moving most of the keys.
  4. Bloom filter Answering "is this in the set?" in a few bits per item.
  5. Rate limiter Token buckets and sliding windows, request by request.

Distributed systems

Several machines that have to agree, share load or survive each other failing.

CAP theorem
Three replicas and two clients. Cut the network and choose whether the database stays consistent or stays available.
Consistent hashing
Add and remove servers on a hash ring and count how many keys move, compared with hash mod N.
Raft consensus
Five nodes running Raft. Stop the leader or cut off a follower and watch the election and the log replication.
Split brain
Partition a cluster your way and compare majority quorum, no quorum check and last-write-wins by leaders, refused writes and lost writes.
Read and write quorums
Set N, R and W, take replicas down, and see which reads and writes still succeed.
Database sharding
Range, hash and directory-based sharding compared on the same data.
Distributed lock
Clients compete for a lock held in Redis, ZooKeeper or etcd. Add GC pauses and partitions, then turn on fencing tokens.
Distributed cache
Four cache nodes in front of a database: hot keys, cache stampedes, node failures and write policies.
Rate limiter
Send requests through a token bucket, a leaky bucket, a fixed window or a sliding window and see which are let through.
Circuit breaker
Make a downstream service fail and watch the breaker open, test the service in the half-open state and close again.
Exponential backoff and jitter
Retry delays for exponential backoff with full, equal or decorrelated jitter, and hundreds of clients retrying against a recovering server.
Load balancer
Round robin, least connections, power of two choices and hashing, run on the same traffic.
Thundering herd and cache stampede
A hot cache key expires under load: compare no protection, locking, serving stale, XFetch early expiration and TTL jitter.
Chaos playground
Run a chaos experiment: inject latency, errors or a black hole into one dependency for a slice of traffic and compare it with a control group.

Databases

How data is stored on disk, queried and kept correct when things crash.

B-tree
Insert, search for and delete keys and watch nodes split and merge.
Extendible hashing
Insert your own keys and watch buckets split and the directory double, with global and local depths step by step.
Linear hashing
Insert your own keys and watch the split pointer advance, overflow pages appear and buckets split in order.
LSM tree
Writes go to a memtable, are flushed to SSTables and merged by compaction, as in RocksDB and Cassandra.
LSM tree vs B-tree
The same random writes through an LSM tree (leveled or tiered) and a B+ tree, with write, read and space amplification measured.
ARIES crash recovery
Paste a write-ahead log, crash, and step through ARIES analysis, redo and undo, with the dirty page table and the CLRs written.
ACID transactions
Run a money transfer, crash it halfway and see it rolled back. Add a concurrent reader at different isolation levels.
Isolation levels
Dirty reads, non-repeatable reads, phantoms, lost updates and write skew under the four SQL isolation levels.
Join cost calculator
I/O cost of nested loop, block nested loop, index, sort-merge and hash joins for your table sizes and buffer frames, worked step by step.
SQL joins
Two editable tables and the result of INNER, LEFT, RIGHT, FULL and CROSS joins between them.
Redis pipelining
How round-trip time, pipeline depth and client count limit Redis throughput, and how one slow command stalls every client.

Data structures

Ways of arranging data so that the common operations are fast.

Bloom filter
Add words to a bit array using several hash functions, test other words, and compare the false-positive rate with the formula.
Heap
A binary heap shown as a tree and as an array, with sift-up, sift-down and building a heap in linear time.
AVL vs red-black tree
The same keys inserted into an AVL tree and a red-black tree, with every rotation shown.
Red-black tree
Insert and delete keys in a red-black tree and watch the rotations and recolouring.
Skip list
Search, insert and delete in a skip list with random or given node heights, and follow the search path level by level.
Trie (prefix tree)
Build a trie from your own words: search, autocomplete a prefix, insert and delete, and compare it with the compressed radix tree.
Segment tree
Build a segment tree from your array and run range sum, min or max queries, point updates and lazy range adds, node by node.
Suffix tree and suffix array
Type a string to build its suffix tree, suffix array and LCP array, search for a substring and find the longest repeated substring.
LRU cache
A hash map and a doubly linked list working together: each read moves an entry to the front, and the oldest entry is evicted.
Cache eviction
LRU, LFU, FIFO, ARC and TinyLFU run on the same access pattern, with their hit rates side by side.
Linked list
Insert, delete and splice in singly, doubly and circular linked lists, with each pointer change shown.
Queue and stack
A queue, a stack, a deque and a priority queue side by side.
Vector embeddings
Cosine similarity, dot product and distance for two vectors you paste, and the recall an IVF index gives up for speed.

Algorithms

Searching, sorting, path finding and dynamic programming, one step at a time.

Sorting algorithms
Bubble sort, quicksort, merge sort and heapsort animated, with comparison counts.
Binary search
Binary search step by step, including the leftmost, rightmost and insertion-point variants.
Big-O race
Increase n and compare how O(1), O(log n), O(n), O(n log n) and O(n²) grow.
BFS vs DFS
Breadth-first and depth-first search on the same graph, driven by a queue and by a stack.
Dijkstra's algorithm
Dijkstra's shortest-path algorithm on a grid with weighted cells.
A* pathfinding
A* search on a grid with a choice of heuristic. With no heuristic it behaves like Dijkstra.
Recursion visualizer
Step through factorial, Fibonacci, Tower of Hanoi, GCD and merge sort call by call, with the recursion tree, call stack and memoization.
Longest common subsequence
Fill in the table for the longest common subsequence of two strings, then trace the answer back.
N-queens backtracking
Place N queens row by row and watch the search back up when it gets stuck.
Decision tree
Build a decision tree classifier one split at a time, with splits chosen by Gini impurity.
Kadane, sliding window, two pointers
Step through Kadane's algorithm, sliding windows, two pointers and prefix sums on your own array, checked against brute force.

Networking and the web

What happens between a browser and a server, packet by packet.

TCP handshake
The TCP three-way handshake and connection teardown, with sequence numbers, one step at a time.
TCP vs UDP
Send the same data over TCP and UDP with packet loss and reordering, and compare what arrives.
TCP congestion window
cwnd and ssthresh round by round for TCP Tahoe or Reno with your own losses, and how CUBIC differs.
DNS resolution
Look names up through a shared recursive resolver: referrals from the root, caching by TTL, CNAMEs, NXDOMAIN and a nameserver that stops replying.
HTTP message analyzer
Paste an HTTP request and response or curl -v output and get every header explained, with cache lifetime, cookie checks and framing errors.
HTTP/2 streams
Several requests sharing one HTTP/2 connection: frames, flow control and head-of-line blocking.
HTTP/3 and QUIC
HTTP/2 and HTTP/3 loading the same page. Drop a packet and compare how each one recovers.
CORS preflight
Choose a method, headers and the server's CORS response, and see whether the browser sends a preflight and allows the request.
gRPC vs REST
The same call made with gRPC and with REST: wire format, streaming and error handling.
JSON vs Protobuf
The same message encoded as JSON and as Protocol Buffers: size, parsing cost and schema changes.
Anycast routing
Six sites announce one address over BGP. Withdraw or prepend a site and see which site every ISP reaches, and why it is often not the nearest.

Operating systems and runtimes

The kernel, memory, CPU scheduling and the runtimes that sit on top of them.

System calls (strace)
Copy a file with read and write, mmap or sendfile and see every system call as strace shows it, with counts by buffer size and the registers.
CPU scheduler
The same five jobs scheduled by first-come-first-served, round robin, priority and a CFS-style fair scheduler.
Virtual memory
Touch virtual pages and see TLB hits and misses, page-table walks, page faults, swapping and copy-on-write.
Page replacement
FIFO, LRU, Optimal and Clock on your own reference string: the frame table, page faults and the reason for every eviction.
Disk scheduling
FCFS, SSTF, SCAN, C-SCAN, LOOK and C-LOOK on your own request queue, with a head-movement chart and the total seek distance.
Memory allocator
malloc and free with first-fit, best-fit and buddy allocation, and how fragmentation builds up.
Stack frame
See where a C function’s arguments, return address, saved frame pointer and locals sit on x86-64 or 32-bit x86, with offsets and alignment.
Inode calculator
Maximum file size, pointer path and disk reads for any byte, and the indirect blocks a file needs, for any block size and inode layout.
Linux boot
Model a systemd boot from its units and dependencies, and read the timeline with systemd-analyze time, blame and critical-chain.
CPU caches and MESI
Four cores with private L1 caches and a shared L3, kept coherent with the MESI protocol, plus a false-sharing example.
Event loop
Queue timers, promises and animation callbacks, and step through the JavaScript event loop to see the order they run in.
Goroutine scheduler
Go's scheduler: goroutines, OS threads and processors (G, M and P), work stealing and preemption.
Mutex deadlock
Two threads take two locks in opposite orders and deadlock. Change the order or use try-lock to avoid it.
Banker's algorithm
Enter Allocation, Max and Available to get the Need matrix, the safety check step by step, a safe sequence and request decisions.
Hack CPU emulator
Write Hack assembly from nand2tetris, assemble it to machine code and run it on a CPU with RAM and a screen, plus the ALU built from NAND gates.

Containers and cloud

Containers, Kubernetes and the AWS services most systems are built on.

Docker internals
A container built from namespaces, cgroups and an overlay file system. Turn each one off and see what it was isolating.
Container layers
Edit a Dockerfile and rebuild it to see which layers come from the cache and which are rebuilt.
Kubernetes rolling update
A Kubernetes rolling update with maxSurge and maxUnavailable, pod by pod.
Pod eviction
See which pods the kubelet evicts under memory pressure, which the OOM killer picks, and when kubectl drain is blocked by a disruption budget.
Kubernetes scheduler
Step through kube-scheduler's filters and scores for each pod, with taints, anti-affinity, topology spread and the message a Pending pod gets.
Service mesh
Requests down a chain of services through sidecar proxies: how retries multiply load and how outlier detection ejects instances, healthy ones included.
Auto scaling group
An AWS auto scaling group following a changing load with target tracking, cooldowns and alarm delay.
S3 prefix request rates
Spread PUT and GET traffic over S3 prefixes, see which exceed 3,500 writes or 5,500 reads a second, and what retries do to 503 Slow Down.
VPC packet flow
Trace a connection through an AWS VPC hop by hop: route tables, stateless network ACLs, stateful security groups, NAT and internet gateways.
CloudFront cache TTL
Paste a Cache-Control header to see how long CloudFront caches it under your TTL settings, and how many requests reach the origin with and without Origin Shield.

Security

Storing passwords and passing around signed tokens.

Password hashing
Hash a password with SHA-256, PBKDF2, bcrypt, scrypt and Argon2id in your browser, then attack a leaked table.
JWT lifecycle
Issue, verify, refresh, rotate and revoke JSON Web Tokens.

Articles · Animated walkthroughs · Codex