AWS CloudFront
AWS CloudFront
AWS CloudFront -
- AWS Content Delivery Network (CDN) service that delivers data, videos, applications, and APIs to users globally with low latency and high transfer speeds
- 216 points of presence globally (edge location)
- Integrates with other AWS services products to give developers and businesses easy way to distribute contents to end-users with low latency, high data transfer speed and no minimum usage commitments
- DDOS protection, integration with shield, AWS WAF (Web Application Firewall)
Content Delivery Security -
- CloudFront can distribute content securely over SSL/TLS by creating an HTTPS or WebSocket SSL/TLS connection with the viewer
- Supports HTTP/2, WebSocket, and all versions SSL/TLS
- Provides multiple SSL/TLS certificates to enhance security using server name indication (SNI)
CloudFront Origins -
CloudFront can fetch content from various AWS resources like S3 bucket, ELB or EC2
- S3 Bucket -
- For distributing files and caching them at the edge
- Enhanced security with CloudFront Origin Access Control (OAC)
- OAC is replacing Origin Access Identity (OAI)
- CloudFront can be used as an ingress (to upload files to S3)
- Custom Origin (HTTP) -
- Application Load Balancer
- EC2
- S3 website (must first enables the bucket as a static S3 website)
- Any HTTP backend you want
How CloudFront works -
CloudFront S3 as an Origin -
CloudFront vs S3 Cross Region Replication -
- CloudFront -
- Global edge network
- File are cached for TTL (Time To Leave)
- Great for static content that must be availabe everywhere
- S3 Cross Region Replication -
- Must be setup for each region you want replication to happen
- Files are updated in near real time
- Read only
- Great for dynamic content that needs to be available at low-latency in few regions
CloudFront - ALB or EC2 as an Origin -
CloudFront Geo Restriction -
- You can restrict who can access your distribution
- Allowlist: Allow your users to access your content only if they are in one of the countries on a list of approved countries
- Blocklist: Prevent your users from accessing your content if they are in one of the countries on a list of banned countries
- The "country" is determined using a 3rd party Geo-IP database
- Use case - Copyright laws to control access to content
CloudFront - Pricing -
- CloudFront edge location are all around the world
- The cost of data out per edge location varies
- Price Class All : all regions - best performance
- Price Class 200 : most regoins, but excludes the most expensive regoins
- Price Class 100 : Only the least expensive regoins
CloudFront - Cache Invalidations -
- In case you update the back-end origin, CloudFront doesn't know about it and will get the refreshed content after the TTL has expired
- However, you can force an entire or partial cache refresh (thus by passing the TTL) by performing a CloudFront Invalidation
- You can invalidate all files (*) or a special path (/images/*)
Best Practices of CloudFront -
- Versioning - Use version numbers or adding date-time in file or directory names
- Optimize the default cache behaviour - Ensure that the default cache behaviour is is set to handle the majority of requests
- Use CloudFront compression feature - Compress content to reduce the amount of data transffered
- Security content - Use signed URLs or signed cookies for restricted contents
- Monitoring and logging - Regularly monitor CloudFront metrics and set up alarms in cloudwatch also enable access logs to track users requests
Comments
Post a Comment