Skip to content

System Design Basics in JavaScript

Glossary

158 terms from System Design Basics in JavaScript, in plain words, each with the chapter that teaches it.

A

ACID
The four promises a database transaction makes: all of it happens or none (atomicity), rules still hold (consistency), transactions running at once don't see each other's half-done work (isolation), and committed changes survive a crash (durability). It is why Kettle & Crane can trust an order to be saved completely.
Alert
An automatic message to a person when a metric crosses a set line, such as an error rate above 1% for 5 minutes.
API (Application Programming Interface)
The set of requests a program accepts from other programs, such as the shop's endpoints for products and orders. Apps like the Kettle & Crane website call it instead of touching the database directly.
API key
A secret string a caller sends to prove who it is, usually in a request header.
Asynchronous work
Work done a moment later by something else, so the customer's request doesn't wait for it, like the confirmation email after checkout. Synchronous work is the opposite: the reply waits for it, like saving the order.
At-least-once delivery
A promise most queues make: every message arrives, but some may arrive twice, for instance if a worker crashed before confirming. Consumers must therefore cope with duplicates.
Atomic operation
One step that can't be split, so nothing can happen between the check and the change. A single `UPDATE ... WHERE qty >= ?` checks and subtracts stock at once, so two checkouts can't sell the same last bag.
Authentication
Proving who the caller is, for example with an API key or token.
Authorization
Deciding what a known caller is allowed to do, such as a customer reading only their own orders while staff read everyone's.
Auto-increment ID
A number the database hands out in order (1, 2, 3...) for each new row. The URL shortener turns it into a short code.
Autoscaling
Automatically adding servers when load rises and removing them when it falls, by a rule such as keeping average CPU under 60%.
Availability
The share of time a system answers, written as a percentage such as 99.9%.

B

Back pressure
Pushing back on producers when a queue is full, by making them wait or refusing the message, so the queue doesn't grow until memory runs out.
Back-of-the-envelope estimate
A rough calculation, like one you could do on an envelope, aimed at the order of magnitude rather than an exact number.
Backups
Copies of the data kept elsewhere so it can be restored after a disaster. They should be tested by actually restoring one.
Base62
Writing numbers with 62 symbols (0-9, a-z, A-Z) instead of 10, so a link ID like 125000 becomes the short code `ww8`.
Batching
Grouping many writes into one, such as wrapping 200 inserts in one transaction so the slow commit happens once.
BEGIN / COMMIT / ROLLBACK
SQL commands that control a transaction: `BEGIN` opens it, `COMMIT` saves all its changes, and `ROLLBACK` undoes them all.
Body
The data part of an HTTP request or response, after the headers and a blank line, such as a new order's JSON.
Broker
The program that stores a message queue and hands messages to consumers, such as RabbitMQ or Amazon SQS.

C

Cache
A small, fast store holding copies of data that is slow to get, such as a product page read thousands of times between price changes.
Cache hit / miss
A hit means the data was found in the cache; a miss means it wasn't, so the app fetches it from the slow source.
Cache invalidation
Removing or updating a cached copy when the underlying data changes, for example deleting a product's key right after Jo changes its price.
Cache stampede
What happens when a popular cached entry expires and many requests all miss at once and hit the database together.
Cache-aside
A pattern where the app checks the cache first; on a miss it reads the database and stores the result in the cache for next time.
Cache-Control header
An HTTP header telling browsers and CDNs how long to keep a file; `max-age=86400` means one day. It is a TTL set through HTTP.
CAP theorem
The rule that during a network partition a system must choose between consistency (refuse rather than be wrong) and availability (answer, maybe stale).
CDN (Content Delivery Network)
Servers in many cities that hold copies of files such as product photos, so customers get them from nearby instead of from Portland.
Celebrity problem
A feed problem where one source with a huge number of followers makes fan-out on write slow, because each post needs a write per follower. Hybrid fan-out is the usual fix.
Circuit breaker
A guard that notices repeated failures calling a service and stops calling it for a while. It is closed when calls go through, open when it refuses them, and half-open when it lets a trial call test whether the service recovered.
Client
A client is a program that asks for something (like a browser or `fetch`), and a server is the program that answers.
Clock (injectable / fake clock)
A function that returns the current time, passed in as a parameter. A test can pass a fake clock and move it by hand instead of waiting 60 real seconds.
Component
One part of a system, such as a web server, database, cache or queue.
Consensus
Getting several servers to agree on one value, such as which server is the new primary. It is needed when machines can fail or lose contact with each other but the system must still act as one.
Consistency
Whether all readers see the latest data. Designs choose strong or eventual consistency per feature.
Consistent hashing
A sharding method that moves only a fraction of keys when shards are added or removed. In Kettle & Crane's example, going from four to five shards moves about a fifth of customers, where plain `%` hashing moves nearly 80%.
Cross-shard query
A question that doesn't include the shard key, so it must ask every shard and combine the answers, like "best sellers this week".

