๐๏ธ 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.
- 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.
- 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.
- The stand keeps a stack of copies and hands one to Ana. The next reader on her road gets one without any runner.
- 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.
- 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.
- 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.
- A blog page comes from a partner printer across town. The stand treats it like any other page and keeps a stack.
- Ana asks for the map. The stand hasn't got it, so the runner fetches one, stamped good for an hour.
- 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.
- 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.
- A new page arrives with no stamp at all. The stand falls back on its own house rule and keeps it for a day.
- Ana asks for the menu in English. The stand writes "menu, English" on a shelf label, fetches it and starts a stack.
- Ben asks for the menu in French. That's a different page, so it gets its own label and its own stack.
- 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.
- 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.
- 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.
- Ana asks for the page and gets an old copy. The stand has no idea anything changed, because its stamp hasn't run out.
- 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.
- 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.
- Someone tries to walk straight into the storeroom and skip the stand. The door is locked, and they're turned away.
- Ana asks the stand for an open, unsealed page. The stand politely tells her to ask again for a sealed one.
- 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.
- 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.
- 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.
- Ana asks for a page that has moved. The helper tells her where it is now, without bothering the stand at all.
- 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.
- On the way out, the counter helper adds a note to the page reminding Ana to always ask for sealed pages next time.
- Ana asks for a page with an edition name. The workshop stamps it good for a year, because that edition will never change.
- 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.
- 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.