CSE Roadmap

Core tier · about 4 hours · 10 parts

Part 10 of 10 · 3 min read

Exercises

Easy

Easy 1: Trace a request (15 minutes)

Write the steps of a request from typing shop.example.com to seeing a page, in your own words, naming DNS, IP address and HTTP.

Done when: at least five numbered steps, each in one sentence.

Hint

Name, then DNS, then address, then request, then answer.

Easy 2: Name the fix (15 minutes)

Match each problem with the rung that fixes it: (a) the one database machine died and the site went down, (b) images load slowly for users abroad, (c) sending confirmation emails slows checkout, (d) one web server cannot handle the load, (e) the same menu is read from the database ten thousand times an hour.

Done when: five problems, each with one named fix.

Hint

Think failure, distance, slow work, load and repeated reads.

Easy 3: Scale up or out? (15 minutes)

Decide whether to scale up or out, with a reason: (a) a tiny site with 100 users, (b) a site that must survive any single machine failing, (c) a database that is only slightly too slow.

Done when: three answers with a reason each.

Hint

Up is simple but has a ceiling and no safety net.

Medium

Medium 1: Count the servers (25 minutes)

Peak load is 1,500 requests per second. One server handles 250. The site must survive the loss of two servers at peak. How many servers? Show the steps. Then say what happens if the peak doubles.

Done when: a count with arithmetic, and a count for double peak.

Hint

1,500 ÷ 250 = 6 servers for the peak. Then add two for the failure plan.

Medium 2: Cache walk-through (30 minutes)

Using the code in section 5, a menu is requested 1,000 times in 10 minutes with a TTL of 300 seconds. How many times does the database get asked? Then change the TTL to 60 seconds and recount. What do you gain and lose with the shorter TTL?

Done when: two counts, and one sentence on the trade-off.

Hint

With a 300-second TTL, 10 minutes is two cycles. With 60 seconds, ten cycles.

Medium 3: Stateless or stateful? (25 minutes)

A shop keeps each user's shopping basket in the memory of the web server that first served them. List three problems this causes when servers are added, replaced or restarted, and design a stateless alternative.

Done when: three problems, a drawing or description of the alternative, and one cost of the alternative.

Hint

Think of a restart, a failed server and the load balancer picking a different server.

Hard

Hard 1: Climb the ladder (45 minutes)

A photo app starts with 5,000 users on one server. For each of the sizes 50,000, 500,000 and 5,000,000 users, write which rungs you add, in order, with a reason and a number (made up but sensible) that triggers each one.

Done when: three sizes, at least eight rungs in total, and each with a reason and a trigger number.

Hint

Start each size with the cheapest step and move up only when a number requires it.

Hard 2: Choose a shard key (40 minutes)

A chat app stores messages. Compare three shard keys: user id, chat id and time. For each, say how evenly data spreads, which queries stay on one shard and which need many shards. Choose one and name its main risk.

Done when: three options compared in a table, one choice and one stated risk.

Hint

A key that groups all of a chat's messages keeps a conversation on one shard.

Hard 3: Draw the full system (50 minutes)

Draw a system with every rung from the table: DNS, CDN, load balancer, web servers, cache, queue and workers, leader and follower databases, and shards. Label each arrow. Then trace a "post a photo" and a "view a feed" request on it.

Done when: one diagram with at least ten labelled parts, and two traces of at least five steps each.

Hint

Put the CDN and DNS on the left, shards on the right.