Skip to content

System Design Beyond the Basics in C++

Glossary

184 terms from System Design Beyond the Basics in C++, in plain words, each with the chapter that teaches it.

#

#pragma once
A line at the top of a C++ header that tells the compiler to include the file only once, even if several files include it. Kettle & Crane's `envelope.hpp` starts with it.
80/20 rule
A rule of thumb that about 20% of the data (the hot data) gets about 80% of the reads. Kettle & Crane can cache only that hot share of customer profiles instead of all of them.

A

Ack (acknowledgement)
A replica's confirmation that it stored a write. A quorum write waits for W acks before it counts as done.
Active-active
A multi-region setup where both regions serve customers at the same time. Kettle & Crane picks this to cut latency and keep failover always tested, at the cost of two full regions and possible write conflicts.
Active-passive
A multi-region setup where one region serves traffic and the other keeps copies and waits. It is simple, but gives no latency gain and the idle region may fail when needed.
Adaptive bitrate
A streaming technique where the video player measures its connection speed and fetches each next segment from the rendition that fits. A slow phone drops to 480p instead of stalling.
Amazon S3
Amazon's object storage service, which holds file bytes (blobs) under object keys. It is a common home for files such as product photos, with facts about each file kept separately in a database.
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
A single front door that checks every request, such as for rate limits, before the app sees it.
API key
A secret string that a client, such as a café's software calling the wholesale API, sends to identify itself. It makes a good key for rate limiting.
assert
A C++ macro from `<cassert>` that stops the program with a message if its condition is false. If a test program reaches its last line, every assert passed.
Assumption
A guess you choose to work with and say out loud in an interview, such as 'I'll assume 60,000 orders a day'. Stating it lets the interviewer correct you early.
Asynchronous replication
The leader confirms a write right away and followers catch up later. It is fast, but a crash can lose the latest writes, which is why cross-region copies have an RPO.
At-least-once
A delivery guarantee from committing the offset after processing. A crash in between means the event arrives again, so consumers must be idempotent.
At-most-once
A delivery guarantee from committing the offset before processing. There are no duplicates, but a crash after the commit loses the event, so it suits view counts and never orders.
Atomic increment
A single step that adds one to a counter and returns the new value, such as Redis's `INCR`. It stops two servers from both reading 4 and writing 5.

B

Bandwidth
A network link's throughput, counted in bits per second and rated in Mbps (millions of bits per second). Since a byte is 8 bits, 1 MB a second needs 8 Mbps.
Blob
A file's raw bytes, such as a product photo or a brewing-class video. Blobs go in object storage while facts about them go in the database.
BM25
The standard search relevance formula. Rare words count more than common ones, and long texts count a little less, so 'chocolatey' outranks 'espresso' in Kettle & Crane's products.
Bottleneck
The one component that limits the whole system, like a bottle's neck limits pouring. For Kettle & Crane's national shop it is peak traffic, not storage.
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 without serving a stale picture.
Cassandra and DynamoDB
Widely used databases that partition data across nodes with hashed rings. Both offer local and global secondary indexes for finding rows by something other than the partition key.
Causal consistency
A promise that 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 files such as images and video segments. Kettle & Crane serves images from `cdn.kettleandcrane.com`.
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 an event log.
CHECK macro
A small macro defined in `test_national.cpp` that counts a failure and prints the failed condition with its line number, so plain C++ tests need no library.
Chunk
One piece of a large file in a multipart upload, say 8 MB. A failed chunk can be resent on its own.
Committed offset
The next offset a consumer group will read in a partition. After a restart the group carries on from there, and when it commits decides what a crash costs.
Conflict
Two writes to the same key happening at once in different places, as can occur with multi-leader or leaderless replication. Rules like last-write-wins or merging resolve them.
Consensus
Getting nodes to agree on one value, or one order of changes, even when some fail. It is how a cluster agrees on a single leader.
Consistency model
A promise about what a read may return. Models run from linearizable down through causal, read-your-writes and monotonic reads to eventual.
Consistent hashing
Placing both keys and shards on a hash ring so that adding a shard moves only about its fair share of keys. With `% n` going from 4 to 5 shards, 795 of 1,000 customers moved, but the ring moved 188.
Constant-time comparison
Comparing two strings by checking every character so the time taken doesn't reveal where they differ. It stops attackers guessing a signature by timing the answers.
constexpr
A C++ keyword marking a value fixed at compile time, such as the constant `SECONDS_PER_DAY`.
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.
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.
CRC32
A fast, stable hash function that turns data into a 32-bit number. It is often used to pick a partition for a key, for example with `hashing::crc32` and `% n`.
Cross-region replication
Each region copying its data to the other for disaster recovery. It is asynchronous, because waiting 70 ms on every write would be too slow.

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 citizens' data to stay inside the country. Global shops may need a region there.
Deduplication
Storing files or chunks with the same content hash only once. In the 20 MB test file, chunks 1 and 2 are identical, so one copy is enough.
Deep dive
A close look at one hard part of a design, such as how payments avoid double charges. Interviews spend minutes 30 to 40 on them.
Direct upload
A browser sending file bytes straight to object storage using a signed URL, so app servers only handle small requests.
Dirty read
Seeing another transaction's unfinished changes. The read committed isolation level 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 app servers.
Double-entry ledger
A record of money where each movement is written as entries in two or more accounts that add up to zero. Mistakes are fixed with new entries, never edits.
Durability
How surely stored data survives failures. Object storage reaches very high durability using erasure coding or copies.

