TwiceToldby Develoker
ConceptsSystem designLabsCheat sheetsAbout

Develoker makes free tools for learning to build software. TwiceTold explains each idea twice, as an everyday analogy and the real thing; CloudArch lets you design cloud systems and put load on them.

About ยท Labs ยท Cheat sheets ยท Learning paths

โ† Back to Amazon CloudFront

๐Ÿ—ž๏ธ Amazon CloudFront: cheat sheet

๐ŸŽจ The analogyA newsstand in every neighbourhood, sending a runner to the print works only when its copy is missing or stale.
๐ŸŽ“ The regular explanationAWS's content delivery network. Edge locations around the world cache copies of responses from your origins, such as an S3 bucket or a load balancer, so viewers are served from nearby and the origin does less work.
Edge locations and the originStep 4 of 4
๐Ÿง‘Ana๐Ÿง”Ben๐ŸชAna's newsstandhas the logo๐ŸชBen's newsstandhas the logo๐ŸญPrint works
  1. Without any stands, Ana has to ask the print works itself, far away in another country. Every page makes the long trip there and back.
  2. Now there's a newsstand down Ana's road. She asks there instead. It hasn't got the page yet, so it sends a runner to the print works.
  3. The stand keeps a stack of copies and hands one to Ana. The next reader on her road gets one without any runner.
  4. Ben lives on the other side of the world, so he asks his own stand. That stand has its own stack, so it sends its own runner the first time.
Origins and cache behaviorsStep 3 of 3
๐Ÿญ The print works๐Ÿง‘Ana๐ŸชNewsstand๐Ÿ“ฆStoreroompictures๐Ÿง‘โ€๐Ÿ’ผOrder desknot kept๐Ÿ–จ๏ธPartner printerblog pages
  1. Ana asks for a picture. The stand's list says pictures come from the storeroom, so that's where the runner goes, and the stand keeps a stack.
  2. Then she asks for her own receipt. The list says receipts come from the order desk, and since a receipt is made for one reader, the stand never keeps a stack.
  3. A blog page comes from a partner printer across town. The stand treats it like any other page and keeps a stack.
Hits, misses and TTLsStep 4 of 4
๐Ÿง‘Ana๐Ÿง”Ben๐ŸชNewsstandhouse rule 24h๐ŸญPrint worksno stamp
  1. Ana asks for the map. The stand hasn't got it, so the runner fetches one, stamped good for an hour.
  2. Ben asks for the same map ten minutes later. The stand hands him a copy from the stack, and the print works never hears about it.
  3. After the hour, the stamp has run out. The stand asks the print works if the map is still the latest. It is, so a quick yes is enough and the stack gets a new stamp.
  4. A new page arrives with no stamp at all. The stand falls back on its own house rule and keeps it for a day.
The cache keyStep 4 of 4
Stacks by shelf labelenkey /menu.html?lang=en: en0frkey /menu.html?lang=fr: fr1a3key /menu.html?lang=en + session a3: a3โœฆโœฆโœฆโœฆโœฆ2b7key /menu.html?lang=en + session b7: b7โœฆโœฆโœฆโœฆโœฆ345๐Ÿง‘Ana๐Ÿง”Ben๐ŸชNewsstandalmost no hits๐ŸญPrint works
  1. Ana asks for the menu in English. The stand writes "menu, English" on a shelf label, fetches it and starts a stack.
  2. Ben asks for the menu in French. That's a different page, so it gets its own label and its own stack.
  3. Ana comes back from an advert, and her slip also says which advert. The stand ignores that part, finds the English stack and hands her a copy.
  4. If the stand put each reader's own name on the label, every reader would get a stack of one, and the runner would be out for nearly everyone.
Invalidations versus versioned namesStep 4 of 4
๐Ÿง‘Ana๐Ÿง‘โ€๐Ÿ’ปYou, the publisher๐ŸชNewsstand Aapp.3f9c.js 1 year๐ŸชNewsstand B๐ŸญPrint worksapp.3f9c.js
  1. You fix a mistake and send the new page to the print works under the same old name. Both stands still have stacks of the old one.
  2. Ana asks for the page and gets an old copy. The stand has no idea anything changed, because its stamp hasn't run out.
  3. You send every stand a recall notice. After a short while they all bin their old copies, and the next reader gets a fresh one.
  4. The smarter way is to print the new page as edition 7 with a new name. No stand has ever stocked it, so the first reader's stand fetches it, and nobody needs a recall.
A private bucket behind HTTPSStep 4 of 4
staff pass๐Ÿง‘Ana๐Ÿ•ต๏ธBack-door visitor๐ŸชNewsstandID card๐Ÿ“ฆLocked storeroomprivate
  1. Someone tries to walk straight into the storeroom and skip the stand. The door is locked, and they're turned away.
  2. Ana asks the stand for an open, unsealed page. The stand politely tells her to ask again for a sealed one.
  3. She asks again for a sealed page. The stand shows its ID card, which proves it really works for the print works, and they agree a seal nobody else can open.
  4. The stand's runner shows the staff pass. The storeroom checks it belongs to these stands, opens the door and hands over the page, sealed all the way to Ana.
Edge functionsStep 4 of 4
๐Ÿง‘Ana๐Ÿ™‹Counter helper+ seal note๐ŸชNewsstand๐Ÿ“žDepot helperpicked origin๐ŸญPrint works
  1. Ana asks for "the docs". The counter helper knows that means the docs' front page and fixes the slip before the stand looks for it.
  2. Ana asks for a page that has moved. The helper tells her where it is now, without bothering the stand at all.
  3. The stand hasn't got the page, so before the runner leaves, the slower helper at the district depot makes a phone call to decide which door to use.
  4. On the way out, the counter helper adds a note to the page reminding Ana to always ask for sealed pages next time.
The origin sets the stampsStep 3 of 3
๐Ÿง‘Anakept 1 min๐ŸชNewsstandkept 10 min๐ŸญYour workshopfront page short
  1. Ana asks for a page with an edition name. The workshop stamps it good for a year, because that edition will never change.
  2. The front page gets a "check every time" stamp, so the stand asks the workshop whether it's still the latest before handing it out.
  3. A product price gets two stamps, one for the stand and one for Ana. The stand may keep it ten minutes, but Ana should ask again after one.

๐Ÿงฉ Key questions

Ana's stand handed out the map a minute ago. Ben asks a stand in another country for the same map. What happens?
Ben's stand sends its own runner to the print works, because each stand keeps its own stacks. Every stand starts with no stack of a page, so the first reader at each stand causes one runner trip.
You fix a page and send it to the print works under the same name, but readers still get the old one. Why?
The stands' old copies are still within their good-until stamp. Changing the print works doesn't touch the stacks. Send a recall notice, or better, give the new page a new name.
The stand starts putting each reader's own name on the shelf label. What happens?
Nearly every reader gets a stack of one, so the runner goes to the print works almost every time. Only put on the label what really changes the page, like the language.
How does the storeroom make sure readers can only get pages through the stands?
It keeps the door locked and only opens for runners carrying these stands' staff pass. A hidden address can still be found, and sealed slips protect the trip, not the door. The staff pass is what keeps the storeroom closed.