13.3 Global Content & Service Distribution: CloudFront & Global Accelerator
Key Takeaways
- Amazon CloudFront accelerates content delivery across 600+ Edge Locations and Regional Edge Caches, with Origin Shield providing an optional centralized caching tier that consolidates cache misses and reduces origin load and egress fees.
- Origin Access Control (OAC) replaces legacy OAI, supporting SSE-KMS encryption with customer managed keys, dynamic HTTP methods (PUT/POST/DELETE), and all AWS Regions through SigV4 signing.
- Cache Policies define the Cache Key (headers, cookies, query strings) and TTL parameters to maximize cache hit ratios, while Origin Request Policies pass viewer headers to origins without fragmenting the cache.
- CloudFront Functions deliver sub-millisecond, lightweight JavaScript execution at 600+ Edge Locations for viewer header rewrites and cache key normalization, whereas Lambda@Edge runs full Node.js/Python at Regional Edge Caches for heavy compute and network calls.
- AWS Global Accelerator uses Anycast static IP addresses to route TCP/UDP traffic directly onto the AWS global private fiber network without caching, taking an unhealthy endpoint out of service in less than one minute for multi-Region failover.
13.3 Global Content & Service Distribution: CloudFront & Global Accelerator
CloudOps Blueprint Focus: The AWS Certified CloudOps Engineer – Associate (SOA-C03) exam tests your ability to optimize global application performance, secure origin infrastructure, and design high-availability delivery architectures. CloudOps engineers must master Amazon CloudFront edge topology, protect origins using Origin Access Control (OAC) with KMS encryption, optimize caching efficiency using Cache and Origin Request policies, implement edge compute (CloudFront Functions vs. Lambda@Edge), and differentiate between CloudFront and AWS Global Accelerator for non-HTTP and static IP workloads.
Amazon CloudFront Global Architecture
Amazon CloudFront is a global Content Delivery Network (CDN) service that securely delivers data, videos, applications, and APIs to users with low latency and high transfer speeds. CloudFront terminates TLS connections close to viewers and caches content across a multi-tier global infrastructure:
- Points of Presence (PoPs) / Edge Locations: More than 600 geographically distributed Points of Presence located in major metropolitan areas worldwide. Edge locations terminate viewer connections, inspect TLS certificates, evaluate AWS WAF rules, run CloudFront Functions, and serve cached responses.
- Regional Edge Caches (REC): A mid-tier caching layer deployed across approximately 13 core AWS Regions. Regional Edge Caches possess significantly larger storage capacities than individual edge locations. When an edge location experiences a cache miss, it queries its nearest Regional Edge Cache before forwarding the request to the origin. RECs retain less frequently requested long-tail content, preventing cache evictions and reducing origin fetch volume.
- Distribution Types: CloudFront supports Web Distributions delivering HTTP/1.1, HTTP/2, and HTTP/3 (over QUIC). Legacy RTMP distributions for streaming media are fully deprecated.
Origins & Origin Shielding
CloudFront acts as a reverse proxy in front of one or more Origins:
- Supported Origins: Amazon S3 buckets, Elastic Load Balancers (ALB/NLB), Amazon EC2 instances, AWS Elemental MediaStore, Amazon API Gateway, or custom on-premises web servers.
- Origin Groups & Failover: CloudFront supports Origin Groups containing a primary origin and a secondary origin. If the primary origin returns specific HTTP error status codes (e.g., 500, 502, 503, 504, or connection timeouts), CloudFront automatically fails over to the secondary origin.
Amazon CloudFront Origin Shield
When an application experiences high global request volumes across dozens of edge locations simultaneously, multiple edge locations and RECs may fetch the exact same object from the origin concurrently (the "thundering herd" phenomenon), causing origin performance degradation and high cross-region data transfer fees.
Origin Shield is an additional, centralized caching layer that you explicitly configure within the Regional Edge Cache closest to your origin:
- All cache misses from every edge location and Regional Edge Cache worldwide are routed through this single Origin Shield REC.
- The Origin Shield REC consolidates requests, serves cached content, and forwards only a single request to the origin for any cache miss.
- Operational Benefits: Origin Shield dramatically increases cache hit ratios, protects backend databases and application servers from traffic spikes, and minimizes cross-region data transfer egress costs.
+---------------------------------------------------------------------------------------------------+
| CLOUDFRONT MULTI-TIER CACHING TOPOLOGY |
| |
| Global Viewers |
| | |
| v |
| +-------------------------------------------------------------+ |
| | Edge Locations (600+ Global PoPs) | <-- Runs CloudFront Functions |
| | (Viewer TLS Termination, Caching, AWS WAF inspection) | |
| +------------------------------+------------------------------+ |
| | Cache Miss |
| v |
| +-------------------------------------------------------------+ |
| | Regional Edge Caches (RECs - 13 Global Hubs) | <-- Runs Lambda@Edge |
| | (Large-capacity caching for long-tail assets) | |
| +------------------------------+------------------------------+ |
| | Cache Miss |
| v |
| +-------------------------------------------------------------+ |
| | ORIGIN SHIELD (Designated Central REC) | <-- Consolidates global fetches |
| +------------------------------+------------------------------+ |
| | Single Origin Fetch |
| v |
| +-------------------------------------------------------------+ |
| | ORIGIN INFRASTRUCTURE (Amazon S3 / Application Load Balancer)| |
| +-------------------------------------------------------------+ |
+---------------------------------------------------------------------------------------------------+
Origin Access Control (OAC) vs. Legacy Origin Access Identity (OAI)
When using Amazon S3 as a CloudFront origin, public read access on the bucket must be completely disabled. To ensure that users access objects strictly through CloudFront, AWS previously used Origin Access Identity (OAI), which is now legacy and deprecated in favor of Origin Access Control (OAC).
Why OAI Is Deprecated
- No KMS CMK Support: OAI cannot download S3 objects encrypted with AWS KMS Customer Managed Keys (SSE-KMS); it only supports default SSE-S3 encryption.
- HTTP Method Limitations: OAI is restricted strictly to
GETandHEADrequests; it does not supportPUT,POST, orDELETEmethods. - Regional Incompatibility: OAI cannot be used in AWS Regions launched after December 2022 (e.g.,
ap-south-2,eu-central-2,me-central-1).
Origin Access Control (OAC) Capabilities
- Comprehensive Region Support: Supports all AWS Regions, both current and future.
- SSE-KMS Encryption Support: OAC natively passes the CloudFront distribution identity and AWS Signature Version 4 (SigV4) headers to AWS KMS, allowing CloudFront to decrypt S3 objects protected by Customer Managed Keys.
- Dynamic HTTP Methods: Fully supports dynamic writes (
PUT,POST,PATCH,DELETE) to S3. - Granular Least Privilege: Integrates with AWS IAM resource policies using service principals and explicit condition keys.
Configuring OAC with S3 Bucket Policies & KMS
To implement OAC, the CloudOps engineer creates an OAC profile in CloudFront, attaches it to the S3 origin, and configures an S3 Bucket Policy granting access exclusively to the CloudFront distribution ARN via aws:SourceArn:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipalReadOnly",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::corp-production-assets/*",
"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:cloudfront::111122223333:distribution/EDFDVBD6EXAMPLE"
}
}
}
]
}
If the S3 bucket is encrypted using an AWS KMS Customer Managed Key, the KMS key policy must also authorize the CloudFront service principal:
{
"Sid": "AllowCloudFrontKMSDecryption",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": ["kms:Decrypt", "kms:GenerateDataKey*"],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:cloudfront::111122223333:distribution/EDFDVBD6EXAMPLE"
}
}
}
Cache Policies vs. Origin Request Policies
In modern CloudFront architectures, request processing behavior is decomposed into distinct, reusable policies:
Cache Policies
A Cache Policy defines what values from a viewer request are included in the Cache Key, as well as the object's Time-To-Live (TTL):
- Cache Key Elements: Headers, Cookies, and Query Strings. If an element is included in the cache key, CloudFront stores separate cached variations of the object for each distinct combination of values.
- Golden Rule of Caching: Minimize cache key parameters. Including unnecessary headers (e.g.,
User-Agent) creates thousands of unique cache keys for identical files, causing cache fragmentation and plummeting the Cache Hit Ratio to near zero. - TTL Configuration: Defines Minimum TTL, Maximum TTL, and Default TTL (used when the origin does not return
Cache-Controlheaders).
Origin Request Policies
An Origin Request Policy determines which viewer request headers, cookies, and query strings are forwarded to the origin on a cache miss, without including them in the Cache Key:
- Operational Power: Allows backend application servers to receive critical context (such as viewer device headers, custom authorization headers, or user session cookies) while maintaining a clean, unfragmented Cache Key.
Response Headers Policies
A Response Headers Policy instructs CloudFront to inject HTTP headers into the response sent to viewers without altering origin code. It is the architectural standard for enforcing security headers (such as Strict-Transport-Security [HSTS], Content-Security-Policy [CSP], and X-Frame-Options) and managing Cross-Origin Resource Sharing (CORS).
Edge Compute: CloudFront Functions vs. Lambda@Edge
CloudFront provides two serverless compute options at the edge to customize content delivery, enforce security, and manipulate HTTP traffic.
| Architectural Dimension | CloudFront Functions | Lambda@Edge |
|---|---|---|
| Runtime & Language | Lightweight JavaScript (ECMAScript 5.1 compliant) | Node.js and Python |
| Execution Location | 600+ CloudFront Edge Locations | ~13 Regional Edge Caches (RECs) |
| Event Triggers | Viewer Request, Viewer Response | Viewer Request, Origin Request, Origin Response, Viewer Response |
| Execution Latency | Sub-millisecond (< 1 ms); immediate start | Milliseconds to seconds (cold start possible) |
| Maximum Execution Time | 1 millisecond | 5 seconds (viewer triggers) / 30 seconds (origin triggers) |
| Maximum Memory | 2 MB | 128 MB to 10,240 MB (10 GB) |
| Network & Filesystem Access | None (isolated sandbox; cannot make HTTP calls) | Full access (network calls to VPC/internet APIs, /tmp disk) |
| Request Body Access | No access | Full access (read and modify request/response bodies) |
| Cost Profile | Extremely low cost (~1/6th of Lambda@Edge); millions of RPS | Standard serverless pricing based on duration and memory |
| Primary Use Cases | URL rewrites/redirects, cache key normalization, header manipulation | Heavy authorization (JWT/OAuth), dynamic origin routing, SSR, image resizing |
AWS Global Accelerator vs. Amazon CloudFront
Both services leverage AWS's global network infrastructure to improve application performance, but they solve fundamentally different operational problems.
AWS Global Accelerator Architecture
- Static Anycast IP Addresses: Global Accelerator provisions two static Anycast IPv4 addresses that act as fixed entry points for your application worldwide.
- Private Backbone Ingress: Anycast routes client traffic to the topologically closest AWS edge location. From the edge, traffic enters the AWS private fiber-optic backbone network directly, bypassing congested public internet transit providers.
- Direct Protocol Routing: Global Accelerator routes traffic directly to endpoints (Application Load Balancers, Network Load Balancers, or EC2 instances) across one or more AWS Regions.
- Zero Caching: Global Accelerator does not cache any content. It is purely a Layer 4 (TCP/UDP) and Layer 7 network transport accelerator.
Architectural Decision Matrix
| Architectural Requirement | Amazon CloudFront | AWS Global Accelerator |
|---|---|---|
| Primary Protocol Support | Layer 7 only: HTTP, HTTPS, WebSockets | Layer 4 & Layer 7: TCP, UDP, HTTP, HTTPS |
| Content Caching | Yes (caches static and dynamic content at edge) | No (pure network path optimization) |
| IP Address Management | Dynamic IP addresses (DNS-driven; IPs change) | 2 Static Anycast IPv4 addresses (fixed) |
| Firewall Whitelisting | Difficult (requires subscribing to AWS IP ranges) | Seamless (fixed static IPs for client firewalls) |
| Disaster Recovery Failover | DNS TTL-dependent or Origin Groups | Health-check driven; AWS states an unhealthy endpoint is taken out of service in less than one minute, with no client DNS cache dependency |
| Client IP Address Preservation | Passes client IP in X-Forwarded-For header | Natively preserves client IP address to ALB/EC2 |
| Best Workloads | Static media, web APIs, video streaming | Non-HTTP apps, gaming (UDP), VoIP, IoT, fixed IP APIs |
A media streaming company stores private video assets in an Amazon S3 bucket. The assets are encrypted at rest using an AWS KMS Customer Managed Key (SSE-KMS). The company must distribute these assets globally through Amazon CloudFront while ensuring that: (1) users can only access videos through CloudFront, (2) video uploads using HTTP PUT requests are permitted through CloudFront, and (3) CloudFront can successfully decrypt and fetch the KMS-encrypted objects. How should the CloudOps engineer configure this origin security architecture?
An e-commerce platform experiences high traffic volumes exceeding 100,000 requests per second at peak. The operations team needs to implement two edge processing functions on viewer requests: (1) normalize incoming URLs by converting paths to lowercase and stripping marketing query parameters before the cache lookup, and (2) redirect legacy URL paths to new catalog endpoints with an HTTP 301 response. The solution must execute with sub-millisecond latency at the lowest possible cost, without requiring external network access or request body inspection. Which edge compute mechanism should be selected?
A global real-time multiplayer gaming company hosts game servers running on Amazon EC2 instances across multiple AWS Regions. The gaming client communicates using a custom low-latency UDP protocol. Corporate enterprise firewall policies at several university campuses and gaming centers require client traffic to be sent to fixed, unchanging public IP addresses. Furthermore, if an AWS Region experiences network impairment, client traffic must fail over to a healthy secondary Region without depending on client-side DNS cache expiry. Which AWS service fulfills these requirements?