D

Dead-letter queue
A side queue where messages go after failing too many times, so a person such as Priya can look at them instead of retrying forever.
Denormalization
Storing a copy of data in the shape a page needs, even though it repeats data held elsewhere, to make reads cheap.
Design document
A short shared description of what you'll build and why, which the team reviews before anyone writes code.
DNS (Domain Name System)
The internet's phone book: it turns a name like shop.kettleandcrane.com into an IP address.
Document store
A NoSQL database that stores JSON-like documents, good for products with varied fields; MongoDB is an example.
Downtime
The time a system is not answering. Each extra "nine" of availability cuts the allowed yearly downtime by ten.
Durability
The promise that saved data is never lost, even after a crash.

E

Edge location
A CDN server in one of many cities that holds copies of files close to customers.
Endpoint
One method and path pair an API accepts, such as `GET /v1/products`.
Eventual consistency
Reads may be briefly out of date, but once writes stop every copy catches up, as with read replicas. It lets any copy answer, so it is faster and more available.
Eviction
Throwing entries out of a full cache to make room for new ones.
EXPLAIN QUERY PLAN
A SQLite command placed before a query to show how it would run, such as `SCAN` (every row) or `SEARCH ... USING INDEX`, without running it.
Exponential backoff
Doubling the wait after each failed retry (0.1 s, 0.2 s, 0.4 s...) to give a struggling server room to recover.

F

Failover
Switching to a standby when the main part fails, such as promoting a read replica to primary.
Fallback
A simpler answer shown when a part fails, such as a cached "Popular this week" list when recommendations are down.
Fan-out
Copying one post or message to many readers.
Fan-out on write / read
Two ways to build feeds. On write, a post is copied into every follower's feed when posted (slow post, fast read); on read, posts are stored once and gathered when a customer opens the feed (cheap post, slow read).
Feed
A list of recent posts from the cafés a customer follows, newest first.
fetch
JavaScript's built-in function for making HTTP requests. `AbortSignal.timeout(ms)` passed to it makes the call give up after that many milliseconds.
Functional requirement
What the system does, such as "customers can check out".

G

Graceful degradation
Offering less instead of nothing when a part fails, such as showing a cached list or letting emails wait on the queue.

H

Hash sharding
Choosing a shard by turning the key into a number with a stable hash and taking the remainder after dividing by the shard count.
Header
A `Name: value` line in an HTTP request or response carrying extra information, such as `Content-Type` (what kind of data the body holds, like `application/json`) or `Idempotency-Key`.
Health check
A regular test, such as `GET /v1/health`, that a load balancer uses to see whether a server is answering. Failing servers are marked down until they pass again.
Hit ratio
Cache hits divided by all lookups; 0.9 means one lookup in ten reaches the database.
Horizontal scaling
Adding more machines that share the work. It has no ceiling, but the data or requests must be split between them.
Hot spot
A shard or key that gets far more traffic than the others, for instance the newest shard under range sharding by date, or one very busy café (a hot key).
HTTP (Hypertext Transfer Protocol)
The plain-text protocol browsers and servers use: a request with a method, path and headers goes out, and a response with a status code comes back.
HTTP method
The verb at the start of a request: `GET` reads, `POST` creates, `PUT` replaces and `DELETE` removes.
HTTPS
HTTP encrypted with TLS, so nobody in between can read things like card numbers or tokens.
Hybrid fan-out
Fan-out on write for ordinary cafés, but fetching a few very popular cafés' posts at read time and merging them in.

I

Idempotency key
A unique ID the client sends with a create request so the server can recognise a retry and return the first result instead of doing it twice, such as charging a card twice.
Idempotent
Doing it twice has the same effect as doing it once. `GET`, `PUT` and `DELETE` are idempotent; a plain `POST` is not.
Idempotent consumer
A queue consumer that handles a message twice with the same effect as once, usually by recording which messages are done and skipping repeats.
Index
A sorted lookup structure on a column that lets the database jump straight to matching rows instead of scanning the table. It slightly slows writes because each insert updates it.
IP address
A number such as 203.0.113.7 that identifies a machine on the network.

J

