One page per lesson: the takeaways, key ideas and pitfalls. Print or save as PDF.
What Makes an Agent
From one model call to a system that decides for itself what to do next.
Takeaways
One model call turns text into text, so it cannot fetch fresh data or act. A workflow adds tools, but your code fixes the path. An agent is a model that chooses the next step in a loop, using tools, towards a goal, with a stopping rule.
More autonomy gives flexibility and costs calls, time and predictability. Use the lowest level that does the job. Next, see how a model actually asks for a tool in Tools & Function Calling.
Key ideas
A workflow is a recipe. Whoever wrote it chose every step in advance.
No stopping rule means no agent, only a loop that runs until the money runs out.
Test: could you draw the flowchart in advance? If yes, build the flowchart.
Watch out
A fluent answer is not a checked answer. Without data it can only guess.
When the right next step depends on what was just found, a fixed path fails.
A loop with no step limit can spin forever. Always cap the number of turns.
You should be able to
Say why one model call cannot finish a task that needs fresh data and actions
Tell a fixed workflow from an agent by who chooses the next step
Name the parts of an agent: model, tools, loop, goal and stopping rule
Decide when an agent is the wrong choice
Tools & Function Calling
How a model asks your code to act, and what comes back.
Takeaways
A tool is a name, a description and typed parameters. The model only requests a call. Your code validates it, runs it and returns the result, errors included.
Write descriptions like prompts, keep the tool set small and distinct, run independent calls together and limit tools that can do harm. How these calls repeat until a task is done is the subject of The Agent Loop.
Key ideas
Everything a tool does happens in your code, so that is where you can check and limit it.
Make error messages specific enough to act on. "Failed" teaches nothing, "must be 4 digits" does.
Watch out
A wrong tool choice often looks like a model mistake when it is really a description mistake.
Arguments from a model are untrusted input, exactly like text typed by a stranger.
A model can be fooled by text in a web page or email. Never let a single call do unchecked damage.
You should be able to
Explain that the model only requests a tool call and your code runs it
Write a tool description that steers the model to the right tool
Validate arguments and return errors the model can recover from
Weigh the power of a tool against its risk
The Agent Loop
Observe, think, act, repeat: how an agent works through a goal one step at a time, and how to make sure it stops.
Takeaways
An agent is a model inside a loop: observe the transcript, think, act with a tool, add the result, repeat. The transcript is the only state, and it is re-read every turn.
Left alone, loops can run forever, repeat a failing call or drift. The agent program adds a step budget, loop detection, a clear definition of done and honest error messages. To see what happens when the transcript outgrows the model's window, continue to Context & Memory.
Key ideas
The model never runs anything. It proposes an action; the agent carries it out.
If something is not in the transcript, the agent does not know it.
Drift is hard to spot because each individual step looks fine.
Total reading is 500 per turn plus 200 for each earlier step, summed over all turns.
Watch out
A loop with only one exit, the model's own decision, has no safety net.
Retrying without new information is not persistence. It is a loop within the loop.
You should be able to
Describe one turn of the loop: observe, think, act
Explain why the transcript is the agent's only working state
Name three ways a loop goes wrong and the fix for each
Context & Memory
The model sees only its context window each turn, so an agent must decide what to keep, shrink, store and forget.
Takeaways
The model sees only its window. A loop fills it, and at the limit truncation silently drops the oldest text, often the goal. Summaries, a scratchpad and an external store each keep the window small in a different way.
Save facts, preferences and decisions, never secrets. Date and expire notes so stale ones do not mislead. The planning lesson next builds on this: an agent that plans needs a place to keep its plan.
Key ideas
Summarising is itself a model call, so it costs tokens and time too.
The window is a desk; the store is a filing cabinet. Only what you pull out is on the desk.
Every memory scheme trades window space against the chance of missing something.
Watch out
Cost and speed also rise with window size, long before the limit is reached.
The failure is silent: no error appears, the agent just behaves as if it never heard the goal.
Never write passwords or payment details into memory. Notes are read back into prompts.
A wrong memory is worse than none: the agent trusts it without checking.
You should be able to
Explain the context window and why an agent run fills it
Planning & Task Decomposition
Break a big goal into ordered sub-tasks, each with a check, so an agent can finish it instead of wandering.
Takeaways
Without a plan, an agent that chooses one step at a time repeats work, forgets the goal and cannot measure progress. With a plan, the goal becomes an ordered list of sub-tasks, each with a check and a place in the dependency order, and independent ones can run in parallel.
Verify each result before moving on, replan when a step fails or new facts appear, and keep the plan as a visible, editable list. The cost is tokens and the risk of a confident wrong plan, so scale planning to the task.
Key ideas
More steps do not mean more progress. Without a plan the agent has no way to measure either.
A plan is a small dependency graph: what can start now, and what must wait.
Plan as much as the task's risk and size deserve, and no more.
Watch out
Local sense, no global view: each step is fine, the path is not.
A result that looks plausible is not a result that is correct. Check against something independent.
You should be able to
Explain why a big goal overwhelms an agent that decides one step at a time
Decompose a goal into ordered sub-tasks that each have a check
Spot dependencies and run independent sub-tasks in parallel
Retrieval for Agents
Let the agent look facts up in your documents, as a tool, instead of guessing from memory.
Takeaways
A model guesses when it lacks facts, because its knowledge is frozen and does not include your private documents. Retrieval fixes that: chunk documents, embed the chunks, store them in a vector index, embed the question, fetch the top-k chunks and put them in the prompt.
For an agent, retrieval is a tool it can call, rewrite and repeat. Watch for bad chunk sizes, silent misses and stale indexes, and use better chunking, hybrid search, citations and "not found". The price is latency, upkeep and context tokens.
Key ideas
Retrieval-augmented generation: look up first, then generate from what was found.
Citations make errors visible. "Not found" makes misses harmless.
Retrieve when the knowledge is large, private or changing. Otherwise keep it simple.
Watch out
Fluent is not the same as grounded. A wrong answer sounds just like a right one.
A retrieval miss does not announce itself. The model answers anyway.
Grounded does not mean current. Re-index when documents change.
You should be able to
Explain why a model guesses when it lacks your facts
Describe chunking, embeddings, a vector index and top-k retrieval
Workflows vs Agents
Fixed paths, routers and loops: when a script around a model beats a free-running agent.
Takeaways
Start with one prompt. If it is overloaded, add routing. If a result needs checking, chain steps with gates. Use parallel calls for independent pieces and a capped critic loop for hard-to-check writing.
Reach for a full agent last, for open-ended tasks where the steps are not known in advance. Each rung buys flexibility and costs predictability, so stop at the first rung that works.
Key ideas
Routing works when inputs fall into a few distinct kinds that need different handling.
An agent is a workflow whose path is chosen at run time by the model.
Rule of thumb: use an agent when the steps cannot be known in advance and a wrong turn is cheap to undo.
Watch out
A prompt that must handle every case becomes hard to change and hard to test.
Every round is a full extra pair of calls. Set a maximum before the first run.
If you cannot list the steps ahead of time, a pipeline of fixed steps will guess them.
You should be able to
Tell a workflow (code picks the path) from an agent (the model picks it)
Choose between routing, chaining, parallel calls and an evaluator loop
Spot the task that a fixed path cannot handle
Multi-Agent Systems
Splitting a big job across specialist agents, and the price of coordinating them.
Takeaways
Split a job across agents when it divides cleanly: an orchestrator hands sub-tasks to workers with their own contexts, or a hand-off passes the conversation to a specialist. Return summaries, not everything that was read.
Expect extra tokens, latency and new failures: lost context, disagreement, error cascades and endless delegation. Counter them with contracts for every hand-off, a single owner of the final answer, and limits on depth and budget. When in doubt, use one agent.
Key ideas
Split along lines where the sub-tasks barely depend on each other.
The hand-off note is the agent's whole memory of what came before.
Hard limits are cheap insurance. Pick them before the first run, not after the first bill.
Start with one agent. Add a second only when you can name the exact problem it solves.
Watch out
A context full of other tasks' details is a distraction, not an asset.
Tokens are money and latency. Count them before adding an agent.
Each extra agent is another place where a vague message can become a wrong fact.
You should be able to
Explain why a team of agents can beat one overloaded agent
Connecting Tools: Protocols & Servers
A shared protocol lets any agent use any tool, turning N x M hand-built connectors into N + M.
Takeaways
Hand-built connectors cost N x M and break in many places at once. A shared protocol with a client in each app and a server for each tool costs N + M: 3 + 4 = 7 instead of 12, and a fifth tool is one new server.
Servers announce their tools, resources and prompts through discovery, run locally or remotely, and should act with the user's scoped identity. What they send back is untrusted: allow-list them, pin versions, limit permissions and gate risky actions.
Key ideas
Many-to-many becomes many-to-one-to-many. Cost grows by adding, not multiplying.
Local is simple and private. Remote is shared and central, and brings network concerns.
More servers means more capability and more to trust. Count both.
Watch out
Each new app or tool multiplies the work instead of adding to it.
A change in one tool becomes M separate repairs, one per app.
The model never holds the secret; the client attaches the token. Scope it to the least needed.
Installing a server is closer to installing code than to adding a harmless plug-in.
You should be able to
Explain why N x M connectors do not scale and how N + M fixes it
Evaluating Agents
Measure an agent with realistic tasks, graders and repeated runs, because its path and wording change every time.
Takeaways
Exact-match unit tests fail on free text and varying paths, and a few examples can mislead: 3 of 3 passed while 40 tasks showed 60% against 72%. Use realistic tasks with known good results, and measure outcome, trajectory, cost and time.
Choose graders deliberately: code checks where possible, a calibrated judge for meaning, people for the hard cases. Run each task several times and report a rate, gate every prompt or model change with a regression suite, and read traces to find the first wrong step.
Key ideas
A pass rate alone hides waste. Report outcome, steps, cost and time together.
Say "passes 7 of 10", never just "passes".
Later errors often just inherit an earlier one. Fix upstream.
Watch out
Keep unit tests for the plain code around the agent. They cannot judge the agent's wording or path.
A few examples can only reassure you. A bigger set can overrule you.
Treat a judge as an instrument that needs calibrating against people.
Agreement with itself is not accuracy. Spot-check the judge against people, for example 20 cases.
You should be able to
Explain why exact-match unit tests fail for agents
Safety, Permissions & Oversight
An agent acts with real credentials, so limit what it can touch, distrust what it reads, and put a person in front of the irreversible.
Takeaways
An agent acts with real credentials, so safety is about limiting damage when something goes wrong. Give tools the least access they need, treat everything the agent reads as untrusted, and never let one agent hold private data, untrusted input and a way out together.
Enforce rules in code, sandbox generated code, and ask a human before irreversible steps, gated by risk so approvals stay meaningful. Keep an audit log. Next: measure these defences with evals, and see Cost, Latency and Reliability for the price of every extra check.
Key ideas
Treat an agent like a new employee with your login: decide what it may touch before it starts.
Defences must live outside the model: in permissions, code and people.
Prompts shape behaviour. Code enforces limits.
Watch out
"It will not do that" is a hope, not a control. Assume some calls will be wrong.
Direct injection comes from the user's own message. Indirect injection hides in content someone else controls.
Every approval costs time and attention. Spend them only where a wrong call hurts.
You should be able to
Cost, Latency & Reliability
Every loop step re-sends a growing context, adds waiting time and can fail, so a long agent run gets expensive, slow and shaky unless you design for it.
Takeaways
Each loop step re-sends a growing context, so input tokens grow roughly with the square of the steps. Latency adds per step, and per-step success compounds: 0.95 over 10 steps is about 60%.
Fewer steps, trimmed context, a cached prefix, right-sized models and parallel calls cut cost and time. Budgets and timeouts cap the worst case, safe retries and a graceful "could not finish" handle failure, and evals tell you what each saving cost in quality. Pair this with Safety, Permissions & Oversight: every check adds a little latency.
Key ideas
Measure a whole run, not one step. Steps multiply every cost.
Budgets cap the worst case. Without them, one bad run can cost more than a thousand good ones.
Watch out
Output tokens grow linearly. The quadratic part is the re-sent input.
A 95% step is a 60% run at ten steps. Reliability has to be designed in.
A changing line near the top of the prompt breaks the cache for everything after it.
Retry without idempotency on a write is how a customer gets charged twice.
You should be able to
Estimate input tokens and wait time for a multi-step run
What Is Machine Learning
Learning rules from examples instead of writing them by hand, and knowing when that is the wrong tool.
Takeaways
Hand-written rules break when the world changes. Machine learning instead takes examples (features plus a label), runs a trainer that searches for the settings that fit those examples, and outputs a model.
Training is expensive and occasional; inference on new input is cheap and constant. Models are sometimes wrong, so they must be checked on examples they never trained on. That is where the next lesson, Data, Features & Splits, begins.
Key ideas
Machine learning swaps the question: not "what are the rules?" but "where are the examples?"
Training is a search: try settings, score them against the known answers, keep the best.
A model trades certainty for flexibility. That is a good deal only when mistakes are affordable.
Watch out
Catching 40 of 100 spam while blocking 10 real emails is a poor trade, and it gets worse as spammers adapt.
"Can we use ML?" is the wrong first question. Ask whether a simple rule already works.
You should be able to
Explain why hand-written rules break as the world changes
Define example, feature, label and model
Data, Features & Splits
What a model is fed, how to cut it up fairly, and the leak that fakes success.
Takeaways
A dataset is rows (examples), feature columns and a label. Clean it, check it matches the real world, and put features on comparable scales when the model needs it.
Split into train, validation and test before anything else, and open the test set once. Watch for leaks: features that hold the answer, steps fitted on test rows, and shuffled time. Next, Linear Regression builds a first real model on tables like this, and Overfitting & Regularisation shows what the validation set is really catching.
Key ideas
Clean the data, then ask: does this sample look like the future?
The test set should rehearse the real future, nothing less.
Watch out
Garbage in, garbage out: a model can only be as good as the table it studied.
Units are arbitrary. Measuring spend in cents instead of dollars would make the dominance far worse.
A test score you have tuned against is no longer a test score.
A result that looks too good to be true: suspect a leak before celebrating.
You should be able to
Describe a dataset as rows, features and a label
Explain why features need a common scale
Say what train, validation and test sets are each for
Fitting a Line
Predicting a number from examples: a line with two knobs, an error for every miss, and the best fit as the lowest loss.
Takeaways
Regression predicts a number. A line price = w x size + b has two knobs. The error of each example is real - predicted, and the mean squared error rolls all errors into one loss. The best line is the one with the lowest loss.
In our example line A scored 5,375, line B 1,625 and line C (w = 2.5, b = 20) just 25. Outliers can drag the fit, a line cannot follow a curve, and it cannot be trusted far outside the data it saw.
Next: Gradient Descent explains how a computer searches for low-loss settings when no formula exists, and Overfitting & Regularisation shows what happens when a model is too flexible instead.
Key ideas
The model is just two numbers. Everything it knows about houses lives in w and b.
The loss turns "how good is this line?" into a number a computer can compare and improve.
Squaring makes one big miss hurt more than several small ones. Remember this when outliers show up.
A line is a strong first baseline. Fit it first, then ask what it misses.
Watch out
"Looks close" is not a measurement. We need a number that says how wrong a line is.
Look at unusual points first: is it a data error, or a different kind of house the line should not cover?
Gradient Descent
Finding good settings by walking downhill one small step at a time, and what the step size does to the walk.
Takeaways
The loss is a landscape and the model's settings are a position. The slope says which way is up, and gradient descent moves against it by learning rate x slope, again and again.
On our bowl with rate 0.25, w went 0, 1.5, 2.25, 2.625, 2.8125 toward 3 while the loss fell 9, 2.25, 0.56, 0.14, 0.035. A rate of 0.01 crawled and 1.1 diverged. Mini-batches make steps cheap but noisy, and stopping rules decide when to quit.
Next: Classification trains the same way, with a loss designed for predicting categories instead of numbers.
Key ideas
The slope is all we need: it says which way is down. We never have to see the whole landscape.
The wobble is noise around the true slope. Over many steps the trend still goes downhill.
Different starting points can end in different dips, so two training runs can give different models.
One general method, bought with tuning, many steps and no guarantee of the best answer.
Watch out
Checking every combination grows exponentially with the number of knobs.
Too small is safe but slow: you may run out of budget before the loss gets low.
A loss that goes up instead of down is the classic sign of a learning rate that is too big.
Classification
How a model turns evidence into a category: a score, a probability, a boundary and a threshold you choose on purpose.
Takeaways
A classifier computes a weighted score, squashes it into a probability, and a threshold turns that probability into a category. The boundary is the line where the probability reaches that threshold.
Choose the threshold from the cost of each kind of mistake, not by habit. Be suspicious of accuracy when one class is rare. If the classes are not separable by a straight cut, engineer features or move to a more flexible model, such as Decision Trees & Ensembles.
Key ideas
The model now says how confident it is, not just which way it leans.
Training produces probabilities. The threshold is a business decision layered on top.
Better features can make a simple model strong. A flexible model is not always the first answer.
Watch out
A line has no ceiling. Labels do: nothing is more spam than spam.
Counting total errors hides this. 8 wrong out of 100 says nothing about which way they went.
Always compare against the lazy baseline: always guess the common class.
You should be able to
Explain why a straight line fitted to 0/1 labels gives awkward answers
Decision Trees & Ensembles
A tree learns a flowchart of yes/no questions from data, and a crowd of trees is steadier than any single one.
Takeaways
A tree is a flowchart of yes/no questions, chosen greedily to make groups purer. Depth must be limited, or it memorises. One tree is unstable, so we train many on random rows and columns and let them vote (forest), or chain them so each fixes the last (boosting).
Pick a single shallow tree when you must explain each decision. Pick a forest or boosted trees when accuracy on tabular data matters more, and remember they cannot extrapolate. Next, see Overfitting & Regularisation for the general fight against memorising.
Key ideas
The path is the explanation: income above 40k and no missed payment, so approve.
A tree is built greedily: the best question for each group now, never a plan for the whole tree.
Voting reduces variance. It cannot fix a bias that every tree shares.
Watch out
Training accuracy only ever rises with depth. The test line is the one to watch.
High variance: the tree depends heavily on exactly which rows it saw.
Do not use a forest to predict beyond the range of its training data.
You should be able to
Explain how a tree picks its next question by comparing how pure the groups become
Overfitting & Regularisation
A model can score perfectly on the examples it trained on and badly on new ones, because it memorised the noise.
Takeaways
Training error measures memory. New-data error measures learning. Underfit: both errors high. Overfit: training error low, new-data error high. The size of that gap tells you which problem you have.
Fix overfitting with more data, a simpler model, a penalty on large weights, or early stopping. Choose settings on validation error or cross-validation, and open the sealed test set once, at the end. See Measuring Success for which numbers to compare.
Key ideas
A model is only useful on data it has not seen. Training error cannot tell you that.
The penalty does not ban wiggles. It makes them cost more than they are worth.
Underfit means high bias. Overfit means high variance. The goal is the lowest total.
Watch out
Underfitting shows up as high error on both the training data and new data.
Zero training error from a flexible model on little data is a warning sign, not a trophy.
Never tune on the test set. Once you do, it is just another validation set.
You should be able to
Tell underfitting from overfitting by comparing training and new-data error
Work out how a penalty on large weights changes which fit wins
Measuring Success
Why 99% accuracy can be useless, and which numbers to look at instead.
Takeaways
Accuracy is fine when classes are balanced and mistakes cost the same, but it lies when one outcome is rare. Use the confusion matrix, then precision, recall and F1. Set the threshold by the cost of a miss against a false alarm, and compare everything with a simple baseline.
Measure on data the model has not seen, use cross-validation when data is small, and look beyond one number to groups and examples. Together these tell you whether a model is truly useful, not just whether it scores well.
Key ideas
Every metric in this lesson is just arithmetic on these four counts.
One model has a different precision and recall at every threshold.
A score only means something next to a baseline. The always-fine model in step 2 was one.
Report a few numbers and a few examples, not one headline figure.
Watch out
Always ask what the dumbest possible model would score. If it scores nearly the same, the metric tells you little.
A metric quoted without its threshold can be made to look however you like.
If a result looks great, first check the model never saw those test examples in training.
You should be able to
Explain why accuracy misleads when one outcome is rare
Clustering & Unsupervised Learning
Finding groups, outliers and structure in data that nobody labelled, and why a person must judge the result.
Takeaways
Unsupervised learning looks for structure in unlabelled data: groups, odd points out, and fewer columns. K-means picks k centres, assigns each point to its nearest one, moves each centre to its group's mean, and repeats until nothing changes.
Rescale columns first, try several starts, and use the elbow as a hint for k. Then ask a person whether the groups are meaningful. For the next lesson on judging models, see Evaluation Metrics.
Key ideas
The goal changes from "predict the answer" to "describe the shape of the data".
Both moves reduce the spread or leave it alone. That is why k-means always settles.
Anomaly detection here means "unlike everything we have seen", not "proven fraud".
Watch out
You must choose k yourself. The method does not discover it.
Rescale columns before clustering, or the largest-valued column quietly decides everything.
A neat-looking cluster is not proof that it is real. Test it against how the business actually works.
You should be able to
Say what can be learned from data with no labels
Run k-means by hand: assign to the nearest centre, move to the mean, repeat
Neural Networks
Why one straight line is not enough, and how stacked layers of simple units learn their own features.
Takeaways
A neuron is a weighted sum, a bias and a bend. Layers of them build their own features, so a network can draw curved and banded boundaries where a line cannot. Training measures the loss, sends blame back through the layers, and nudges every weight a little, again and again.
Size brings power and cost: lots of data and compute, a risk of overfitting, and little transparency. Next, see Embeddings, where networks learn numbers that capture meaning.
Key ideas
Weights and biases are the numbers a network learns. The activation is chosen by the designer.
A forward pass is only multiplication, addition and the bend, repeated layer by layer.
More parameters give more capacity, and also more to fit wrongly. See Overfitting & Regularisation.
Watch out
More data will not fix a model that cannot draw the right shape.
The learning rate matters. Too large and the loss bounces around, too small and training crawls.
Always evaluate on data the network never trained on.
You should be able to
Explain why a single straight line cannot separate some data
Compute a neuron and a small forward pass by hand
Embeddings & Similarity
Turning words, images and users into points where distance means similarity, and how to search millions of them fast.
Takeaways
IDs and one-hot codes carry no meaning. An embedding is a learned list of numbers per item, trained so that items used in similar contexts end up close. Distance and cosine similarity measure that closeness.
Search embeds the query and returns the nearest vectors. At scale an approximate index trades a little recall for a large speed-up. Watch for bias, multi-meaning words, out-of-domain queries and model changes, which force a re-index. Next topic of interest: Retrieval for Agents.
Key ideas
The same trick works for images, songs, products and users, not only words.
Directions can carry meaning too. The step from "kitten" to "cat" often points roughly the same way as from "puppy" to "dog".
Watch out
With one-hot codes, "cat" is exactly as unrelated to "kitten" as it is to "tax".
Figures here are illustrative; real speed depends on hardware, but the cost grows in proportion to the collection.
Store the embedding model's name and version beside every vector, and test search quality on real queries.
You should be able to
Explain why bare IDs and one-hot codes carry no meaning
How Language Models Are Trained
From predicting the next token on huge amounts of text to a model that follows instructions, and where its limits come from.
Takeaways
Text is split into tokens. The model outputs odds for the next token. Pretraining on huge text teaches grammar, facts and patterns as a side effect. Fine-tuning on instructions and preference tuning turn a text continuer into an assistant.
At use time it samples one token at a time, shaped by temperature. It predicts plausible text, not verified truth, its knowledge stops at a cutoff, and its context window is finite. Related: Neural Networks for the model inside, Context & Memory for the window.
Key ideas
Output is a probability for every possible next token, not a single answer.
Preferences reflect the raters' instructions and judgement, so they can also teach flattery or hide gaps.
Watch out
Learning to predict plausible text is not the same as learning what is true. We come back to that.
Usable behaviour, answering, following instructions and refusing harmful requests, has to be added after pretraining.
Treat answers as drafts to check when the facts matter, and give the model the documents it needs.
You should be able to
How Networks Work
Data crosses a network as small packets wrapped in layers and passed hop by hop, and its speed depends on both latency and bandwidth.
Takeaways
Networks cut data into packets so many senders share a link and a loss costs little. Each packet is a header plus a payload, wrapped by the link, network, transport and application layers. Routers forward packet by packet, and may drop one when their queue is full.
Time on a network is latency plus size / bandwidth. Distance sets latency, links set bandwidth, and small transfers care mostly about latency. Next: Local Networks, on how packets cross the very first hop.
Key ideas
Packets let many conversations share one link, and make a loss cheap to repair.
Layering lets each part change on its own: Wi-Fi can replace Ethernet without the browser noticing.
Bandwidth is how much fits per second. Latency is how long one bit takes. They are different things.
Watch out
Sending whole files as single blocks makes small, urgent messages wait for big ones.
The bigger the unit you send, the more you lose when something goes wrong.
A dropped packet is normal network behaviour, not a failure of the whole network.
Sending lots of tiny packets wastes most of the link on headers.
You should be able to
Local Networks: Ethernet, Wi-Fi & ARP
Devices in one place find each other by hardware address, and a switch, ARP and shared radio each decide how well that works.
Takeaways
A hub shares one wire and everyone hears everything. A switch learns MAC addresses per port, forwards to the right port and floods only what it must. ARP asks "who has this IP?" by broadcast, caches the answer briefly and trusts whoever replies, so it can be stale or spoofed.
Wi-Fi shares airtime among all devices on a channel, so distance, walls and crowds cost speed. Wired switches and wired access points scale better, and Wi-Fi gives convenience. A switch costs more than a hub did, and is worth it. Next: IP, how packets cross between networks.
Key ideas
Nobody configures the MAC table. The switch learns it by watching who sends from which port.
ARP is the glue between the network layer (IP) and the link layer (MAC).
Watch out
On a hub, every device hears every conversation. Privacy rests on devices behaving politely.
Collisions waste time, and the more devices share a hub, the more often they happen.
ARP and switches assume everyone on the local network is honest. That is not always true.
Distance and walls lower speed, and every device on the channel pays for the slowest one.
You should be able to
IP Addresses & Routing
Subnets, gateways and routers: how a packet finds its way between networks.
Takeaways
The prefix splits an address into network and host. Same subnet: ARP and send directly. Different subnet: send to the default gateway. Routers pick the matching route with the longest prefix, and 0.0.0.0/0 catches the rest.
TTL (Hop Limit in IPv6) ends loops and powers traceroute. Private ranges plus NAT stretch IPv4, and IPv6 removes the shortage. When neighbours work but the internet does not, check the mask and gateway first. IP only delivers on a best-effort basis; TCP: Reliable Delivery builds dependability on top.
Key ideas
Dots are for humans. Routers compare the raw 32 bits.
The default route has prefix length 0, so it always matches and is always the last choice.
TTL does not fix the bad route. It limits the damage and makes the problem visible.
IPv6 changes the address size, not the way routers choose.
Watch out
A loop does not look like an error. The packet just never arrives.
NAT hides hosts only as a side effect and is not a firewall. See Firewalls & VPNs.
You should be able to
Split an address into network and host with a prefix, and size a subnet
Decide whether two hosts are on the same subnet using the mask
TCP: Reliable Delivery
Ports, the three-way handshake, sequence numbers and retransmission: how TCP turns lossy packets into a dependable stream.
Takeaways
Ports pick the program. A three-way handshake sets up state, at the price of one round trip. Sequence numbers count bytes and ACKs report the next byte expected, so the receiver can reorder, drop duplicates and spot gaps.
A missing segment is resent after a timeout or three duplicate ACKs, and the stream closes with FINs. The price is startup delay, head-of-line blocking and per-connection state. How much TCP may send at once is covered in Congestion Control, and the alternative in UDP & QUIC.
Key ideas
Latency, not bandwidth, sets this cost. A faster link does not shorten a round trip to a far-away server.
Reliability here means: keep a copy, watch for the ACK, and resend until it arrives.
TCP spends time and memory to give the app a guarantee. Whether that is worth it depends on the app.
Watch out
None of this raises an error. Packets just go missing, double up or arrive out of order.
ACKs only move forward when the oldest missing byte shows up.
You should be able to
Name what ports and the handshake do, and what the handshake costs in time
Read sequence numbers and ACKs to see which bytes have arrived
Congestion & Flow Control
A sender must respect two limits, the receiver's buffer and the network's capacity, and it has to discover the second one by trial and error.
Takeaways
The receiver advertises a window to protect its own buffer (flow control). The sender keeps a congestion window to protect the path (congestion control). In flight is never more than the smaller of the two.
Slow start doubles the window each round trip from 10 segments. Loss makes the sender halve it, then grow by about one segment per round trip. Throughput is roughly window / RTT, so fast, long links need big windows. Giant buffers hide congestion and add delay, which small buffers, early drops and delay-aware algorithms such as BBR address.
Key ideas
The window is advertised by the receiver in every acknowledgement, so it tracks the buffer as it fills and drains.
Slow growth and sharp cuts are what let many senders share a link without wrecking it.
Loss-based senders fill whatever buffer exists. Fixes either shrink the buffer or make the sender stop relying on loss.
Watch out
Flow control cannot see the network. Without a second limit, a receiver with lots of room invites the sender to flood the path.
Loss is the only message the network sends here, so the sender must treat it as 'slow down'.
Good throughput does not mean good latency. A queue that is always full adds delay without adding speed.
UDP & QUIC
UDP gives up TCP's guarantees to stay fast and simple, and QUIC rebuilds the useful ones on top of it with fewer round trips.
Takeaways
UDP has ports and a checksum in an 8-byte header and nothing more, so the application decides what loss means. It suits DNS, live calls, games and telemetry, where late data is useless or one question and one answer are enough.
QUIC builds reliable streams, congestion control and TLS 1.3 on UDP. It needs 1 round trip to set up (against about 3 for TCP with TLS 1.2), avoids head-of-line blocking across streams and survives network changes through connection IDs. The costs are UDP being blocked on some networks, extra CPU and less visibility for middleboxes.
Key ideas
Ask whether late data is still useful. If not, do not pay for guaranteed delivery.
Independence is the key: order within a stream, no order between streams.
Watch out
For live media, a late packet is as useless as a lost one. Waiting for it only delays everything behind it.
UDP gives freedom, not safety. Every guarantee you skip becomes your own code to write.
0-RTT trades safety for speed. Do not use it for actions like payments.
In-order delivery is a promise about the whole stream, so one gap blocks every resource behind it.
You should be able to
DNS: Names to Addresses
The hierarchy, the caches and the delays behind every lookup.
Takeaways
A device asks a recursive resolver, which walks root, TLD and authoritative servers on a cold lookup (about 102 ms in our example) and answers from its cache afterwards (about 2 ms). Records come in types: A, AAAA, CNAME, MX, NS and TXT. The TTL says how long an answer may be reused.
Stale answers after a move are fixed by lowering the TTL ahead of time. A resolver outage is softened by a second resolver and monitoring. Short TTLs cost extra queries, and plain DNS is unauthenticated unless DNSSEC and encrypted DNS are used. Once the address is known, the browser speaks HTTP to it.
Key ideas
Each level only knows who to ask next. The last level knows the answer.
Caches turn a 102 ms walk into a 2 ms answer and take load off the servers at the top.
Watch out
A cold lookup is slow. If every page view paid it, the web would feel sluggish.
If the old server is switched off straight away, users behind stale caches get errors until their cache expires.
Choose the TTL per record: short while a change is planned, long when things are stable.
You should be able to
Walk a lookup through the root, TLD and authoritative servers
HTTP/1.1, HTTP/2 and HTTP/3
How the web protocol changed to load pages faster.
Takeaways
HTTP/1.1 handles one exchange per connection, so browsers open about six: 720 ms on one connection becomes 220 ms on six, in our example. HTTP/2 multiplexes 12 streams over one connection (170 ms) and compresses headers, but one lost TCP packet stalls every stream. HTTP/3 runs over QUIC so only the affected stream waits, and it needs one round trip to start instead of two.
Methods, status codes and headers stay the same, so servers and sites mostly carry on unchanged. Browsers learn about HTTP/3 through Alt-Svc and fall back to HTTP/2 when UDP fails. The gains are largest on high-latency and lossy links. Next, TLS and HTTPS explains the encryption these versions rely on.
Key ideas
Keep-alive saves reconnecting. It does not let one connection do two things at once.
The fix is not less reliability but reliability per stream.
New versions change the transport underneath. Your application still sees methods, codes and headers.
Watch out
The link is idle most of the time: the cost is round trips, not bandwidth.
Six connections is a workaround, and it still blocks: one slow response ties up a whole connection.
TLS & HTTPS
TLS gives a web connection privacy, tamper detection and proof of who is on the other end, at the cost of one extra round trip.
Takeaways
Back in the coffee shop, the snooper still sits on the Wi-Fi and still captures every packet, but now only scrambled bytes. A changed packet fails its integrity check, and a fake certificate fails the chain check. Meanwhile one extra round trip bought all three guarantees.
Remember the order of the story: a key agreement using public-key maths, a certificate that links the name to a key, and fast shared-key encryption for the data. Then keep the practical habits: renew certificates automatically, watch expiry dates, send the full chain, and set HSTS.
Key ideas
Encryption alone is not enough. Without authentication you could be sending secrets, perfectly encrypted, to the attacker.
Before the certificate is checked, the client cannot know who it is talking to. The handshake proves identity, then keys protect the data.
Round trips are the real cost. A server farther away makes every extra handshake step hurt more.
Watch out
Plain HTTP fails twice at once: it leaks what you send and accepts whatever arrives.
Clicking through that warning throws away the authentication promise. The padlock then protects you from nobody.
Test from a clean client with no cached certificates. Your own browser can hide a broken chain.
Proxies & Load Balancers
A proxy forwards traffic for someone else; placed in front of servers it can spread load, hide backends and speed up connections, if you keep the client's address.
Takeaways
A proxy forwards for someone else. A forward proxy represents clients, a reverse proxy represents servers, and a load balancer is a reverse proxy that picks among backends: round robin, least connections or hashing. Layer 4 passes connections quickly, layer 7 reads requests and can route by path, host or cookie.
Health checks skip a dead backend, warm connections save handshakes, and X-Forwarded-For carries the real client address if you trust only your own proxy. Run the proxy as a pair, because it is now the front door. Next: Firewalls & VPNs, which decide who may come in at all.
Key ideas
Same mechanism, opposite side. Forward: hides clients from servers. Reverse: hides servers from clients.
Choose layer 4 when you only need to spread connections. Choose layer 7 when the decision depends on what the request says.
Redundancy moves the single point of failure up a level, it does not remove it. Keep the pair on separate hardware and test the takeover.
Watch out
A saturated server fails slowly: it answers late first, then not at all.
A server can pass the check and still be slow. Set a request timeout as well, so one slow backend cannot hold connections forever.
Firewalls, NAT & VPNs
Filtering, hiding and tunnelling traffic, and the mistakes that open holes.
Takeaways
A packet filter applies an ordered rule list with default deny. A stateful firewall remembers outbound connections so replies are admitted without opening high ports. A DMZ keeps public servers apart from the data, and egress rules stop what leaves as well as what arrives.
NAT shares one public address by rewriting source addresses and ports, and hides inside hosts as a side effect only. A VPN encapsulates packets in encrypted ones, and its overhead means the tunnel MTU must sit below the link MTU. Next, see how the rest of the toolbox finds faults in Troubleshooting Networks.
Key ideas
Outbound by policy, replies by state, new inbound connections only by explicit rule.
The tunnel hides the contents and the inner addresses from the network in between, not from the two ends.
A VPN decides who can reach the network. Each service must still decide who it will serve.
Watch out
Databases, admin panels and remote desktops should almost never be reachable from the open internet.
Allow-any outbound is the most common forgotten rule. Check both directions.
NAT hides addresses. It does not authenticate or filter anything, so do not count it as a security control.
You should be able to
Troubleshooting Networks
A layer-by-layer method and the tools that find where a connection breaks.
Takeaways
Turn "the site is down" into a place. Check the link and the IP address, ping the gateway and then an outside address, ask dig for the name, probe the port with nc, and read the exchange with curl -v. Use traceroute to find where delay appears, ss to see what listens, and a capture when the tools disagree.
Refused means something answered and nothing listens; a timeout means silence in the path. Change one thing at a time, write it down and check from both ends. For how the firewall rules behind a timeout are built, see Firewalls, NAT & VPNs.
Key ideas
Read traceroute as a list of where time is added, not as a list of broken routers.
Refused is good news about the path. A timeout says to look at the network in between.
Any HTTP status, even an error, proves the path works. Stop blaming the network once you hold one.
Each case ended in a different layer, and each test ruled the layers below it in or out.
Watch out
If you changed three things and it works, you do not know which one mattered.
No ping reply is a clue, not a verdict. Test the actual service.
You should be able to
Read a traceroute and say where delay is added along the path
What the Cloud Is
Rent capacity by the hour instead of buying it, and learn what regions, zones and the shared-responsibility line mean for your app.
Takeaways
The cloud swaps buying for renting: capacity in minutes, paid by use, elastic. A region is a place you choose for latency, law, price and services. Zones inside it fail separately, so spread work across at least two, and size so the survivors can carry the load.
Pick the highest service layer that suits you, remember the provider secures the data centre while you secure your data and settings, and watch for idle bills, lock-in and egress fees. Next lessons: Compute, then Networking.
Key ideas
The saving comes from elasticity: capacity follows demand instead of being sized for the worst day.
A region protects you from distance and law problems. Zones protect you from a single building failing.
Rented capacity is easy to get and easy to waste or misconfigure. The skill is in the design.
Watch out
Owned capacity is a bet on the future, and you pay for it whether the bet is right or not.
More instances in the same failure domain do not add resilience. They only add capacity.
Most cloud breaches are customer-side misconfiguration, not provider hardware faults.
You should be able to
Compute: VMs, Images & Autoscaling
Virtual machines from a template, and how a group of them grows and shrinks with load.
Takeaways
A VM is a slice of a host made by a hypervisor, in types that trade CPU, memory and GPUs. An image makes every instance identical, so instances are replaceable cattle. Scale out for resilience and room to grow, scale up only for simplicity.
An autoscaling group holds a count between a minimum and a maximum and follows a policy, such as 60% CPU. Size it with load / (capacity x target), allow for boot lag, add a cooldown, keep state off the instance, and use spot only for interruptible work.
Key ideas
Treat instances as disposable and the image as the thing you care about.
Headroom is the price of reacting slowly: more spare capacity means a smaller gap but a bigger bill.
Good compute design assumes any instance can disappear at any moment and the system carries on.
Watch out
If a server can only be recreated by remembering what you did to it, it is a risk, not an asset.
A human reacting to a graph is too slow, and just as slow at removing capacity afterwards.
If deleting a VM would lose data, that VM is a pet again, even if it came from an image.
You should be able to
Explain what a VM and an image are and why identical instances beat hand-tuned servers
Cloud Networking: VPCs & Security Groups
Private networks, public and private subnets, and who is allowed to reach what.
Takeaways
A VPC is your own network, cut into subnets that each live in one zone. Public subnets have a route to the internet gateway, private ones do not. Route tables send packets; security groups decide who may speak, statefully and by group, so each tier accepts traffic only from the tier in front of it.
Private servers go out through a NAT gateway, one per zone, so no zone depends on another. The costs are money (NAT, cross-zone and outbound traffic) and more rules to keep correct. For firewalls and NAT in depth, see "Firewalls, NAT & VPNs" in Networking Fundamentals; for how a load balancer picks servers, see "Load Balancing" in System Design.
Key ideas
A subnet never spans zones. To use two zones you need at least two subnets.
Least privilege: each tier accepts one kind of traffic from one neighbour, and nothing else.
Zone-local design: each zone should be able to work alone.
Watch out
0.0.0.0/0 means the entire internet. Treat it as a red flag on anything except a public web port.
Do not fix this with public addresses on app servers. Fix the route.
Cross-zone dependencies hide in route tables. Trace the whole path, including the way out.
You should be able to
Containers
Isolated processes in layered images: what they are, what they are not, and how to build them well.
Takeaways
A container is an isolated process: namespaces limit what it sees, cgroups limit what it uses, and the kernel is shared with the host. An image is read-only layers from a recipe, stored in a registry, and a running container adds a writable layer that disappears with it. Order the recipe so slow, stable steps are cached.
Ship small images built in stages, run as non-root, deploy by version or digest, and keep data in volumes. In return you get the same bytes on every machine and starts measured in seconds. See "Observability" and "CI/CD & Deployments" in System Design for running them well.
Key ideas
The bug is not in the code. It is in an unrecorded difference between environments.
Smaller images start faster, cost less to store and move, and expose less.
Treat a container as disposable. Anything that must last lives outside it.
Watch out
Shared kernel means shared fate: a kernel flaw can matter to every container on the host.
Cache invalidation flows downward: a changed layer re-runs everything below it.
Everything in the final image ships to every node and can be used by anyone who breaks in.
A tag links a name to contents only by habit. Anyone who can push can move it.
Kubernetes: Desired State
Declare what you want and let controllers make it true, over and over.
Takeaways
You declare a Deployment: image and replicas. The control plane stores it, the scheduler places pods on nodes with room, and controllers run observe, compare, act forever. A deleted pod or a dead node is just another gap to close.
A Service gives pods a stable address through a label selector. What the loop cannot do is fix a broken image: a CrashLoopBackOff needs logs and a human. Next, Scaling & Updating on Kubernetes covers resource requests, autoscaling and safe rollouts.
Key ideas
Imperative: do these steps. Declarative: make it look like this, and keep it that way.
Deployment, then ReplicaSet, then pods: each layer keeps the next one at the right size.
You state a level (3). The loop keeps the cluster at that level.
Watch out
Nothing in this setup knows how many containers should be running.
Self-healing restarts things. It does not understand why they keep failing.
Adopt it for a problem you have, not because others use it.
You should be able to
Name the parts of a cluster and what a Deployment, ReplicaSet and pod are
Explain the reconcile loop and how it replaces a deleted pod or a dead node's pods
Scaling & Updating on Kubernetes
Resource requests, autoscaling and rollouts that stop themselves when something is wrong.
Takeaways
Requests reserve resources and limits cap them. The HPA sets replicas with ceil(n x current / target), scales down slowly, and the cluster autoscaler adds nodes when pods cannot be scheduled, in minutes rather than seconds. Over-requesting wastes money and a memory limit that is too low causes restart loops.
Rolling updates stay inside maxSurge and maxUnavailable, readiness probes keep bad pods away from users and stall the rollout, and kubectl rollout undo returns to the old version. Next, Infrastructure as Code applies the same declare-and-reconcile idea to the machines underneath.
Key ideas
Requests drive placement and the autoscaler's maths. Limits drive throttling and kills.
Pods scale in seconds, nodes in minutes. The slower layer sets the real pace.
Readiness turns a bad release into a stalled rollout instead of an outage.
Watch out
The scheduler cannot protect a node from pods that never said what they need.
At 90% there is almost no room left: a small burst becomes queueing.
Measure real usage before choosing requests and limits, then revisit them.
You should be able to
Infrastructure as Code
Describe infrastructure in files, preview every change as a plan, and catch drift before it bites.
Takeaways
Infrastructure as code turns the console's invisible clicks into files in git. The tool compares files, state and the real cloud, shows a plan, and applies only what you approved. Applying twice changes nothing, and modules with variables give every environment the same shape.
Read every plan, especially the destroy count. Protect critical resources, keep state in one shared locked place, and watch for drift. For what comes next, see Configuration & Secrets, and GitOps & Safe Delivery for automating the review-and-apply loop.
Key ideas
Declarative: describe what should exist. The tool works out how to get there.
Different sizes, same shape: that is what makes staging a faithful rehearsal of production.
Run plans on a schedule, even with no code change, to catch drift early.
Watch out
If production is lost, rebuilding means days of guessing at settings nobody recorded.
Always read the destroy count. A rename can look to the tool like a delete plus a create.
State can hold sensitive values in plain text. Protect it like a password store.
You should be able to
Explain why click-built environments cannot be repeated or audited
GitOps & Safe Delivery
Git as the source of truth, rollouts you can undo, and a cluster that corrects itself.
Takeaways
Delivery strategies trade speed against risk: rolling is gradual, blue/green is instant but doubles capacity, canary limits the blast radius to a small share. GitOps puts the desired state in git and lets an in-cluster agent pull and reconcile it, so a deploy is a merged pull request and a rollback is a revert.
Commit every change, pin versions, keep secrets out of git, and add checks before merge plus a canary after it. Know your break-glass path and who can merge to production. Related lessons: Configuration & Secrets, and Observability in System Design for the signals a canary compares.
Key ideas
Same goal, different blast radius: rolling is gradual, blue/green is instant, canary is measured.
Rollback by revert is reviewed, recorded and repeatable. A hand-typed fix is none of these.
Watch out
Two problems: a powerful key outside the cluster, and no way to see that git and the live system disagree.
In GitOps, a change not in git is a change on a timer.
Automation applies mistakes as quickly as it applies good changes.
Whoever can merge to the production branch can change production. Protect that branch.
You should be able to
Configuration & Secrets
Keeping settings out of code and credentials out of git, images and logs.
Takeaways
Configuration is what differs between environments and lives outside the code and image, so one build runs everywhere. Secrets are configuration that grants access, so they get a manager, expiring identity-based credentials, least privilege per service, rotation with overlap and commit scanning.
The failures to watch for: a key in git (history keeps it), a secret in an image layer or log line, and one shared admin key. When something leaks: revoke, rotate, audit, clean up. For related ideas see the System Design lessons Encryption & Secrets and CI/CD & Deployments, and GitOps Delivery in this course.
Key ideas
The code holds a name. The manager holds the value.
Limit what a leaked credential can do, not only how likely a leak is.
Every control adds a moving part. Plan for its failure.
Watch out
Deleting a committed secret does not un-leak it. Revoke it.
What you write into an image or a log is copied to places you do not control.
One leaked copy opens everything the key can reach.
Deleting the file is the last step, not the first.
You should be able to
Tell configuration from secrets and keep both outside the code and image
SLOs & Error Budgets
Turning reliability into a number you can spend, and alerting on what users feel.
Takeaways
Measure reliability as an SLI from the user's side, set an SLO for it, and keep the SLA looser. The error budget is 100% minus the SLO: 43.2 minutes per 30 days at 99.9%. Spend it on change while it lasts and follow a pre-agreed freeze policy when it runs low.
Alert on burn rate: fast burns page, slow burns become tickets. Watch for health checks that measure the server, SLOs nobody owns, and dependencies that cap you. For the underlying metrics see the System Design lesson Observability, and for what happens when a page fires, the next lesson on Incidents.
Key ideas
Set the SLO tighter than the SLA, so you have room to react.
Pick the lowest target users would not notice missing.
Page when the budget will vanish soon, not when a number twitches.
Watch out
A green health check only proves that the check passed.
A policy agreed in advance beats a debate during an outage.
An alert that is usually ignored is worse than no alert.
You should be able to
Define SLI, SLO and SLA, and say why an SLI measures the user's experience
Compute an error budget in minutes and in requests
Incidents & Postmortems
Stopping the damage first, learning afterwards, and doing both without blame.
Takeaways
Alerts shorten time to detect. A severity level sets who wakes and how often you update. Roles and one channel keep the response orderly: one commander, responders who change one thing at a time, a communications lead.
Mitigate first: roll back, fail over or flip a flag, and find the root cause once users are fine. Share the load with runbooks and a rotation, never a hero. Finish with a blameless postmortem whose action items have an owner and a date. In our example: 6 minutes to detect, 24 to mitigate, 30 of user impact.
Key ideas
Severity is a decision made early so nobody argues about it while the clock runs.
Resolve means the real fix; mitigate means the users are fine again. Do the second one first.
A postmortem without owned action items is just a story about last week.
You cannot prevent every incident. You can make each one shorter and make sure it happens only once.
Watch out
If users find out before you do, your detection has failed, whatever else went right.
More hands is not more progress. Uncoordinated changes destroy the evidence you need.
A response that needs a specific person is a single point of failure.
You should be able to
Cloud Costs
Where the bill comes from and the levers that bring it down without breaking things.
Takeaways
A bill is four meters: compute hours, storage GB-months, data transfer and managed services. Tag everything so every cost has an owner, switch off what idles, and right-size and autoscale so you pay for demand, not the peak.
Buy the steady floor with a commitment, the peaks on-demand and restartable batch on spot. Give data lifecycle and location rules, and put budgets and anomaly alerts on the account. Weigh each saving against flexibility, engineer time and reliability.
Key ideas
You cannot ask someone to justify a cost that has no name on it. Tags give every cost a name.
Commit to the floor you are sure to use, never to the peak.
Treat a cost spike like an incident: alert, find the change, roll it back.
Cost work is reliability work with a price tag: reduce waste, keep the safety margins.
Watch out
Idle resources cost exactly as much as busy ones. The meter does not know nobody is using it.
Low utilisation is the clearest sign of paying for capacity you do not use.
Storage without a retention rule and transfer without a location rule are slow leaks.
A saving that causes an outage is not a saving. Check the SLO before you cut.
The Security Mindset
Assets, attackers and risk: how to reason about what could go wrong before it does.
Takeaways
Name your assets, then ask which of confidentiality, integrity and availability could fail. Rank risks by likelihood x impact, and count the attack surface so you can shrink it. Attackers pick the easiest way in, which is often a person rather than a firewall.
Defend with several independent layers, give every account the least privilege it needs, and deny by default. Do not rely on obscurity. Weigh each control's cost against the risk it removes, and put your effort at the top of the ranking.
Key ideas
A system can be perfectly secret and still fail availability: a locked door nobody can open helps nobody.
Good test: if the attacker had the full design document, would the control still stop them?
You cannot stop every mistake, so shrink what any one mistake can reach. That is the blast radius.
Watch out
A score only ranks. Two risks with the same product can still need very different responses.
Attackers go around strong controls and through weak people or processes. A perimeter alone is one point of failure.
You should be able to
Name the three goals of security (confidentiality, integrity, availability) and give one failure of each
Threat Modeling
Drawing the system, marking the trust boundaries and asking what can go wrong at each one.
Takeaways
Draw the system as a data flow diagram: external entities, processes, data stores, flows. Mark the trust boundaries as dashed lines. Walk every element and crossing with STRIDE to list what can go wrong, then rank each threat by likelihood x impact.
Give every threat a response (mitigate, accept, transfer or avoid) and an owner. Do it early, because late fixes cost more. Update the model whenever the design changes. Keep each session short enough that the team will actually run it again.
Key ideas
If you cannot draw where the data goes, you cannot say who can touch it.
Question 4 is a check: for every threat, can you point to the control, or the written decision to accept it?
Watch out
Never trust data just because it arrived through your own front door. Everything from the browser is attacker-controlled input.
A threat you have not written down will not be handled. A list full of minor items is still better than an empty one.
An out-of-date threat model is a map of a city that has since built a new district.
You should be able to
Draw a data flow diagram with an external entity, a process, a data store and an outside service
Passwords & Hashing
Why stored passwords must be slow to guess, and what still goes wrong when people reuse them.
Takeaways
Store passwords as a salted, slow hash from bcrypt, scrypt or Argon2, with the cost tuned to about 100 ms. A leaked table then costs the attacker hours per small list instead of milliseconds, and no shared hashes give shortcuts.
Assume users reuse passwords anyway: rate-limit, check new passwords against breach lists, offer MFA, favour length, and give one error message for every failure. Keep secrets like a pepper out of the database. For key and secret handling see Encryption & Secrets in System Design and Configuration & Secrets in Cloud & DevOps.
Key ideas
The server never needs to know your password, only whether what you typed hashes to the same value.
A pepper is an extra secret mixed in and kept outside the database, for example in a secrets store. It helps if only the table leaks, but it is an optional extra, not a replacement for a slow salted hash.
Every difference an attacker can observe, a message or a delay, is a small leak.
Watch out
Design the user table as if it will leak one day. Then the leak is an incident, not a catastrophe.
Speed is a virtue for file checksums and a vice for password storage.
Slow hashing protects stolen hashes. It does not protect against passwords the user chose to reuse.
Injection Attacks
When input becomes code: SQL and command injection, and why parameters end them.
Takeaways
Injection happens when untrusted input is mixed into text that an interpreter parses. Stop it at the root: parameterised queries for SQL, argument lists instead of a shell, and allow-lists for the parts that cannot be parameters.
Then limit the damage: a least-privilege database account, generic errors for visitors with the full details in the log, and validation as defence in depth. Sweep legacy code for string-built queries, and treat every raw fragment as a review point.
Key ideas
Injection is not a database bug. It is a missing boundary between data and code.
Least privilege does not prevent injection. It shrinks what an injection can do.
Watch out
The attacker never needed the password. They changed what the question meant.
Assume some bug will get through. Limit what it can do and what it reveals.
A file name is untrusted input like any form field.
You should be able to
Explain how a quote in input turns data into SQL when a query is built by joining strings
Use parameterised queries and say why input can then only be a value
Handle parts that cannot be parameters, and limit damage with least privilege and quiet errors
Cross-Site Scripting
How untrusted text turns into script in someone else's browser, and the layers that stop it.
Takeaways
XSS is untrusted data treated as code in someone else's browser, running with the site's own privileges. Stored, reflected and DOM-based differ only in where the data comes from. The main fix is always the same: encode for the context at output, through templates and textContent.
Sanitise the rare rich-text field with an allow-list library, add a CSP and HttpOnly cookies as backstops, and never trust an admin page or a word blocklist. Related lessons: Injection for the same idea on the server side, and Sessions & CSRF for what a stolen session allows.
Key ideas
Ask of every value: where did it come from, and where does it land? XSS lives in that path.
These are backstops. They reduce harm; they do not replace encoding at the source.
Watch out
Treat every value from a user, a URL or another system as untrusted, however friendly the form looks.
With 120 readers a day and the comment live for 3 days, that is about 360 page views, each running the script.
Allow-lists and context-aware output encoding work. Hunting for bad words never ends.
You should be able to
Sessions & CSRF
Cookies that prove who you are, and the forged requests that borrow them.
Takeaways
Keep it long, random and meaningful only on the server. Set HttpOnly, Secure and SameSite explicitly. Rotate the id at login, delete it at logout, and use idle and absolute timeouts. Then defend the other direction: a forged request borrows a real cookie, so require a token, check Origin and never change state on GET.
Related lessons: Cross-Site Scripting (the usual way ids are stolen), Authentication and Authorization in System Design, and TLS & HTTPS in Networking Fundamentals for why Secure matters.
Key ideas
Use your framework's session library. Rolling your own id generator is how counters and timestamps sneak back in.
Each check is cheap. Together they leave the attacker with no path.
Watch out
Never derive a session id from a counter, a timestamp, a user name or any other guessable value.
Both attacks succeed because the id stays the same while the privilege changes.
The cookie proves who is asking, but not that they meant to ask.
You should be able to
Explain what a session id is and why it must be long, random and kept server-side
Choose cookie attributes and rotate or expire sessions to stop hijacking and fixation
Broken Access Control
Why 'logged in' is not 'allowed': per-object checks, hidden buttons and client-supplied roles.
Takeaways
Authentication proves who someone is; authorisation decides what they may do, and it must run on the server for every request and every object. A changed id (IDOR), a hidden button and a client-supplied role all fail the same way: the server believed something the user controlled.
The defences stack: take the user from the session, check ownership or role per object, keep the rules in one policy that denies by default, use random ids as a second layer, log and alert on denials, and run a two-user test on every change. Next in this course comes 'Supply Chain Security', about the code you did not write.
Key ideas
Anything running on the user's machine can be edited by the user. Hide buttons for tidiness, check on the server for safety.
Fail closed: a missing rule should break a feature, not expose data.
Choose the simplest policy that no route can bypass, and grow it when the rules grow.
Watch out
A valid login plus an unchecked id is enough. No special skill is needed, only a different number.
Saving every field of a request ('mass assignment') is how this creeps in. Accept only a named list of fields.
'Nobody could guess that address' is a hope, not a rule. Check ownership anyway.
Supply Chain Security
The code you did not write: dependencies, build pipelines and the ways they get poisoned.
Takeaways
Attackers aim at what you trust: look-alike names, public twins of private names, stolen maintainer accounts, poisoned pipelines and tainted images, plus old libraries with known flaws. Each works without a bug in your own code.
The defences: a lockfile with integrity hashes, private names kept private, reviewed and tested updates, a scanner, fewer dependencies, an SBOM so you can answer 'who uses it?', and a least-privilege, ideally reproducible pipeline. Next in this course, 'Hardening' reduces what an attacker can reach on the systems themselves.
Key ideas
You do not only trust the code you wrote. You trust every maintainer, registry and build step behind it.
Each of these breaks trust you extended on purpose, which is why 'we never click suspicious links' does not cover them.
Inventory first, then response. The speed of your patch is limited by the speed of your answer to 'where is it?'.
Measure how long a fix takes from announcement to production. That one number shows whether the balance is right.
Watch out
A package name is just text. Similar names are different packages, owned by different people.
If a name can be claimed on the public registry, assume somebody will claim it.
Secure Configuration & Hardening
Defaults, open ports and forgotten consoles: shrinking what an attacker can touch.
Takeaways
Systems arrive configured for ease, and attackers search for exactly those settings. Hardening answers each in turn: close ports until only what is needed remains (5 open, 2 needed, 60% fewer), deny by default, change defaults, require MFA, and turn off debug detail.
Then keep it that way: patch promptly, write the baseline as code, and scan for drift so a hand edit is noticed. Balance it with testing on staging and rules people will actually follow. The next lessons, Logging & Detection and Breach Response, cover how you notice and handle what still gets through.
Key ideas
Software you do not run cannot be attacked. Removing is the cheapest defence.
The goal is not one perfect setup. It is noticing quickly when reality stops matching the plan.
Watch out
Default logins are published in manuals, so attackers try them first.
Detail that helps you debug also helps an attacker. Show it to engineers, not visitors.
A known flaw is a free tip-off to attackers. Time is the thing you control.
You should be able to
Name the common misconfigurations: default credentials, reachable admin consoles, debug mode, open ports, old software
Logging & Detection
What to record, how to protect it, and which patterns should raise an alarm.
Takeaways
You cannot respond to what you cannot see. Log the events that matter (sign-ins, denials, admin and permission changes, exports) with who, what, when, where and a request id, and keep passwords, tokens and card numbers out. Ship logs off the host to an append-only store so an intruder cannot erase them.
Then detect: alert on patterns and baselines, not single events, such as more than 20 failures in 5 minutes. Collect and correlate in a SIEM, tune for low noise, mind cost and privacy, and make someone responsible for reading. The next lesson, Breach Response, covers what to do when an alert is real.
Key ideas
Consistent fields are what let a machine search, count and compare logs later.
A threshold turns a flood of lines into one question: is this rate normal?
Detection does not prevent the break-in. It caps how much a break-in can cost.
Watch out
If outsiders tell you about the breach first, your detection failed.
A secret that reaches a log has been given to everyone who can read that log.
Do not trust a record that the suspect controls.
An ignored alert is no better than no alert. Fewer, trusted alerts beat many noisy ones.
You should be able to
Responding to a Breach
Contain, preserve, eradicate, recover and tell people, in the right order.
Takeaways
Prepare first: a plan, named roles, contacts, logs, an offline runbook and a private chat. Then identify and triage, contain with isolation, revoked sessions and blocks, and preserve evidence (memory, disk, logs) before any wipe.
Eradicate the foothold, patch the hole and rotate every credential the intruder could reach (7 of 7, not 3 of 7). Recover from clean sources in stages, scope from the logs and notify on time (for example 72 hours under GDPR, with legal advice). Finish with a blameless learning review that produces owned actions.
Key ideas
Isolate, do not power off: a running machine still holds evidence that a shutdown erases.
If you cannot prove a secret was not read, treat it as read.
Decide the trade-offs in the plan, before the night when everyone is tired.
Speed matters, but order matters more: preserve before you wipe, and rotate everything before you relax.
Watch out
Do not wait for certainty before waking the team. Triage can be revised; lost hours cannot.
A rebuilt server proves nothing about how the breach happened. Evidence you destroyed does not come back.
Testing for Security
Reviews, scanners, fuzzing and authorised attacks that find flaws before others do.
Takeaways
Security tests check what should not be possible. Layer them cheapest first: review, static analysis, secret and dependency scanning, regression tests for rules like "B cannot read A's invoice", DAST and fuzzing on a test copy, then pen tests with a signed scope. Shift left, since earlier means cheaper.
Triage output down to what matters (400, then 40, then 6), give each finding an owner and a deadline, and automate the cheap gates in CI so there is no 9-month gap. Offer a way for outsiders to report flaws, test only what you are allowed to, and remember a clean scan is not proof of safety.
Key ideas
Layers catch different things. No single tool covers all of them.
Severity, exploitability and exposure together decide the order, not the tool's colour alone.
Report "no findings from X", never "secure".
Watch out
A green test suite proves only that the cases somebody thought of still work.
A finding nobody owns is a finding nobody fixes.
A snapshot is not a guarantee. Treat a pen test as one layer, not the whole programme.
Good intentions are not authorisation. Get it in writing first.
You should be able to
Why Caching Helps
Keep a copy of popular answers close by, so the slow place is asked less often.
Takeaways
A cache keeps copies of frequent answers in fast storage, which cuts latency and database load. Hits are cheap and misses cost a database trip. Cached data can be stale, so choose an expiry or an invalidation rule.
Key ideas
Caching trades freshness for speed. Decide how stale is acceptable.
Watch out
The database does identical work again and again.
You should be able to
Spot a read-heavy bottleneck
Add a cache in front of the database
Explain hits, misses and stale data
Estimate how step count drives cost
Describe what happens at the limit and what gets lost
Choose between summaries, a scratchpad and external memory
Decide what to save and how to expire stale memories
Verify results, replan on failure, and weigh the cost of planning
Treat retrieval as a tool the agent can call, rewrite and repeat
Name the failure modes and their fixes: chunk size, stale index, silent misses
Weigh predictability and cost against flexibility
Describe the orchestrator-worker pattern and hand-offs
Estimate what extra agents cost in tokens and which new failures they bring
Apply contracts, a single owner and depth limits, and know when to stay with one agent
Describe discovery: tools, resources and prompts a server offers
Choose between local and remote servers and decide who a tool acts as
Treat server descriptions and outputs as untrusted input
Separate outcome from trajectory, cost and latency
Choose graders and report a rate over repeated runs
Run a regression suite and read traces to find the first wrong step
Explain how a hostile page can steer an agent (indirect prompt injection)
Apply least privilege: scoped, read-only, allow-listed tools
Enforce rules in code and keep dangerous combinations apart
Gate actions by risk so human approval stays meaningful
Compute how per-step success compounds over a run
Cut cost and latency: trim, cache, right-size, parallelise
Add budgets, safe retries and an honest fallback
Describe training as a search for the setting with the fewest mistakes
Say when plain rules beat machine learning
Spot data leakage and name the fixes
You should be able to
Write a prediction rule as price = w x size + b and say what w and b mean
Compute the error of each prediction and the mean squared error
Explain why errors are squared and why the best line has the lowest loss
Name three limits of a straight-line model
You should be able to
Apply the rule new w = w - learning rate x slope to a small example
Describe what a learning rate that is too small or too large does
Explain epochs and mini-batches, and why mini-batch steps are noisy but cheap
State the costs and the guarantees (and non-guarantees) of gradient descent
Turn a score into a probability, and a probability into a decision with a threshold
Choose a threshold by weighing the two kinds of mistake
Name two limits: skewed classes and a straight-only boundary
Describe how depth moves a tree from underfitting to memorising
Explain why many trees voting are steadier than one, and what boosting adds
List what a forest costs: readability, compute and range
Use validation error to stop training early or choose a model
Explain bias versus variance in plain words
Fill in a confusion matrix and compute precision, recall and F1
Describe how the threshold trades precision against recall
Choose a metric from the cost of each kind of mistake
Choose k, and name two things that change the answer
Explain why clusters need a human check
Describe training as loss, blame sent backwards, and small weight updates
Name the costs of neural networks: data, compute, overfitting, opacity
Compare two vectors by hand with distance and cosine similarity
Describe how embeddings are learned from context
Explain why big searches use an approximate index, and what can still go wrong
Explain how text is split into tokens and what the model outputs
Describe pretraining as next-token prediction and why it teaches more than grammar
Tell pretraining, instruction tuning and preference tuning apart
Explain how temperature changes sampling and name three limits of a trained model
Explain why data is cut into packets instead of sent as one block
Describe a packet as a header plus a payload, wrapped in layers
Follow a packet hop by hop through routers
Estimate transfer time as latency plus size divided by bandwidth
Explain how a switch learns MAC addresses and why it beats a hub
Describe how ARP turns an IP address into a MAC address
Explain why ARP entries can be stale or spoofed, and what limits the damage
Say why Wi-Fi is shared airtime and name three ways to improve it
Predict which route a router picks by longest prefix
Explain how TTL stops loops and how traceroute uses it
Explain how a lost segment is noticed and resent
Describe the costs: handshake delay, head-of-line blocking and connection state
You should be able to
Tell flow control (protects the receiver) from congestion control (protects the network)
Work out how a congestion window grows in slow start and shrinks after loss
Estimate throughput as window divided by round-trip time
Explain bufferbloat and name two ways to avoid it
Describe what UDP provides (ports and a checksum) and what it leaves to the application
Choose UDP or TCP for a given job by asking whether late data is still useful
Compare connection setup in round trips for TCP+TLS 1.2, TCP+TLS 1.3 and QUIC
Explain how QUIC streams avoid head-of-line blocking
Explain how caching and the TTL change lookup time
Say what the common record types hold
Plan a DNS change so stale answers expire quickly
HTTP/2 put all eggs in one TCP basket: a hole in the byte stream blocks everything behind it.
The chart shows an illustrative shape, not measured data. Measure your own users before promising speed-ups.
You should be able to
Explain why HTTP/1.1 needs several connections and where it blocks
Describe how HTTP/2 multiplexes streams and why one lost packet still hurts
Say what HTTP/3 and QUIC change, and how a browser finds out about it
Name what stayed the same and when the gains are small
You should be able to
Name the three guarantees TLS adds to a plain connection
Walk through the one-round-trip TLS 1.3 handshake and say why data then uses a shared key
Explain how a certificate chain lets a browser reject a man in the middle
Predict the cost of HTTPS and the usual ways certificates cause outages
Putting a proxy in the path changes what the next hop can see. Anything keyed on the client address silently breaks.
You should be able to
Tell a forward proxy from a reverse proxy by who it works for
Choose between layer 4 and layer 7 balancing and name a rule only layer 7 can apply
Work out what health checks and connection reuse save, using round-trip numbers
Recover the real client address with X-Forwarded-For without trusting a forged one
Predict which rule of an ordered list a packet matches, with default deny at the end
Explain why a stateful firewall lets replies in without an inbound rule
Follow a NAT translation table and say why NAT is not a security control
Describe how a VPN encapsulates packets and why the tunnel overhead can break large ones
Test link, IP and DNS in order with ping and dig and read their output
Tell a refused connection from a timeout and say what each implies
Match a symptom to the layer where it ends, using the three case studies
Explain how renting capacity by the hour differs from buying servers up front
Tell a region from an availability zone and say how to choose a region
Show why spreading across zones behind a load balancer survives a zone outage
Draw the shared-responsibility line and name the costs of the cloud
Compare scaling up with scaling out
Size an autoscaling group from request rate, per-instance capacity and a target utilisation
Explain how boot time, cooldown, local state and spot capacity shape a fleet
Size a VPC and its subnets from CIDR blocks
Explain what makes a subnet public or private
Write security-group rules that name groups instead of addresses
Describe how private servers reach out through NAT, and why each zone needs its own
You should be able to
Explain what a container is made of, and how it differs from a virtual machine
Order the instructions of an image recipe so rebuilds stay fast
Shrink an image and run it without root
Deploy by version or digest instead of a moving tag, and keep data in volumes
Explain how a Service keeps one address while pod addresses change
Recognise CrashLoopBackOff and weigh the cost of running Kubernetes
Explain what requests and limits do, and what happens when a limit is exceeded
Compute the autoscaler's replica count and explain why scale-down waits
Describe how a rolling update uses maxSurge and maxUnavailable
Explain how readiness probes stall a bad rollout and how to roll back
Describe the files, the state record and the real cloud, and read a plan summary
Use modules and variables to build dev, staging and production from one pattern
Guard against a destructive plan, shared-state accidents and drift
Compare rolling, blue/green and canary releases by blast radius and cost
Explain how an agent inside the cluster pulls from git and reconciles
Roll back with a git revert, and say why a manual hotfix gets reverted
Limit a bad change with merge checks, a canary and pinned versions
Explain why a secret in git, an image layer or a log line is already leaked
Describe a secrets manager, identity-based access and least privilege
Plan a rotation with an overlap window and respond to a leak in the right order
Use the budget to decide between shipping and slowing down
Read a burn rate and choose between a page and a ticket
Walk through detect, triage, mitigate, resolve and review, and measure time to detect and to mitigate
Explain why roles and one shared channel beat five people changing things at once
Say why you mitigate before you find the root cause
Write a blameless postmortem whose action items have an owner and a due date
You should be able to
Name the four main cost drivers and why a pay-as-you-go bill can grow unnoticed
Use tags, schedules and right-sizing to match spend to real use
Choose between on-demand, committed and spot capacity for a workload
Control storage and transfer costs, and catch surprises early with budgets and anomaly alerts
Rank risks with likelihood x impact and count an attack surface
Explain why one strong wall fails and why obscurity is not a control
Apply defence in depth, least privilege and deny by default, and say what they cost
Mark trust boundaries where data crosses from less to more trusted
Use STRIDE to list threats and rank them by likelihood x impact
Choose mitigate, accept, transfer or avoid for each threat
Explain why a model must be revisited when the design changes
You should be able to
Explain why a stored password must be hashed, not kept in plain text or encrypted
Say what a unique salt defeats and what it does not
Work out how a cost factor turns guesses per second into hours of work
Name three defences against credential stuffing and the trade-off each one brings
Recognise command injection and fix it by avoiding the shell and allow-listing
Explain how text becomes code, and tell stored, reflected and DOM-based XSS apart
Encode output for its context and prefer templates and textContent over raw insertion
Recognise the failed fixes: input encoding, blocklists, and trusting an admin page
Add backstops: an allow-list sanitiser, a Content Security Policy and HttpOnly cookies
Describe how a forged cross-site request works and why the browser sends the cookie
Stack SameSite, anti-CSRF tokens and Origin checks, and know what CORS does not do
You should be able to
Tell authentication (who are you?) from authorisation (what may you do?)
Recognise an insecure direct object reference, a hidden-button flaw and a trusted client field
Enforce access on the server for every request, with one central policy that denies by default
Prove it with a two-user test and by scoping every query to its owner
Not knowing what you run is a vulnerability of its own: you cannot patch what you cannot find.
You should be able to
Name the ways a dependency or build step can be poisoned: typosquatting, dependency confusion, a bad update, CI and images
Use lockfiles, integrity hashes and private scopes so builds are repeatable and verified
Balance pinning against patching with automated update pull requests, tests and a scanner
Answer 'which services use this library?' in minutes with an SBOM
Shrink the attack surface by closing what is not needed, and calculate the cut
Protect an admin console with a private network, a removed default and MFA
Use a baseline, configuration as code and a scanner so drift is noticed
Say what to log (who, what, when, from where, request id) and what never to log
Protect logs by shipping them to a central append-only store
Write a pattern-based alert with a threshold and read a failures-per-minute chart
Explain dwell time, and why alert fatigue and cost need tuning
A patched hole does not remove a foothold the intruder already planted.
Silence turns a security incident into a trust incident. Customers who hear it from the news stop believing you.
You should be able to
Name the phases of a response (identify, contain, preserve, eradicate, recover, learn) and what to prepare beforehand
Contain a breach without destroying the evidence you will need later
Remove the foothold and rotate every credential the intruder could have touched
Scope the damage from logs and notify regulators and users honestly and on time
Order the security checks cheapest first: review, scanning, tests, DAST, fuzzing and penetration tests
Write a test that asserts something must not be possible, such as one user reading another's invoice
Triage a scanner report from hundreds of findings down to the few that matter, each with an owner and deadline
State when testing is legal and ethical, and why a disclosure policy helps outsiders report flaws