Quiz
Warm-up from lesson 4-2: what did enabling static website hosting on an S3 bucket replace?
Portfolio, docs, landing page
The production static-site stack is four pieces, three of them managed:
- S3 holds the built files (lesson 4-2).
- CloudFront is AWS's CDN (content delivery network): 400+ edge locations, small caches in cities worldwide. Visitors fetch from the nearest edge, which serves from its cache or pulls from your bucket once and remembers it. This kills both problems S3-alone has: latency for far-away users (lesson 1-2's speed-of-light problem) and it serves repeat traffic from cheaper edge bandwidth (lesson 8-1's meter 4).
- Certificate Manager issues the free TLS certificate, so the site is HTTPS.
- Route 53 (lesson 5-3) holds the DNS records, pointing
yoursite.devat the CloudFront distribution with an alias record.
Deploying is still aws s3 sync from lesson 4-2, plus telling CloudFront to drop its cached copies:
aws s3 sync ./build s3://my-portfolio
aws cloudfront create-invalidation --distribution-id E2ABC123 --paths "/*"Monthly cost for a typical portfolio: well under $1. There is no server to patch, no security group, nothing to wake you up.
Code exercise · bash
The number that makes a CDN work is the hit ratio: the share of requests the edge answers from cache without bothering S3. Run it for a typical static site at 95%, and note what it does to both latency (lesson 1-2) and the transfer meter (lesson 8-1).
Quiz
Your portfolio's images load in 40 ms for you in California but 300 ms for a friend in Singapore, straight from an us-west S3 bucket. Which piece of this architecture fixes that, and how?
Problem
Cost check on this architecture. The site's files total 1 GB in S3 at $0.023 per GB-month, and CloudFront's always-free tier covers all of its traffic. To the nearest cent, in cents, what is the monthly bill? (Digits only.)