CSE Roadmap

Core tier · about 3 hours · 8 parts

Part 8 of 8 · 3 min read

Exercises

Easy

Easy 1: Time saved (20 minutes)

A user is 200 ms from the origin and 20 ms from an edge. A new connection needs 4 round trips. Work out the time before the first byte from each, and the saving.

Done when: two times, a saving, and one sentence on a later request on the open connection.

Hint

Round trips × time per round trip.

Easy 2: Hit ratio (20 minutes)

Out of 2,000,000 requests in a day, 1,880,000 were hits. Find the hit ratio and the number of requests that reached the origin. Then find the load at the origin if the hit ratio becomes 98 percent.

Done when: a ratio, two origin counts and the factor between them.

Hint

Origin requests = all requests − hits. Compare 2 percent with the first figure.

Easy 3: Static or dynamic (20 minutes)

Sort into static or dynamic and give a cache rule for each: company logo, user's inbox, a product photo, a search result page, a video segment.

Done when: five rows, each with a class and one cache rule.

Hint

If every user gets identical bytes, it is static.

Medium

Medium 1: Bandwidth at the origin (30 minutes)

A news site has 4 million page views a day, with 3 MB of static files each. Compute the total per day, the average rate in megabits per second, and the origin rate at hit ratios of 90 and 99 percent.

Done when: a daily total, an average rate and two origin rates, with every division shown.

Hint

TB per day to MB per second, divide by 86,400. Multiply MB per second by 8 for megabits.

Medium 2: Fix the key (30 minutes)

Images are requested as /img/p1.jpg?session=abc, with a different session value for every user, 80,000 users a day. Describe what this does to the hit ratio. Write the better cache key. Show the number of copies per edge before and after.

Done when: a before and an after key, a count of copies, and one risk of dropping the parameter.

Hint

The session value is unique per user, so each user gets a separate copy.

Medium 3: Choose TTLs (30 minutes)

A site has a home page, app.5c1.js, a price list that changes hourly, a user's order history and product photos. Give a Cache-Control value for each and justify it.

Done when: five headers, each with a reason and the worst thing that happens if the TTL is wrong.

Hint

Build output with a fingerprint can last a year. Personal data cannot be shared.

Hard

Hard 1: Release plan (45 minutes)

Design the release steps for a new version of a script used by the home page. Use versioned names, short-lived HTML and a purge for the HTML only. Describe what a user sees during the switch, including a user who loaded the page just before it.

Done when: an ordered list of steps, a timeline, and the experience of the user caught in the middle.

Hint

Old pages must still find old files. Keep the old script until the old HTML is gone.

Hard 2: Shield or no shield (45 minutes)

There are 300 edges in 6 regions. A 50 MB file is released. Count the origin requests and the bytes sent by the origin with no shield, with one global shield and with six regional shields.

Done when: three counts of requests and bytes, and a recommendation with one trade-off.

Hint

Each fetch from the origin sends the whole file once.

Hard 3: When the CDN fails (50 minutes)

A shop serves 18 TB a day through a CDN at a 96 percent hit ratio, and the origin can deliver 1.2 Gbit/s. Suppose the CDN fails for an hour at peak, when traffic is 3 times the daily average. Work out whether the origin copes. Propose three steps to survive.

Done when: the average and peak rates, a verdict, and three steps with the effect of each.

Hint

Turn daily terabytes into gigabits per second first (divide by 86,400, multiply by 8), then apply the factor 3.