Jitter
Randomness added to retry waits so thousands of clients don't all retry at the same instant.
JSON
A text format for data (objects, lists, numbers, strings) widely used for API bodies. `JSON.stringify` turns an object into JSON text.

K

Kafka
A popular message broker built around topics, widely used for event streaming. Many services can subscribe to a topic and each gets a copy of its messages.
Key-value store
A NoSQL database holding one value per key, like a `Map`; good for sessions and carts. Redis and DynamoDB are examples.

L

Latency
How long one request takes.
Layer 4 / Layer 7
Two kinds of load balancer. Layer 4 looks only at addresses and ports and passes bytes on unread (very fast); Layer 7 reads the HTTP request, so it can route by path and handle HTTPS.
Least connections
A balancing rule that sends each request to the server with the fewest requests still open, which suits requests of very different cost.
Load balancer
A server in front of the app servers that takes every request and passes it to one of them, so customers only see one address.
Logs
Records of events, such as each failed charge. `console.log` is the simplest form.
LRU (least recently used)
An eviction rule: when the cache is full, throw out the entry that has gone unread the longest.

M

Message queue
A holding place for work: producers put messages on it, and consumers take them off later. It lets checkout reply quickly while emails are sent afterwards.
Metrics
Numbers measured over time, such as latency or the error rate (the share of requests that fail).
Microservices
A style that splits a system into many small programs talking over APIs; the opposite of a monolith.
Monitoring
Watching what a system is doing using logs, metrics and alerts.
Monolith
One program that does everything, as opposed to microservices, which split a system into small programs that talk over APIs. It is simpler to build and run, which suits small teams.

N

Network partition
A network failure in which some servers can't reach others, such as replicas losing contact with the primary.
Nines
A shorthand for availability: 99.9% is "three nines". Each extra nine cuts allowed downtime by ten and costs more.
node:http
Node's built-in module for writing HTTP servers. Its `createServer` function calls your code once per request, with objects for the request and the response.
node:sqlite
Node 22's built-in SQLite module. SQLite is a small relational database, and the module lets JavaScript create tables, run SQL and use transactions without installing anything.
node:test
Node's built-in test runner. `node --test` runs files of `test(...)` checks written with `node:assert/strict`.
Non-functional requirement
How well the system does its job: latency, availability, durability and scalability.
NoSQL
Databases that aren't relational tables, such as key-value or document stores, trading some features for simplicity and very large scale.

O

Object storage
A service that stores any number of files by name, cheaply and durably, such as Amazon S3. The CDN fetches photos from it.
Order of magnitude
The rough size of a number, such as 2, 200 or 20,000 requests a second. Each size needs a very different design.
Outbox
A queue of work (such as emails) to be done only after an order is safely saved.

P

p99
The latency that 99% of requests beat; the slowest 1% take longer. An 80 ms average can hide a p99 of 3 seconds.
Pagination
Returning a long list one piece at a time, with `?page=2` or `?after=K-1040`.
Peak factor
How many times the average load the busiest moment reaches. For the shop's holiday hour it is about 10.
Polling
Asking again and again whether anything is new. It is simple but slow to notice updates and wasteful when nothing changed.
Port
A number that identifies one of the network doors on a machine, so that several programs can listen at once. For example, 443 is used for secure web traffic and 8121 for the shop's example server.
Precompute
Calculating a heavy result ahead of time and storing it so page views read a few rows, such as a best-sellers table refreshed every 10 minutes.
Prepared statement
A SQL statement written once with `?` placeholders and run many times with different values. It is also the safe way to include user input, instead of building SQL by joining strings.
Presence
Whether a person is online. The chat design tracks it with a key that expires if the app stops sending "I'm here".
Primary
The database copy that takes every write and copies changes to the replicas.
Producer / consumer
The producer is the code that puts messages on a queue (checkout); the consumer is the worker that takes them off and does the work.
Pub/sub
Publish/subscribe: a message sent to a topic is delivered as a copy to every subscriber, unlike a queue where one consumer gets it.

R

