CSE Roadmap

Core tier · about 3 hours · 8 parts

Part 8 of 8 · 3 min read

Exercises

Easy

Easy 1: Who does what (20 minutes)

A shop has one leader and three followers. For each action, say which node handles it: placing an order, viewing a product page, updating stock, running a sales report.

Done when: four answers with a reason each.

Hint

Writes go to the leader. Reads can go to followers.

Easy 2: Read replicas needed (20 minutes)

Each machine does 8,000 operations per second. The workload is 1,500 writes and 20,000 reads per second. Compute the number of replicas needed.

Done when: a replica count with the working.

Hint

Capacity for reads per replica = 8,000 − 1,500.

Easy 3: Writes at risk (20 minutes)

A leader takes 600 writes per second. Compute the maximum writes lost if it dies, for asynchronous replication with 100 ms lag and for semi-synchronous replication with one live synchronous follower.

Done when: two numbers.

Hint

Writes at risk = writes per second × lag in seconds.

Medium

Medium 1: Catch-up time (30 minutes)

A snapshot takes 90 minutes. The leader makes 800 changes per second. The follower applies 3,000 per second. Compute the backlog and the catch-up time. What happens if the follower applies only 700 per second?

Done when: a backlog, a time and an explanation of the second case.

Hint

Backlog = changes per second × seconds of the snapshot. Net rate = apply rate − new changes.

Medium 2: Pick the timeout (30 minutes)

A leader's pauses last up to 8 seconds in normal running. A failover takes 20 seconds. Writes arrive at 1,000 per second. Choose a timeout and compute the writes affected by a real crash and the false failover risk for timeouts of 5, 15 and 60 seconds.

Done when: a three-row table and a chosen timeout with a reason.

Hint

Writes affected = rate × (timeout + failover time).

Medium 3: Choose the log (30 minutes)

Choose a replication log type for each case, with reasons: a zero-downtime upgrade of the database software, feeding a search index from the database, replicating one table to a different kind of database, a database that must use identical versions anyway and wants the simplest set-up.

Done when: four choices with reasons.

Hint

Think of version independence and readability by other systems.

Hard

Hard 1: Failover walk-through (45 minutes)

Write a step-by-step failover for a leader with two asynchronous followers: the lag of each, the choice of the new leader, the writes lost, what the old leader does when it returns, and how split brain is prevented. Use numbers of your own for lag and write rate.

Done when: a numbered timeline with numbers, plus the guard against split brain.

Hint

The best new leader is the follower with the least lag.

Hard 2: Design for two regions (45 minutes)

A service has users in two regions 100 ms apart. Design the leader and follower placement, synchronous or not, the read routing and the failover plan. Compute the write latency in each region and the data lost if the leader's region goes down.

Done when: a diagram, two latency figures and a loss figure.

Hint

A synchronous write across regions adds the round trip.

Hard 3: Capacity plan (50 minutes)

A service grows from 3,000 to 12,000 writes per second and from 20,000 to 80,000 reads per second. Each machine does 10,000 operations per second. Work out the number of replicas at each stage, and find the point where the single leader becomes the limit. State what you would do then.

Done when: two replica counts, the limit point and a next step.

Hint

Every replica applies all writes. Reads per replica = 10,000 − writes.