E

Egress
Data leaving your network, which clouds charge for. It is the big cost in video streaming, so a CDN serves it cheaply.
Elasticsearch and OpenSearch
Search engines that keep the inverted index for you, rank with BM25, and shard indexes with scatter-gather queries.
emplace
A C++ map method that inserts an entry only if the key is new, and returns the entry plus a `bool` saying whether it was inserted. It works as an "insert or ignore", so a retried order with the same ID is stored only once.
Erasure coding
Splitting data into pieces plus extra computed pieces so lost pieces can be rebuilt. Storage services get high durability this way without keeping three full copies.
etcd and ZooKeeper
Services that store small shared facts, such as who leads or which shards exist, using consensus. You use them instead of writing consensus yourself.
Event
A record that something happened, such as an order placed. A log keeps events in arrival order.
Event streaming
Building systems around a log that keeps events so many readers can read them 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 writing elsewhere must still be idempotent.

F

Failover drill
Turning a region off on purpose at a quiet time to measure the real RPO and RTO. Targets mean nothing until tested this way.
Fan-out
How a post reaches followers' feeds. Below a threshold, such as 10,000 followers, the post is pushed into each follower's cached list. Bigger authors are pulled and merged at read time.
Feed cache
A cache of each account's latest feed, a list of post IDs. Caching the hottest 20% of 1,000,000 accounts takes about 0.8 GB.
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 after a split brain.
Fixed window counter
A limiter that counts requests per key in fixed windows, such as each minute. It needs one counter per key but allows a window edge burst.
Follower
A node that holds a copy of the leader's data and applies its changes. If the leader dies, a follower must take over.
Full-text search
Finding products whose text contains the typed words, best match first. It uses an inverted index, because SQL `LIKE '%word%'` would scan 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 for each map grid cell. It is the common real-world version of the courier grid.
Grid cell
A square of the map about 1 km across, found by rounding latitude and longitude to 2 decimals. 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 next shard point clockwise, wrapping around after the largest point.
Headroom
Spare capacity kept in reserve for surprises. Servers are planned at about 70% load, so a server that can handle 300 requests a second counts as handling 210.
Health check
A periodic test of whether a server or region is working. Failed checks remove a server or trigger failover to another region.
Hex digits
Base-16 digits where `a` to `f` stand for 10 to 15. Two hex digits make one byte, so MD5's first eight hex digits form a 32-bit ring position.
HLS (HTTP Live Streaming)
A common video streaming format in which 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 a signed URL, but only the secret's holder can make a matching signature.
Home region
The region that holds a customer's account and orders and serves them, chosen from their shipping state. It keeps each customer's writes in one place, so two regions rarely write the same row.
Hot key
A single key getting far more traffic than others, such as the feed of a famous café. Even spread across shards doesn't help it, but key salting does.
HTTP status codes
Three-digit numbers a server returns to say how a request went. For example, 429 Too Many Requests is sent when a client has hit its rate limit, normally with a `Retry-After` header telling it how many seconds to wait.