Race condition
A bug whose result depends on the timing of two overlapping operations, like two checkouts both reading 1 bag in stock and both selling it.
Range sharding
Giving each shard a range of keys, such as a span of dates. It risks a hot spot on the newest shard.
Rate limiting
Capping how many requests each client may make in a given time. It protects a service from being overwhelmed by one caller, such as a script hammering an API, and is usually answered with status 429.
Read replica
A copy of the database that receives the primary's changes and answers reads, so several servers can share the read load.
Read-heavy / write-heavy
A system that reads far more than it changes data (like the shop, about 100 reads per write) is read-heavy; the reverse is write-heavy. The ratio shows which side to scale first.
Read-your-writes
A promise that a user always sees their own latest changes, for example by reading from the primary for a short time after they write.
Redirect
A response that tells the browser to go to another URL, with the new address in a `Location` header. 301 means moved for good (browsers remember it), 302 means moved for now.
Redis
A shared in-memory server used as a cache (Memcached is similar), and also a key-value store.
Redundancy
Having two or more of each critical part so one failure doesn't stop everything.
Relational database
A database of tables with fixed columns, queried with SQL, where tables can be combined in one query (a join). PostgreSQL and MySQL are examples.
Replication
Keeping copies of a database on several servers.
Replication lag
How far a replica is behind the primary; reading just after a write may return the old value.
Requests per second (RPS)
The key load number: how many requests arrive each second. Average RPS is daily requests divided by 86,400.
Requirement
Something the system must do or be, either functional or non-functional.
Resharding
Moving rows to new shards when you add or remove shards. With `% shardCount`, most keys move.
REST
A common API style where URLs name resources (nouns like `orders`) and HTTP methods say what to do with them.
Retry
Trying a failed call again, which helps with brief failures. It is safe only for idempotent work and should use backoff and jitter.
Round robin
Giving requests to servers in turn: app1, app2, app3, then app1 again.
Router
The app-side code that sends writes to the primary database and reads to a replica.

S

Scalability
Keeping working as the load grows.
Scan
The database reads every row of a table to answer a query, which is slow on big tables without an index.
Session
What a server knows about one visitor, such as who is logged in and what's in their cart.
Shard
One piece of a table that has been split across several databases.
Shard key
The column whose value decides which shard a row lives on, such as `customer_id` for orders.
Sharding
Splitting one table's rows across several databases so each holds part of the data. It brings costs like hot keys and cross-shard queries, so shard only when you must.
Short code
The few symbols after the slash in a short link, such as `abc12`.
SKU
Stock-keeping unit: the code identifying a product, such as `MUG-BLUE`.
SLO (service level objective)
A target a team sets for a service, such as "checkout is available 99.9% of the time".
SPOF (single point of failure)
One part whose failure stops everything, such as a single database. Redundancy removes it.
SQL
The language used to ask relational databases questions and change their data, such as `SELECT` and `UPDATE`.
Stable hash
A hash function that gives the same number for the same key on every machine and every run, like Node's built-in `crc32` from `node:zlib`. Sharding needs one so customers don't change shards after a restart.
Stale
Cached or copied data that no longer matches the source of truth.
Stateless server
A server that keeps no session data in its own memory; it lives in a database or cache. Any server can then answer any request, so adding servers is easy.
Status code
The number that starts an HTTP response: 2xx means success, 4xx the client's mistake, 5xx the server's problem. Common codes include 200 OK, 201 Created, 301 moved for good, 302 moved for now, 400 Bad Request, 401 Unauthorized (missing or wrong token), 403 Forbidden (known but not allowed), 404 Not Found, 409 Conflict, 429 Too Many Requests, 500 Internal Server Error and 503 Service Unavailable.
Sticky session
A load balancer sending a customer to the same server every time because that server holds their cart in memory. If it dies, the cart is lost.
Strong consistency
Every read sees the latest write, as when reading from the primary.
System design
Deciding a system's parts and how they talk to each other, before or while building it, often sketched as boxes and arrows on a whiteboard.

T

TCP
The connection protocol that delivers bytes in order and resends lost ones; HTTP runs on top of it.
Timeout
The longest you will wait for a reply to a network call. Without one, a hung server ties up connections until none are left.
Token
A long secret string sent in a header, such as `Authorization: Bearer <token>`, to prove who is calling.
Transaction
A group of changes saved all together or not at all, so an order reserves every product in the cart or none.
TTL (time to live)
How long a cached entry stays valid. After that it expires, so the next lookup misses and fetches a fresh copy.

U

URL shortener
A service that turns long web addresses into short links like `go.kettleandcrane.com/abc12` and redirects visitors to the long URL.

V

Versioning
Putting a version such as `/v1/` in API paths so a `/v2/` can appear while old apps keep working.
Vertical scaling
Moving to a bigger machine. It is simple, but there is a largest machine you can buy.

W

WebSocket
A connection that starts as an HTTP request and then stays open so either side can send messages at any time, as in the support chat.
Weighted round robin
Round robin where bigger servers appear more often in the list and so get more requests.
Worker
A program, here an `async` function with a loop, that takes messages off a queue and does the work, such as sending emails.
Write-through cache
A cache that is written together with the database at the same moment, instead of being invalidated.