System Design Beyond the Basics in Go
Glossary
175 terms from System Design Beyond the Basics in Go, in plain words, each with the chapter that teaches it.
#
- 80/20 rule
- About 20% of the data gets about 80% of the reads, so you only need to cache that hot share. Kettle & Crane caches the hot 20% of its 1,000,000 customer profiles.
A
- ack (acknowledgement)
- A replica's confirmation that it stored a write. A quorum write waits for W acks before it reports success.
- Active-active
- A multi-region setup where both regions serve traffic. Latency is lower and both regions are always tested, but writes in two places can conflict.
- Active-passive
- A multi-region setup where one region serves while the other keeps copies and waits. It is simple, but you gain no latency and the idle region may fail when needed.
- Adaptive bitrate
- The video player measures its connection speed and fetches each next segment from the rendition that fits. A slow connection drops to 480p instead of stalling.
- Anycast
- A routing method where several regions share one IP address and the internet's routing sends each user to the nearest one. It is the alternative to geo DNS.
- API gateway
- One front door that checks every request, for example with a rate limiter, before the app sees it.
- API key
- A secret string a client program sends to identify itself. Kettle & Crane limits each café's wholesale API key to a burst of 20, then 5 a second.
- Assumption
- A guess you choose to work with and say out loud, such as "I'll assume 60,000 orders a day." Stating assumptions lets the interviewer correct you early.
- Asynchronous replication
- The leader confirms a write at once and followers catch up later. It is fast, but a crash can lose the latest writes.
- At-least-once
- A delivery guarantee you get by committing an offset after processing the event. A crash in between means the event comes again, so consumers must be idempotent.
- At-most-once
- A delivery guarantee you get by committing before processing. There are no duplicates, but a crash after the commit loses the event.
- Atomic increment
- One step that adds to a counter and returns the new value, so two servers can't both read 4 and both write 5. Redis's INCR command does this for shared rate-limit counts.
B
- Bandwidth
- A network link's throughput, counted in bits per second and rated in Mbps (millions of bits a second). Moving 1 MB a second needs 8 Mbps.
- Bit
- A single 0 or 1. A byte is 8 bits, which is why converting bytes to bandwidth multiplies by 8.
- Blob
- A file's raw bytes, such as a product photo or a class video. Blobs go in object storage, and facts about them go in the database as metadata.
- BM25
- The standard search ranking formula. Rare words weigh more than common ones and long texts count a little less; sqlite's FTS5, Elasticsearch and OpenSearch use it.
- Bottleneck
- The one component that limits the whole system, as a bottle's neck limits how fast it pours. Deep dives should go to the parts that hold it.
- Broker
- A Kafka server that stores partitions of topics. Spreading partitions across brokers spreads the load.
C
- Cache busting
- Putting the content hash in a file's name, as in mug-blue.3f9a1c.jpg. A changed photo gets a new name, so the CDN can cache every name forever and never serve an old picture.
- Cassandra / DynamoDB
- Widely used databases that partition data with hashed rings and offer both local and global secondary indexes.
- Causal consistency
- Effects never appear before their causes. If Priya replies to a review, nobody sees the reply without the review.
- CDN (content delivery network)
- A network of servers near users that caches and serves images and videos. Kettle & Crane serves photos and class videos through it.
- Change data capture (CDC)
- Reading a database's own change log and publishing every change as an event. It is an alternative to the transactional outbox for feeding a log.
- Chunk
- One piece of a large file, say 8 MB, in a multipart upload. A failed chunk can be sent again on its own.
- Committed (Raft)
- In Raft, a change is committed once a majority of nodes store it, so it survives any later election.
- Committed offset
- The next event a consumer group will read in a partition. After a restart the group carries on from it.
- Conflict
- Two writes to the same key happening at once in different places, which can occur with multi-leader or leaderless replication.
- Consensus
- Getting nodes to agree on one value or one order of changes even when some fail. Raft and Paxos solve it.
- Consistency model
- A promise about what a read may return. They run from linearizable down through causal, read-your-writes and monotonic reads to eventual.
- Consistent hashing
- Placing keys and nodes on a hash ring so adding a shard moves only about its fair share of keys, not most of them as `% n` does.
- Constant-time comparison
- A comparison that takes the same time whether the first or last character differs, so attackers can't guess a signature by timing. Go's hmac.Equal does this.
- Consumer group
- A named reader of a log with its own committed offset per partition. The shipping and email groups each read every order event independently.
- container/heap
- Go's standard package that maintains a heap over any type implementing `heap.Interface`: `Len`, `Less`, `Swap`, `Push` and `Pop`. You call `heap.Push` and `heap.Pop`, and the package calls those methods in the right order, for example to keep a min-heap of the top-scoring posts in a feed.
- Content hash
- A hash of a file's bytes, such as SHA-256. It checks integrity after upload, allows deduplication, and can be put in file names for cache busting.
- Courier matching
- Assigning each same-day delivery to the nearest courier. Couriers' latest positions are kept in memory on a grid, and the order's cell and its 8 neighbors are searched.
- CRC-32
- A fast, stable hash function available in Go's `hash/crc32` package. It turns a key into a number, so partitioning by `hash % n` hashes the key with it and picks one of `n` partitions or shards.
- Cross-region replication
- Copying each region's data to the other region, asynchronously, so a regional disaster doesn't lose it all.
- crypto/md5
- Go package that makes a stable hash used to place keys on the ring. MD5 spreads well but is too weak for security uses.
D
- Data center
- A building full of servers. A cloud region is a group of them in one area.
- Data residency
- Laws in some countries requiring their citizens' data to stay inside the country, so a global shop needs a region there.
- Deduplication
- Storing identical files or chunks only once by recognizing their matching content hashes.
- Deep dive
- A close look at one hard part of a design, such as how payments avoid double charges. It gets the 10 minutes from minute 30 to 40 of the 45-minute plan.
- Direct upload
- Sending file bytes straight from the browser to object storage using a signed URL, so app servers handle only small requests.
- Dirty read
- Seeing another transaction's unfinished changes. Read committed prevents it.
- Distributed rate limiting
- Keeping one shared count per key in a fast store such as Redis, so a customer can't get 9 times the limit across 9 servers.
- DNS TTL
- How long resolvers may keep a DNS answer. Lower it, for example to 60 s, before failover drills so clients switch regions faster.
- Double-entry ledger
- A record of money movements where each movement's entries across accounts add up to zero, so money can't vanish unnoticed. Mistakes are fixed with new entries, not edits.
E
- Egress
- Data leaving your network, which clouds charge for. For video it is the big cost, so a CDN serves it.
- Elasticsearch / OpenSearch
- Search engines that rank with BM25 and shard the index by document, answering queries by scatter-gather.
- Erasure coding
- Storing data as pieces plus extra computed pieces so lost pieces can be rebuilt, giving high durability without keeping three full copies.
- etcd / ZooKeeper
- Tools that store small shared facts, such as who leads and which shards exist, using consensus so you rarely write it yourself.
- Event
- A record that something happened, such as an order placed. A log keeps events in arrival order.
- Event streaming
- Writing events to a log that many readers read, now or later. Apache Kafka is the best-known tool.
- Exactly-once
- Each event's effect happens once. Kafka offers it inside Kafka with transactions, but a consumer that writes elsewhere must still be idempotent.
F
- Failover
- Switching customers to a healthy region when their home region is down. Kettle & Crane's route() does this.
- Failover drill
- Turning a region off on purpose at a quiet time to measure the real RPO and RTO.
- Fake clock
- A function that returns a time variable the test controls, so tests of the token bucket never have to wait.
- Fan-out
- How a new post reaches followers' feeds. Hybrid fan-out pushes into followers' cached lists for small authors and pulls big authors' posts at read time.
- Feed cache
- A cache of each account's latest post IDs for the news feed, sized for the hottest accounts.
- Fencing token
- A number that grows with each new leader, such as its term. Storage rejects writes with a lower token, so an old leader's writes bounce.
- Fixed window counter
- A limiter that counts requests per key per fixed time window. It is cheap but allows a window edge burst.
- FTS5
- sqlite's full-text search extension, which ranks with BM25 (its scores are negative, so lower is better).
- Full-text search
- Finding products whose text contains the typed words, best match first. It needs an inverted index; SQL LIKE with wildcards scans every row.
G
- Geo DNS
- DNS that answers the shop's host name with the address of the nearest region, judged from where the request comes from.
- Geohash
- A short text code that names one cell of a map grid, so nearby places share a prefix. It is the common real-world way to implement grid cells for finding nearby things, such as couriers close to an order.
- Go commands (go run, go vet, go test, go mod init)
- `go run` builds and runs a program (name every file when there are several), `go vet` checks for likely mistakes, `go test` runs TestSomething functions from _test.go files, and `go mod init` creates a go.mod for a multi-file project.
- Grid cell
- A small square of the map, here latitude and longitude rounded to 2 decimals, about 1 km across. Courier matching searches the order's cell and its 8 neighbors.
H
- Hash ring
- A circle of hash values from 0 to 4,294,967,295. A key belongs to the first node point clockwise from its hash, wrapping around at the end.
- Headroom
- Spare capacity for surprises. You aim at about 70% load, so a server that handles 300 requests a second counts as 210.
- Hex digits
- Base-16 digits where a to f stand for 10 to 15. Eight hex digits give a number up to 4,294,967,295, the size of the ring.
- HLS (HTTP Live Streaming)
- A common video streaming format where each rendition is cut into short segments listed in a playlist.
- HMAC
- A hash of a message mixed with a secret key. Anyone can read the signed URL but only the secret's holder can make a matching signature.
- Home region
- The region holding a customer's account and orders, chosen from their shipping state, so writes for that customer happen in one place.
- Hot key
- One key, such as the feed of a famous café, that gets so much traffic that even a good spread doesn't help.
I
- idempotent
- Safe to repeat: doing it twice has the same effect as once. Consumers and payment calls use IDs, like an order ID, so retries don't duplicate work.
- idf
- A word's weight in BM25: rare words get large weights and a word in half the products gets almost none.
- Indexer
- A worker that updates the search index when product events arrive. A reindex job rebuilds the index from the database to repair drift.
- Integrity
- Assurance that bytes arrived unchanged, checked by comparing content hashes before and after upload.
- Inverted index
- A map from each word to the set of documents containing it, like the index at the back of a book. AND queries intersect the sets.
- Isolation level
- How much concurrently running transactions can see of each other. The levels range from read committed to snapshot isolation to serializable.
J
- Jitter
- A small random extra delay added to retries so clients don't all retry at the same moment.
K
- Kafka
- The best-known event streaming tool. It keeps events in partitioned logs for consumer groups; version 4 runs on KRaft.
- Key salting
- Splitting a hot key into parts by adding a suffix, like feed:bloom-cafe#0 to #3. Writes pick a part at random and reads fetch all parts.
- KRaft
- Kafka's own built-in Raft consensus, which replaces ZooKeeper in Kafka 4.
L
- Last-write-wins (LWW)
- Resolving a conflict by keeping the write with the later timestamp and dropping the other. It silently loses updates, so it suits data like a last-viewed time.
- Latency
- How long one piece of work takes. Memory reads take about 100 ns, SSD reads 100 µs and a trip across the US about 70 ms.
- Leader / follower
- A leader is a node that accepts writes; its followers are the nodes that copy those writes.
- Leader election
- When followers stop hearing from the leader, one asks for votes and becomes leader only if it wins a majority.
- Leaderless replication
- A style where the client writes to several replicas at once and any replica accepts writes. Quorums decide which value is newest.
- Leaky bucket
- A rate limiter cousin where requests join a queue that drains at a steady rate, smoothing bursts instead of allowing them.
- Lifecycle rules
- Rules that move or delete stored objects by age, such as to cheaper archive storage after 90 days. Storage classes trade price for speed.
- LIKE
- SQL's pattern match, as in LIKE '%espresso%'. An index can't help with a leading wildcard, so the database scans every row.
- Linearizable
- The system behaves like a single copy: once a write is confirmed, every later read by anyone sees it. Stock and payments need it.
- Local / global index
- Two kinds of secondary index: a local one is kept per shard (cheap writes, queries ask every shard), a global one is partitioned by the indexed value (one-place queries, costlier writes).
- Local fallback limit
- A looser limit each server applies on its own when the shared rate-limit store is down, instead of refusing everyone.
- Log
- An ordered list that keeps every event in arrival order instead of deleting it once handled, so many readers can read it now or later.
- Lost update
- A write that disappears with no error because another write overwrote it, as with last-write-wins.
- Lua script
- A script run inside Redis that makes read, change and write one atomic step. It lets a token bucket work across servers.
M
- Majority
- More than half of all nodes, counting yourself. Two majorities of the same cluster always share a node, so two leaders can't win one term.
- math.Hypot
- Go function giving the straight-line distance for a step of dx and dy, used to find the nearest courier.
- Merge
- Combining conflicting versions instead of dropping one, such as taking the union of two carts or keeping both notes for a person to pick.
- Metadata
- The facts about a file: name, size, owner, type and where it's stored. It lives in a database row that holds the object key.
- min-heap
- A structure that always hands back its smallest item first. Keeping only k items and dropping the smallest each time finds the top k posts without sorting everything.
- Monotonic reads
- A reader never sees older data after newer data: once you've seen version 5 you never get version 4. An order must not vanish on refresh.
- Multi-leader replication
- Several leaders, usually one per region, each accept writes and send them to the others. Writes stay local and fast, but conflicts are possible.
- Multipart upload
- Sending a large file as chunks, in parallel, that can be retried one at a time. A resumable upload carries on from the last chunk that arrived.
N
- Network partition
- A network failure that cuts nodes off from each other, such as an old leader that misses a new election. It can cause split brain.
- Non-repeatable read
- A row changing between two reads in one transaction. Read committed allows it; snapshot isolation prevents it.
O
- Object key
- The name of a stored object in object storage, such as products/mug-blue/1.jpg.
- Object storage
- A service like Amazon S3 that stores file bytes under object keys, leaving app servers free of big transfers.
- offset
- An event's position in its partition, starting at 0. A consumer group tracks the next offset to read.
P
- p99
- A latency target that 99 of 100 requests beat. Kettle & Crane aims for p99 under 300 ms.
- Partition (of a topic)
- One ordered sequence of events within a topic; a topic has several partitions to spread load. Events with the same key go to the same partition and stay in order. The word also describes splitting data across shards in general.
- Paxos
- An older consensus algorithm that solves the same problem as Raft.
- Payment provider
- A company such as Stripe that holds card details so they never touch Kettle & Crane's servers.
- Peak RPS
- The highest requests per second, estimated as the daily average times a peak factor. Kettle & Crane's national peak is about 1,852.
- Posting set
- The set of documents containing a given word in an inverted index. An AND query keeps the SKUs found in every word's set.
- Prefix
- The letters typed so far. Typeahead finds the first name in a sorted slice that could start with the prefix.
Q
- Quorum
- Enough replicas to decide: W must ack a write and R must answer a read. When W + R > N, a read always overlaps the latest write.
R
- Raft
- The common consensus algorithm, with leader election by majority, numbered terms and log replication; a change is committed once a majority hold it.
- Rate limiter
- A mechanism that caps how many requests a client may make in a period, protecting servers and sharing capacity fairly. Refused requests get status 429.
- Read committed
- An isolation level that prevents dirty reads but still lets a row change between two reads.
- Read-your-writes
- You always see your own writes, so "saved" looks saved to you. A session achieves it by reading only from replicas at least as new as its last seen version.
- Rebalancing
- Moving data when shards change, done in the background: copy the moving keys, switch the ring, then delete the old copies.
- Reconciliation
- Comparing your records with a partner's report, such as a nightly job checking the ledger against the payment provider's.
- Redis
- A fast in-memory store used for shared rate-limit counts (with INCR and Lua scripts) and for courier positions with geo commands.
- Region
- A cloud provider's group of data centers in one area. Kettle & Crane runs us-west near Portland and adds us-east near Columbus.
- Relevance
- A score for how well a document fits a query. Ranking sorts results best first, from simple term counts to BM25.
- Rendition
- One quality level of a video, such as 1080p at 5,000 kbps, 720p or 480p, made by transcoding.
- Replay
- Reading a log again from an old offset, possible because events stay until retention removes them.
- Replication lag
- How far a copy is behind its source. Cross-region copies usually lag by hundreds of milliseconds and sometimes seconds, which sets the RPO.
- Retention
- How long a topic keeps events, say 7 days, whether or not anyone has read them.
- Retry-After
- An HTTP header on a 429 Too Many Requests response telling the client how many seconds to wait before trying again.
- RPO (recovery point objective)
- How much recent data you may lose in a disaster, measured in time. Replication lag of up to 2 seconds gives an RPO of about 2 seconds.
- RTO (recovery time objective)
- How long recovery may take. Spotting an outage in 3 minutes and switching in 10 makes the RTO about 13 minutes.
S
- Scatter-gather
- Sending a query to every shard, taking each shard's top results and merging them. It is only as fast as the slowest shard.
- Secondary index
- An index for finding rows by something other than the shard key, such as orders for MUG-BLUE when orders are sharded by customer.
- Secrets manager
- A service for storing real secrets, such as a signing key, instead of putting them in code.
- Segment
- A few seconds of video, here 4, fetched as one file and listed in a playlist.
- Semi-synchronous replication
- A leader waits for just one follower before confirming a write, a middle path between synchronous and asynchronous.
- Serializable
- The strictest isolation level: transactions behave as if run one at a time. It is the slowest.
- Session guarantee
- A promise to one user's session, such as read-your-writes or monotonic reads, rather than to everyone. They cost only a version number per session.
- set (map[string]struct{})
- Go has no set type, so a map whose values carry no information serves as one; struct{} takes no memory.
- SHA-256
- A secure hash function from Go's crypto/sha256. It is used for HMAC signatures and content hashes.
- Sharding
- Splitting data across several databases (shards) by a key, such as orders by customer ID.
- Signed URL
- A link to storage that works only until its expiry, proved by an HMAC signature. It lets browsers upload or download directly without going through app servers.
- Single-leader replication
- One leader per piece of data takes every write, giving one clear order, but a follower must take over if it dies.
- Sliding window log
- A limiter that stores each allowed request's time and counts only those in the last window. It is exact but needs one timestamp per request.
- Snapshot isolation
- An isolation level that prevents non-repeatable reads but still allows write skew.
- sort.Search
- Go functions that find a position in a sorted slice by halving. They find the next point on the hash ring and the prefix start for typeahead.
- Source of truth
- The product database is the authoritative store; the search index is just a copy built for fast reading.
- Split brain
- Two nodes both believing they lead, such as an old leader cut off by a network partition. Fencing tokens guard against it.
- State machine
- A list of allowed states and moves; every other move is refused. A payment goes created, authorized, captured or failed, so a late retry can't capture a failed payment.
- Stop words
- Very common words, such as "the" and "in", dropped from search because they don't help.
- Synchronous replication
- The leader confirms a write only after followers have it. Nothing is lost if the leader dies, but every write waits for the slowest follower.
T
- Term
- A leader's numbered period in Raft. Each election starts a new, higher term, and a node that hears of a higher term steps down.
- term frequency
- How often a query word appears in a text. Raw counts are the simplest ranking score, and BM25 damps them.
- Threshold
- A number that decides between two behaviors, such as pushing posts only for authors with fewer than 10,000 followers.
- Throughput
- How much work a system finishes per second. More highway lanes add throughput; the drive takes just as long.
- Thumbnail
- A small copy of a photo, such as 200 or 800 px wide, made by a worker after upload and stored back in object storage.
- Token bucket
- A limiter where each key's bucket holds up to a capacity of tokens that refill at a steady rate. Each request spends one, so a quiet client saves up a burst.
- Tokenize
- Lowercasing text and splitting it into words, called tokens, before building or querying an inverted index.
- Topic
- A named stream of events, split into partitions.
- Trade-off
- What you give up to get something. A senior answer names it with "We choose X because Y. The cost is Z."
- Transactional outbox
- Writing an order and its event row in one transaction while a relay publishes the row, so no event is lost.
- Transcoding
- Converting an uploaded video into several renditions cut into segments.
- Typeahead
- Suggesting names as the user types, by finding the first name in a sorted slice that could start with the typed prefix.
V
- Variadic parameter
- A Go function parameter such as `down ...string` that takes any number of values, or none.
- Version
- A number that grows with each change to a value. Quorum reads keep the highest version, and sessions remember the highest one they've seen.
- Version vector
- One counter per replica, used by real systems to tell a true conflict from one write that simply follows another.
- Virtual node (vnode)
- One of many ring points given to each node, for example 100 per shard. The many small arcs average out into an even spread.
W
- Window edge burst
- The weakness of the fixed window counter: five requests at 0:59 and five at 1:00 all pass, doubling the limit around a boundary.
- Wrap around
- Going past the largest point on the hash ring back to the start, so keys after the last point belong to the first.
- Write skew
- Two transactions each check a rule, then both write and break it together, such as two baristas both signing off when one must stay. Snapshot isolation allows it.