I

Idempotency key
A unique value sent with a request, such as the order ID on a payment call. On a retry the provider returns the first result instead of charging again.
Idempotent
Safe to do more than once with the same result as doing it once. A shipping consumer that skips order IDs it already shipped can replay events without double shipping.
IDF (inverse document frequency)
The part of BM25 that is large when few documents contain a word and near zero when about half do. It is why 'espresso' scores about 0.
Indexer
A worker that updates the search index when a product-change event arrives. The database stays the source of truth.
inline
A C++ keyword that lets a function be defined in a header safely, even when several files include it.
Integrity
Assurance that bytes arrived unchanged. If the hash computed after upload matches the one the browser sent, integrity holds.
Inverted index
A map from each word to the set of documents containing it, like the index at the back of a book. It lets search find products without scanning every row.
Isolation level
A setting that says how much concurrent transactions in one database can see of each other's work. Common levels are read committed, snapshot isolation and serializable, trading speed for fewer surprises.

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, which stores topics as partitioned logs. Kafka 4 runs on KRaft instead of ZooKeeper and replicates each partition across brokers.
Key salting
Splitting a hot key into parts by adding a suffix, such as `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, measured in milliseconds, microseconds or nanoseconds. Memory is about 1,000 times faster than an SSD read.
Leader
A node that accepts writes and sends them to its followers. Single-leader systems give writes one clear order.
Leader election
Followers voting for a new leader when they stop hearing from the old one. A candidate wins only with a majority of all nodes.
Leaderless replication
The client writes to several replicas at once, and no single leader exists. Quorums decide, and reads check several replicas for the newest value.
Leaky bucket
A rate-limiting cousin of the token bucket. Requests join a queue that drains at a steady rate, smoothing bursts instead of allowing them.
Lifecycle rules
Storage settings that move or delete objects by age, for example moving to archive after 90 days.
LIKE (SQL)
SQL's pattern match, where `%` matches any text. `LIKE '%espresso%'` can't use an index, so the database scans every row.
Linearizable
The strongest model: the system acts like one copy of the data, and once a write is confirmed every later read sees it. Stock and payments need it.
Local fallback limit
A looser per-server rate limit used when the shared store is down, so the shop doesn't refuse everyone.
Local index / global index
Two kinds of secondary index. A local index is kept per shard, so writes are cheap but queries ask every shard. A global index is partitioned by the indexed value, so queries ask one place but writes touch two shards and the index can lag.
Log replication
In Raft, the leader adds each change to its log and sends it to followers. Once a majority store it, the change is committed and survives any later election.
Lost update
A write that vanishes without an error, such as Sam's delivery note being dropped when Priya's later timestamp wins.
Lua script
A script run inside Redis so that reading and writing a token bucket becomes a single atomic step.

M

Macro
Text the C++ preprocessor pastes in before compilation. For example, a `CHECK` macro can report a failed test condition along with its line number.
Majority
More than half of all nodes, counting the candidate itself. Two majorities of the same cluster always share a node, so two leaders can't win the same term.
MD5
A hash function that spreads values evenly, which makes it useful for stable positions on a hash ring. It is too weak to use for security.
Metadata
Facts about a file, such as name, size, owner, type and object key, kept in a database row rather than with the bytes.
Monotonic reads
A promise that you never go back in time: once you've seen version 5, you never get version 4. It keeps an order from vanishing on refresh.
Multi-leader replication
Several leaders, usually one per region, each accepting writes and sending them to the others. Writes stay local and fast, but two leaders can change one row at once.
Multipart upload
Splitting a large file into chunks sent in parallel. A failed chunk is resent alone.

N

Network partition
A network failure that cuts nodes off from each other, so each side can't reach the other. It can leave an old leader isolated and cause split brain.
Non-repeatable read
A row changing between two reads inside one transaction. Read committed allows it, and snapshot isolation prevents it.

O

Object key
The name under which a blob is stored in object storage, such as `products/mug-blue/1.jpg`.
Object storage
A service such as Amazon S3 that stores file bytes under object keys, keeping big files out of app servers and databases.
Offset
An event's position in its partition, starting at 0. Consumers track where they are by offset.

P

p99
A latency target meaning 99 of 100 requests are faster than this value. Kettle & Crane aims for p99 under 300 ms.
Partition (of a topic)
One ordered list of events within a topic. Spreading partitions across brokers spreads load, and order is kept only within a partition.
Partitioning (sharding)
Splitting data across several databases (shards) by a key, such as customer ID. Consistent hashing decides which shard owns each key.
Paxos
An older consensus algorithm that solves the same problem as Raft.
Payment provider
A service such as Stripe that holds card details, so they never touch Kettle & Crane's servers.
Posting set
The set of documents (SKUs) that contain one word in an inverted index. An AND query keeps the SKUs found in every word's posting set.

Q

Quorum
A set of replicas big enough to decide: W acks to write, R answers to read. If W + R > N, a read always overlaps the latest write.

R

Raft
The common consensus algorithm, which elects a leader by majority, numbers terms and commits changes that a majority holds.
Ranking
Sorting search results best first by relevance, a score for how well a document fits the query. Scores range from simple term counts to BM25.
Rate limiter
A mechanism that caps how many requests one client may make in a period. It protects servers from bursts, shares capacity fairly and caps costs.
Read committed
An isolation level that prevents dirty reads but still allows a row to change between two reads.
Read-your-writes
A session guarantee that you always see your own writes. After a customer saves a profile change, 'saved' must look saved to them.
Rebalancing
Moving data when shards change. It runs in the background: copy the moving keys, switch the ring, then delete the old copies.
Reconciliation
Comparing your records with a partner's report. A nightly job checks the ledger against the payment provider's report and flags differences.
Redis
A fast in-memory store used here as the shared place for rate-limit counts and courier positions.
Region
A cloud provider's group of data centers in one area, such as us-west near Portland and us-east near Columbus.
Reindex
A job that rebuilds the search index from the database to repair drift, such as a missed update event.
Rendition
One quality level of a video, such as 1080p at 5,000 kbps, 720p or 480p, made by transcoding.
Replay
Reading events again from an old offset. A new consumer group starts at offset 0 and sees all events still within retention.
Replica
One copy of a piece of data on another node. A leaderless store keeps N replicas of each key.
Replication lag
The delay before a copy has a write. Across regions it is usually hundreds of milliseconds, and writes inside the lag are lost if the region dies.
Resumable upload
An upload cut off halfway that carries on from the last chunk that arrived rather than starting over.
Retention
How long a topic keeps events, say 7 days, whether or not anyone has read them. After that, a new reader can't see them.
Retry-After header
An HTTP header sent with a 429 response giving the seconds a client should wait before trying again.
RPO / RTO
RPO (recovery point objective) is how much recent data you may lose in a disaster, measured in time. RTO (recovery time objective) is how long recovery may take. Kettle & Crane targets under 5 s and 15 minutes.
RPS (requests per second)
The number of requests a system handles each second. Peak RPS is the average rate multiplied by a peak factor and drives server sizing.

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, so give each a timeout.
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 the signing key, instead of putting them in code.
Segment
A few seconds of video, such as 4, fetched as one file. A playlist lists each rendition's segments.
Semi-synchronous replication
A leader waits for just one follower to confirm a write, a middle ground between synchronous and asynchronous.
Serializable
The strictest isolation level: transactions behave as if run one at a time. It prevents everything, but is the slowest.
Session guarantee
A promise to one user's session rather than to everyone, such as read-your-writes or monotonic reads. They are cheap, needing only a version number per session.
SHA-256
A secure hash function. It is used for content hashes and as the hash inside HMAC.
Shard
One slice of partitioned data, such as one order database. In the prototype a `Shard` is a map from order ID to order, so each ID exists once.
Signed URL
A link to storage that works only as issued and until it expires, proved by an HMAC signature. It lets browsers upload and download directly.
Sliding window log
A limiter that stores the time of each allowed request and counts only those in the last window. It is exact but uses memory for one timestamp per request.
Snapshot isolation
An isolation level that prevents non-repeatable reads but still allows write skew.
Source of truth
The authoritative copy of data. The product database is the source of truth, and the search index is a copy built for fast reading.
Split brain
Two nodes both believing they lead, for example an old leader cut off by a network partition. Fencing tokens and majority votes guard against it.
Stale read
A read that returns an older value than the latest write, such as reading a replica the write skipped when W + R is not more than N.
State machine
A list of allowed states and moves, with every other move refused. A payment can go from authorized to captured, but a failed one can't be captured later.
std::function
A C++ type that holds any callable, such as a lambda. The token bucket takes one as its clock so tests can pass a fake.
std::hypot
A C++ function that returns the straight-line distance for given x and y differences. Courier matching uses it to find the closest courier.
std::lower_bound
A C++ search on a sorted range that halves the range and returns the first item not less than x. Typeahead uses it to find where a prefix would go.
std::pair
A C++ type holding two values that compares by its first item first. It can be a `std::map` key but has no hash for `unordered_map`.
std::partial_sort
A C++ function that puts only the first few places in order and leaves the rest unsorted. The feed uses it to rank 20 posts without sorting thousands.
std::string_view
A C++ type naming a slice of existing bytes without copying them. The chunk splitter uses it to cut a 20 MB file cheaply.
std::upper_bound
A C++ search on a sorted range that halves the range and returns the first item greater than x. The hash ring uses it to find the next point clockwise.
Stop words
Very common words, such as 'the', 'a' and 'in', dropped from search because they don't help tell documents apart.
Storage classes
Storage tiers that trade price for speed. Hot storage holds product photos, and cheaper cold or archive storage holds old raw videos.
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 term one higher, and a node that hears of a higher term steps down.
Term frequency
How often the query's words appear in a document's text. It is the simplest relevance score and one input to BM25.
Throughput
How much work a system finishes per second, as opposed to how long one piece takes. More highway lanes add throughput without making the drive shorter.
Thumbnail
A small copy of a photo, such as 200 or 800 px wide, made by a worker after an upload and stored back in object storage.
Token bucket
A limiter giving each key a bucket of up to capacity tokens. Each request spends one and tokens refill at a steady rate, so a quiet client saves up a burst.
Tokenize
Lowercasing text and splitting it into words, called tokens, before building an inverted index.
Topic
A named stream of events in Kafka, split into partitions. Kettle & Crane's `orders` topic is keyed by customer ID.
Trade-off
What you give up to get something. Seniors state it as 'We choose X because Y. The cost is Z.'
Transaction
A group of database reads and writes that succeed or fail together. Isolation levels say how much transactions running at once can see of each other.
Transactional outbox
Writing the order and its event row in one transaction, then letting a relay publish the row. It avoids losing the event if a crash happens between steps.
Transcoding
Converting an uploaded video into several renditions and cutting each into segments.
TTL (DNS TTL)
The time DNS resolvers may keep an answer. Lower it, for example to 60 s, before failover drills so clients switch regions faster.
Typeahead
Suggesting names as the user types. A binary search such as `std::lower_bound` on sorted names finds where the typed prefix would go.

U

Unix time
A time written as seconds since January 1, 1970. It is used for edit timestamps and signed-URL expiry.

V

Version
A number that grows with each change. Replicas and sessions compare versions to find the newest data.
Version vector
One counter per replica, kept so a system can tell a real conflict from one write simply following another.
Virtual node (vnode)
One of many ring points given to each shard so many small arcs average out. With 100 vnodes each shard lands close to its fair 250 customers.

W

Window edge burst
The weakness of a fixed window counter: a client can send a full limit at the end of one window and again at the start of the next, such as 10 requests in one second.
Write skew
Two transactions each check a rule, then both write and together break it, such as two baristas both signing off when one must stay. Snapshot isolation allows it.