I want my Amazon CloudFront distribution to handle increased traffic, unexpected traffic, and illegitimate traffic for an upcoming live streaming event. I also want to maintain my distribution’s security.
Resolution
Optimize the distribution settings for your live streaming workloads
To optimize caching and content delivery for live streams, configure cache behavior settings such as path pattern, viewer protocol policy, and allowed HTTP methods. You can also configure the option to cache based on selected request headers.
To control how long CloudFront caches objects, configure cache control headers, such as Cache-Control: max-age and Cache-Control: no-cache, at the origin.
You can also increase the minimum time to live (TTL) value for the cache behaviors that serve your live streams. This adjustment reduces the traffic load on your origin. CloudFront edge caches can then serve more requests.
For faster downloads, you can serve compressed files. To restrict the applications that can view your data, use field-level encryption.
Scale and provision your origin's infrastructure
To handle anticipated traffic spikes, configure additional origin servers or load balancers based on your requirements. Make sure that you scale your origin's infrastructure to handle the expected load.
Implement security measures
To protect against distributed denial of service (DDoS) attacks or other security threats during your live streaming event, use the following best practices:
- Integrate AWS WAF with your distribution to use rate limiting rules that reduce high request rates from bots or illegitimate traffic.
- Use AWS WAF Bot Control to differentiate between beneficial bots, such as search engine crawlers, and harmful bots that scrape content or perform malicious activities.
- Use AWS Shield Advanced to receive enhanced DDoS attack protection for your CloudFront distribution and origin resources.
For information about costs, see AWS Shield Pricing and AWS WAF Pricing.
Activate real-time logs on your critical distributions
Use real-time logs on your critical distributions to monitor traffic patterns and quickly identify issues.
Test and validate your distribution
Before your live streaming event, test your distribution and origin infrastructure under simulated high-traffic conditions to address potential issues or bottlenecks. For a list of a best practices, see Load testing CloudFront.
Optimize content delivery and availability
Use geographic restrictions and origin failover to optimize content delivery and availability based on the requirements of your live streaming event.
Manage unexpected traffic spikes
If you experience unexpected traffic spikes or illegitimate traffic during your live streaming event, then take the following actions:
- Check the User-Agent and c-ip field in your CloudFront logs to identify suspicious or illegitimate traffic patterns. Then, configure AWS WAF rules based on your log analysis.
- Use Amazon CloudFront Origin Shield to add a caching layer between the origin server and your distribution to reduce the load on your origin.
Forecast expected traffic
Before the event, forecast the expected traffic load as precisely as possible.
Create a support case before your live streaming event to notify AWS Support or your Technical Account Manager (TAM) about your traffic forecast. In the case summary, estimate your bandwidth requirements and how many peak requests per second you expect during your live event. Also, include the distribution IDs that you plan to use during the event.
Monitor your distributions during the event
During the event, closely monitor your distributions for cache matches, cache misses, total requests, total transferred data, error rates, and other metrics. If you notice performance degradation or unexpected traffic spikes, then adjust your configurations.
Related information
Deliver video streaming with CloudFront and AWS Media Services
Monitor CloudFront metrics with Amazon CloudWatch