SlideShare une entreprise Scribd logo
1  sur  208
Télécharger pour lire hors ligne
CloudFront
BEST PRACTICES & ANTI-PATTERNS
Abhishek Tiwari
@abhishektiwari
http://abhishek-tiwari.com
Wednesday, 7 August 13
About me
Wednesday, 7 August 13
About me
Solutions Architect
Wednesday, 7 August 13
About me
Solutions Architect
Early AWS adopter (2007)
Wednesday, 7 August 13
About me
Solutions Architect
Early AWS adopter (2007)
Built Cotton On Group’s AWS
Infrastructure (2012)
Wednesday, 7 August 13
Agenda
CloudFront in a nutshell
CloudFront Best Practices/Anti-Patterns
Wednesday, 7 August 13
CloudFront (CF)
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Serves Static and Dynamic Content
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Serves Static and Dynamic Content
Global, Redundant, Scalable
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Serves Static and Dynamic Content
Global, Redundant, Scalable
Low Latency, High Bandwidth
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Serves Static and Dynamic Content
Global, Redundant, Scalable
Low Latency, High Bandwidth
Cost Effective: Transparent, PAYG, Price
Classes
Wednesday, 7 August 13
CloudFront (CF)
Content Delivery Network
Serves Static and Dynamic Content
Global, Redundant, Scalable
Low Latency, High Bandwidth
Cost Effective: Transparent, PAYG, Price
Classes
NO Edge Side Includes (ESI)
Wednesday, 7 August 13
CF Concepts
Wednesday, 7 August 13
CF Concepts
Distribution
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Object/s (Object Path/Cache Key)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Object/s (Object Path/Cache Key)
Cache Behavior/s (1-10, 1:1, Ordered)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Object/s (Object Path/Cache Key)
Cache Behavior/s (1-10, 1:1, Ordered)
Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/
Query String Forwarding
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Object/s (Object Path/Cache Key)
Cache Behavior/s (1-10, 1:1, Ordered)
Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/
Query String Forwarding
Edge Location (42+)
Wednesday, 7 August 13
CF Concepts
Distribution
Delivery Method (Download or Streaming)
CNAME Aliases (1-10)
Origin Server/s (M:M)
Domain Name, Origin ID, Origin Protocol
Object/s (Object Path/Cache Key)
Cache Behavior/s (1-10, 1:1, Ordered)
Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/
Query String Forwarding
Edge Location (42+)
Viewer (GET, Range GET, HEAD Requests)
Wednesday, 7 August 13
CF Concepts
http://mycontent.cloudfront.net/photos/profile.png
Cache Key: photos/profile.png (Same for HTTP/HTTPS)
Cache Key:
object path relative to origin + forwarded query string/cookies
Wednesday, 7 August 13
CF Concepts
Dynamic Content
http://mycontent.cloudfront.net/photos/profile.png
Cache Key: photos/profile.png (Same for HTTP/HTTPS)
Cache Key:
object path relative to origin + forwarded query string/cookies
Wednesday, 7 August 13
CF Concepts
Dynamic Content
Static Content
http://mycontent.cloudfront.net/photos/profile.png
Cache Key: photos/profile.png (Same for HTTP/HTTPS)
Cache Key:
object path relative to origin + forwarded query string/cookies
Wednesday, 7 August 13
How it works
1. Client request file
2. If file in cache CF return file
Nearest Edge
Location
a. If file not in cache, CF request to origin
b. Origin returns file, status 200, cached in CF
1. Client request file
2. If file in cache CF return file
Nearest Edge
Location
a. If file in cache but expired, CF request to origin
b. Origin returns 304, CF keeps file in cache
Routing based on low latency/price class
Routing based on low latency/price class
Condition GET
Wednesday, 7 August 13
Distribution
Wednesday, 7 August 13
Distribution
Download Distribution
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Cookies/Query String Forwarding
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Cookies/Query String Forwarding
Streaming Distribution
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Cookies/Query String Forwarding
Streaming Distribution
Viewer Protocol: Adobe RTMP
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Cookies/Query String Forwarding
Streaming Distribution
Viewer Protocol: Adobe RTMP
Origin: S3 only (No Custom)
Wednesday, 7 August 13
Distribution
Download Distribution
Viewer Protocol HTTP/HTTPS
Origin: S3 or Custom
Cookies/Query String Forwarding
Streaming Distribution
Viewer Protocol: Adobe RTMP
Origin: S3 only (No Custom)
Dynamic/Adoptive Streaming (Adjust
bit rate during playback)
Wednesday, 7 August 13
Query String Forwarding
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b
http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b
http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a
Case sensitive: Two objects in CF
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b
http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a
Case sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?type=png
Wednesday, 7 August 13
Query String Forwarding
Forward query string to origin
Multiple parameters, order/case sensitive
Order sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b
http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a
Case sensitive: Two objects in CF
http://d111111abcdef8.cloudfront.net/images/image.jpg?type=png
http://d111111abcdef8.cloudfront.net/images/image.jpg?type=PNG
Wednesday, 7 August 13
Cookies Forwarding
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
If choose to forward cookies to origin,
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
If choose to forward cookies to origin,
Can forward all cookies, OR
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
If choose to forward cookies to origin,
Can forward all cookies, OR
Only specified cookies
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
If choose to forward cookies to origin,
Can forward all cookies, OR
Only specified cookies
Object path+FC uniquely identify in CF
Wednesday, 7 August 13
Cookies Forwarding
Forwarded cookies (FC): NV pairs, not attributes
If choose to forward cookies to origin,
Can forward all cookies, OR
Only specified cookies
Object path+FC uniquely identify in CF
NV pair/Case sensitive
Wednesday, 7 August 13
Origin
Wednesday, 7 August 13
Origin
S3 Origin: Best for Static media content
(Image, Video, Audio)
Wednesday, 7 August 13
Origin
S3 Origin: Best for Static media content
(Image, Video, Audio)
Custom Origin: Best for Static application
content (JS, CSS, Fonts)
Wednesday, 7 August 13
Origin
S3 Origin: Best for Static media content
(Image, Video, Audio)
Custom Origin: Best for Static application
content (JS, CSS, Fonts)
Custom Origin: Best for Dynamic media
content (HTML, Thumbnails)
Wednesday, 7 August 13
Make a note
Wednesday, 7 August 13
Make a note
Eventual Consistency
Wednesday, 7 August 13
Make a note
Eventual Consistency
10 Origin Servers per CF Distribution
Wednesday, 7 August 13
Make a note
Eventual Consistency
10 Origin Servers per CF Distribution
10 Cache Behavior per CF Distribution
Wednesday, 7 August 13
Make a note
Eventual Consistency
10 Origin Servers per CF Distribution
10 Cache Behavior per CF Distribution
10 CNAME per CF Distribution
Wednesday, 7 August 13
Make a note
Eventual Consistency
10 Origin Servers per CF Distribution
10 Cache Behavior per CF Distribution
10 CNAME per CF Distribution
10 Cookies forwarded per Cache Behavior
Wednesday, 7 August 13
Best Practices
Wednesday, 7 August 13
Best Practices
Versioning
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Domain Sharding
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Domain Sharding
Expiration
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Domain Sharding
Expiration
Bucket Organization
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Domain Sharding
Expiration
Bucket Organization
Logging
Wednesday, 7 August 13
Best Practices
Versioning
Compression
Domain Sharding
Expiration
Bucket Organization
Logging
Performance Testing
Wednesday, 7 August 13
Anti-Patterns
Cache Invalidation
Wednesday, 7 August 13
Cache Invalidation
Wednesday, 7 August 13
Cache Invalidation
Programmatic Cache Invalidation
Wednesday, 7 August 13
Cache Invalidation
Programmatic Cache Invalidation
Cache Invalidation is expensive
Wednesday, 7 August 13
Cache Invalidation
Programmatic Cache Invalidation
Cache Invalidation is expensive
Unmanageable if you have object dependencies
Wednesday, 7 August 13
Cache Invalidation
Programmatic Cache Invalidation
Cache Invalidation is expensive
Unmanageable if you have object dependencies
3 invalidation requests at any given time
Wednesday, 7 August 13
Cache Invalidation
Programmatic Cache Invalidation
Cache Invalidation is expensive
Unmanageable if you have object dependencies
3 invalidation requests at any given time
Each invalidation request can included
maximum of 1000 files
Wednesday, 7 August 13
Cache Invalidation
Wednesday, 7 August 13
Cache Invalidation
Invalidation takes time to propagate
across all edge locations (5-15 minutes)
Wednesday, 7 August 13
Cache Invalidation
Invalidation takes time to propagate
across all edge locations (5-15 minutes)
Deal breaker: browser cache
Wednesday, 7 August 13
Cache Invalidation
Invalidation takes time to propagate
across all edge locations (5-15 minutes)
Deal breaker: browser cache
Versioning is best way to avoid the
invalidation related issues
Wednesday, 7 August 13
Versioning
Wednesday, 7 August 13
Versioning
CF relies on Origin Servers for versioning
Wednesday, 7 August 13
Versioning
CF relies on Origin Servers for versioning
S3 supports versioning
Wednesday, 7 August 13
Versioning
CF relies on Origin Servers for versioning
S3 supports versioning
Version enabled Custom Origin
Wednesday, 7 August 13
Versioning
Wednesday, 7 August 13
Versioning
Versioning using query strings
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
File name as unique key based on file content /static/712vds57tr18929812312enb.png
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
File name as unique key based on file content /static/712vds57tr18929812312enb.png
Versioning using prefix/suffix
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
File name as unique key based on file content /static/712vds57tr18929812312enb.png
Versioning using prefix/suffix
File name with version prefix/suffix /static/profile_123.png
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
File name as unique key based on file content /static/712vds57tr18929812312enb.png
Versioning using prefix/suffix
File name with version prefix/suffix /static/profile_123.png
File name with version prefix/suffix /static/profile_ 712vds57tr18929812312enb.png
Wednesday, 7 August 13
Versioning
Versioning using query strings
File name plus query string with version /static/profile.png?versionID=123
Versioning using content based hash key
File name as unique key based on file content /static/712vds57tr18929812312enb.png
Versioning using prefix/suffix
File name with version prefix/suffix /static/profile_123.png
File name with version prefix/suffix /static/profile_ 712vds57tr18929812312enb.png
You can use a mixed versioning approach
Wednesday, 7 August 13
Versioning using query strings
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
profile.png
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
profile.png Upload to S3
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
profile.png Upload to S3 static/images/profile.png
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
profile.png Upload to S3 static/images/profile.png Return x-amz-version-id
Wednesday, 7 August 13
Versioning using query strings
CF supports versioning using query strings
forwarding
Versioning enabled Origin (Custom/S3)
For S3 Content
On object upload version enabled S3
bucket will return x-amz-version-id
profile.png Upload to S3 static/images/profile.png Return x-amz-version-id
static/images/profile.png?
versionId=644c69e148
Wednesday, 7 August 13
Versioning using query strings
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
Versionify
Wednesday, 7 August 13
Versioning using query strings
Versionify Application content
Use Build Number or Hash of GIT/HG Head
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
Versionify main.css?v=468df6b
main.js?v=468df6b
Wednesday, 7 August 13
Versioning using query strings
Wednesday, 7 August 13
Versioning using content based
hash key
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
profile.jpg
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
profile.jpg MD5 Hash File Name
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
profile.jpg MD5 Hash File Name b723eh0f0df.png
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
profile.jpg MD5 Hash File Name b723eh0f0df.png Upload to S3
Wednesday, 7 August 13
Versioning using content based
hash key
File name is an unique hash key
generated from file content (MD5)
For S3 content
Before uploading to S3 generate MD5 hash for
file
Use hash as file name to upload on S3
Avoid content duplication by comparing MD5
hashes
profile.jpg MD5 Hash File Name b723eh0f0df.png Upload to S3 static/images/b723eh0f0df.png
Wednesday, 7 August 13
Versioning using content based
hash key
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
MD5 Hash File Name
Wednesday, 7 August 13
Versioning using content based
hash key
For application content use a pipeline
file names generated using MD5 hash
of file content
photo.css, app.css, profile.css
photo.js, app.js, profile.js
Minify+Combine
main.css
main.js
MD5 Hash File Name
8972bw7dyf2h.css
67bfwu9hhuw.js
Wednesday, 7 August 13
Versioning using content based
hash key
Wednesday, 7 August 13
Compression
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
CF can serve both compressed and
uncompressed version of files
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
CF can serve both compressed and
uncompressed version of files
Depends on viewer or browser request
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
CF can serve both compressed and
uncompressed version of files
Depends on viewer or browser request
To receive compressed content browser must include Accept-Encoding: gzip in the request header
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
CF can serve both compressed and
uncompressed version of files
Depends on viewer or browser request
To receive compressed content browser must include Accept-Encoding: gzip in the request header
For compression CF relies on the custom
origin servers
Wednesday, 7 August 13
Compression
Compressed content is served faster
and uses less bandwidth
CF can serve both compressed and
uncompressed version of files
Depends on viewer or browser request
To receive compressed content browser must include Accept-Encoding: gzip in the request header
For compression CF relies on the custom
origin servers
S3 does not perform the compression
Wednesday, 7 August 13
Compression
Wednesday, 7 August 13
Compression
S3 can store both gzip and non-gzip
versions of the file in the same bucket
Wednesday, 7 August 13
Compression
S3 can store both gzip and non-gzip
versions of the file in the same bucket
When uploading gzip file to Amazon S3
set Content-Encoding to gzip
Wednesday, 7 August 13
Compression
S3 can store both gzip and non-gzip
versions of the file in the same bucket
When uploading gzip file to Amazon S3
set Content-Encoding to gzip
On-the-fly compression by custom
origin server (Nginx, Apache)
Wednesday, 7 August 13
Compression
S3 can store both gzip and non-gzip
versions of the file in the same bucket
When uploading gzip file to Amazon S3
set Content-Encoding to gzip
On-the-fly compression by custom
origin server (Nginx, Apache)
Compress: HTML, CSS, JS etc
Wednesday, 7 August 13
Compression
S3 can store both gzip and non-gzip
versions of the file in the same bucket
When uploading gzip file to Amazon S3
set Content-Encoding to gzip
On-the-fly compression by custom
origin server (Nginx, Apache)
Compress: HTML, CSS, JS etc
Compress Image: JPEG, WebP (Q= 0-100)
Wednesday, 7 August 13
Expiration
Wednesday, 7 August 13
Expiration
Use one/both of these
Wednesday, 7 August 13
Expiration
Use one/both of these
On Origin server set Cache-Control
max-age header
Wednesday, 7 August 13
Expiration
Use one/both of these
On Origin server set Cache-Control
max-age header
In Cache Behavior set Minimum TTL
Wednesday, 7 August 13
Expiration
Use one/both of these
On Origin server set Cache-Control
max-age header
In Cache Behavior set Minimum TTL
Date header/Age header (RFC 2616)
Wednesday, 7 August 13
Expiration
Use one/both of these
On Origin server set Cache-Control
max-age header
In Cache Behavior set Minimum TTL
Date header/Age header (RFC 2616)
Avoid Expire header
Wednesday, 7 August 13
Expiration
Wednesday, 7 August 13
Expiration
Browser cachability issues (known bug)
Wednesday, 7 August 13
Expiration
Browser cachability issues (known bug)
Set Cache-Control max-age or Minimum
TTL very far future
Wednesday, 7 August 13
Expiration
Browser cachability issues (known bug)
Set Cache-Control max-age or Minimum
TTL very far future
Depending on request frequency,
CloudFront might remove the object
before its expiration
Wednesday, 7 August 13
Expiration
Browser cachability issues (known bug)
Set Cache-Control max-age or Minimum
TTL very far future
Depending on request frequency,
CloudFront might remove the object
before its expiration
Default expiration 24hrs
Wednesday, 7 August 13
Expiration
Browser cachability issues (known bug)
Set Cache-Control max-age or Minimum
TTL very far future
Depending on request frequency,
CloudFront might remove the object
before its expiration
Default expiration 24hrs
Objects are cached for max {Cache-Control
max-age directive, Cache Behavior Minimum TTL}
Wednesday, 7 August 13
Domain Sharding
Wednesday, 7 August 13
Domain Sharding
To increase client side performance
Wednesday, 7 August 13
Domain Sharding
To increase client side performance
On average 100+ resources on an
ecommerce page
Wednesday, 7 August 13
Domain Sharding
To increase client side performance
On average 100+ resources on an
ecommerce page
Browsers limit the number of
simultaneous connections to one server
Wednesday, 7 August 13
Domain Sharding
To increase client side performance
On average 100+ resources on an
ecommerce page
Browsers limit the number of
simultaneous connections to one server
Hence limit the parallel download from
one server
Wednesday, 7 August 13
Domain Sharding
Wednesday, 7 August 13
Domain Sharding
Use two or more CNAME aliases to serve
the content from a CF distribution
Wednesday, 7 August 13
Domain Sharding
Use two or more CNAME aliases to serve
the content from a CF distribution
Browser treat them as different servers
Wednesday, 7 August 13
Domain Sharding
Use two or more CNAME aliases to serve
the content from a CF distribution
Browser treat them as different servers
Sharding across 2 CNAME aliases will
double the parallel download (Best 2-3)
Wednesday, 7 August 13
Domain Sharding
Use two or more CNAME aliases to serve
the content from a CF distribution
Browser treat them as different servers
Sharding across 2 CNAME aliases will
double the parallel download (Best 2-3)
More than 4 CNAME will degrade browser
performance (high CPU and memory uses)
Wednesday, 7 August 13
Domain Sharding
Wednesday, 7 August 13
Domain Sharding
Use CF CNAME alias feature
Wednesday, 7 August 13
Domain Sharding
Use CF CNAME alias feature
Use Route 53 for CNAME Aliasing
Wednesday, 7 August 13
Domain Sharding
Use CF CNAME alias feature
Use Route 53 for CNAME Aliasing
Custom Wild Card SSL Certificate
Wednesday, 7 August 13
Domain Sharding
Use CF CNAME alias feature
Use Route 53 for CNAME Aliasing
Custom Wild Card SSL Certificate
On application side: enable CF sharding
logic (template compilation etc)
Wednesday, 7 August 13
Domain Sharding
<span style="width:inherit;">
<a href="http://mysite.com/about"><img src="http://cf.mycloudfront.net/about.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/blogs"><img src="http://cf.mycloudfront.net/blogs.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/contact"><img src="http://cf.mycloudfront.net/cont.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/about"><img src="http://cf1.mycloudfront.net/about.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/blogs"><img src="http://cf2.mycloudfront.net/blogs.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/contact"><img src="http://cf1.mycloudfront.net/cont.jpg" alt=""/></
a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/about"><img src="{{ CDN_DOMAINS }}/about.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/blogs"><img src="{{ CDN_DOMAINS }}/blogs.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/contact"><img src="{{ CDN_DOMAINS }}/cont.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/about"><img src="http://mysite.com/about.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/blogs"><img src="http://mysite.com/blogs.jpg" alt=""/></a>
</span>
<span style="width:inherit;">
<a href="http://mysite.com/contact"><img src="http://mysite.com/cont.jpg" alt=""/></a>
</span>
CDN with domain shardingCDN without domain sharding
HTML Template
Without CDN
Compiled OR
DOM Manipulation
Compiled OR
DOM Manipulation
Wednesday, 7 August 13
Domain Sharding
Wednesday, 7 August 13
Domain Sharding
Wednesday, 7 August 13
Domain Sharding
Apply domain sharding only where it’s
needed most
Wednesday, 7 August 13
Domain Sharding
Apply domain sharding only where it’s
needed most
Evenly distribute the resources amongst
the shards
Wednesday, 7 August 13
Domain Sharding
Apply domain sharding only where it’s
needed most
Evenly distribute the resources amongst
the shards
Consider performance overhead due to
the DNS lookup and connection time
Wednesday, 7 August 13
Domain Sharding
Apply domain sharding only where it’s
needed most
Evenly distribute the resources amongst
the shards
Consider performance overhead due to
the DNS lookup and connection time
Sharding may not be good for Mobile
Browsers (CPU, Battery Life)
Wednesday, 7 August 13
Bucket Organisation
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Plan your bucket organisation (object keys)
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Plan your bucket organisation (object keys)
Watch out for the upload paths
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Plan your bucket organisation (object keys)
Watch out for the upload paths
/video/uploads/, /audio/uploads/, /images/uploads/ BAD
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Plan your bucket organisation (object keys)
Watch out for the upload paths
/video/uploads/, /audio/uploads/, /images/uploads/ BAD
/uploads/video/, /uploads/audio/, /uploads/image/ GOOD
Wednesday, 7 August 13
Bucket Organisation
Limited Cache Behavior per CF Distribution
Plan your bucket organisation (object keys)
Watch out for the upload paths
/video/uploads/, /audio/uploads/, /images/uploads/ BAD
/uploads/video/, /uploads/audio/, /uploads/image/ GOOD
Use wild card patterns (/uploads/*)
Wednesday, 7 August 13
Logging
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
One log file per distribution
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
One log file per distribution
Combine log files and analyze logs (EMR)
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
One log file per distribution
Combine log files and analyze logs (EMR)
W3C extended log file format
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
One log file per distribution
Combine log files and analyze logs (EMR)
W3C extended log file format
Streaming log vs Download log
Wednesday, 7 August 13
Logging
Enable logging, store access log file to S3
One log file per distribution
Combine log files and analyze logs (EMR)
W3C extended log file format
Streaming log vs Download log
Content Analytics: Popularity, Error etc
Wednesday, 7 August 13
Performance Testing
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
3rd party service (Gomez), application monitor
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
3rd party service (Gomez), application monitor
Load Testing (Edge Location, Elastic IP Aware)
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
3rd party service (Gomez), application monitor
Load Testing (Edge Location, Elastic IP Aware)
Clients request from different geolocations
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
3rd party service (Gomez), application monitor
Load Testing (Edge Location, Elastic IP Aware)
Clients request from different geolocations
Independent DNS request, different set of IPs
Wednesday, 7 August 13
Performance Testing
Tradition Load Testing not useful
Same DNS request, same set of IPs
Backbone Testing (Ideal Word)
CDN Server → Backbone
Last Mile (Real World, User Experience)
CDN Server → Backbone → Device
3rd party service (Gomez), application monitor
Load Testing (Edge Location, Elastic IP Aware)
Clients request from different geolocations
Independent DNS request, different set of IPs
Distribute load across set of IPs
Wednesday, 7 August 13
Thank You
Q & A
Wednesday, 7 August 13

Contenu connexe

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

CloudFront BEST PRACTICES & ANTI-PATTERNS

  • 1. CloudFront BEST PRACTICES & ANTI-PATTERNS Abhishek Tiwari @abhishektiwari http://abhishek-tiwari.com Wednesday, 7 August 13
  • 4. About me Solutions Architect Early AWS adopter (2007) Wednesday, 7 August 13
  • 5. About me Solutions Architect Early AWS adopter (2007) Built Cotton On Group’s AWS Infrastructure (2012) Wednesday, 7 August 13
  • 6. Agenda CloudFront in a nutshell CloudFront Best Practices/Anti-Patterns Wednesday, 7 August 13
  • 8. CloudFront (CF) Content Delivery Network Wednesday, 7 August 13
  • 9. CloudFront (CF) Content Delivery Network Serves Static and Dynamic Content Wednesday, 7 August 13
  • 10. CloudFront (CF) Content Delivery Network Serves Static and Dynamic Content Global, Redundant, Scalable Wednesday, 7 August 13
  • 11. CloudFront (CF) Content Delivery Network Serves Static and Dynamic Content Global, Redundant, Scalable Low Latency, High Bandwidth Wednesday, 7 August 13
  • 12. CloudFront (CF) Content Delivery Network Serves Static and Dynamic Content Global, Redundant, Scalable Low Latency, High Bandwidth Cost Effective: Transparent, PAYG, Price Classes Wednesday, 7 August 13
  • 13. CloudFront (CF) Content Delivery Network Serves Static and Dynamic Content Global, Redundant, Scalable Low Latency, High Bandwidth Cost Effective: Transparent, PAYG, Price Classes NO Edge Side Includes (ESI) Wednesday, 7 August 13
  • 16. CF Concepts Distribution Delivery Method (Download or Streaming) Wednesday, 7 August 13
  • 17. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Wednesday, 7 August 13
  • 18. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Wednesday, 7 August 13
  • 19. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Wednesday, 7 August 13
  • 20. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Object/s (Object Path/Cache Key) Wednesday, 7 August 13
  • 21. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Object/s (Object Path/Cache Key) Cache Behavior/s (1-10, 1:1, Ordered) Wednesday, 7 August 13
  • 22. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Object/s (Object Path/Cache Key) Cache Behavior/s (1-10, 1:1, Ordered) Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/ Query String Forwarding Wednesday, 7 August 13
  • 23. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Object/s (Object Path/Cache Key) Cache Behavior/s (1-10, 1:1, Ordered) Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/ Query String Forwarding Edge Location (42+) Wednesday, 7 August 13
  • 24. CF Concepts Distribution Delivery Method (Download or Streaming) CNAME Aliases (1-10) Origin Server/s (M:M) Domain Name, Origin ID, Origin Protocol Object/s (Object Path/Cache Key) Cache Behavior/s (1-10, 1:1, Ordered) Path Patterns, Origin ID, Viewer Protocol, Minimum TTL, Cookies/ Query String Forwarding Edge Location (42+) Viewer (GET, Range GET, HEAD Requests) Wednesday, 7 August 13
  • 25. CF Concepts http://mycontent.cloudfront.net/photos/profile.png Cache Key: photos/profile.png (Same for HTTP/HTTPS) Cache Key: object path relative to origin + forwarded query string/cookies Wednesday, 7 August 13
  • 26. CF Concepts Dynamic Content http://mycontent.cloudfront.net/photos/profile.png Cache Key: photos/profile.png (Same for HTTP/HTTPS) Cache Key: object path relative to origin + forwarded query string/cookies Wednesday, 7 August 13
  • 27. CF Concepts Dynamic Content Static Content http://mycontent.cloudfront.net/photos/profile.png Cache Key: photos/profile.png (Same for HTTP/HTTPS) Cache Key: object path relative to origin + forwarded query string/cookies Wednesday, 7 August 13
  • 28. How it works 1. Client request file 2. If file in cache CF return file Nearest Edge Location a. If file not in cache, CF request to origin b. Origin returns file, status 200, cached in CF 1. Client request file 2. If file in cache CF return file Nearest Edge Location a. If file in cache but expired, CF request to origin b. Origin returns 304, CF keeps file in cache Routing based on low latency/price class Routing based on low latency/price class Condition GET Wednesday, 7 August 13
  • 31. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Wednesday, 7 August 13
  • 32. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Wednesday, 7 August 13
  • 33. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Cookies/Query String Forwarding Wednesday, 7 August 13
  • 34. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Cookies/Query String Forwarding Streaming Distribution Wednesday, 7 August 13
  • 35. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Cookies/Query String Forwarding Streaming Distribution Viewer Protocol: Adobe RTMP Wednesday, 7 August 13
  • 36. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Cookies/Query String Forwarding Streaming Distribution Viewer Protocol: Adobe RTMP Origin: S3 only (No Custom) Wednesday, 7 August 13
  • 37. Distribution Download Distribution Viewer Protocol HTTP/HTTPS Origin: S3 or Custom Cookies/Query String Forwarding Streaming Distribution Viewer Protocol: Adobe RTMP Origin: S3 only (No Custom) Dynamic/Adoptive Streaming (Adjust bit rate during playback) Wednesday, 7 August 13
  • 39. Query String Forwarding Forward query string to origin Wednesday, 7 August 13
  • 40. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Wednesday, 7 August 13
  • 41. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF Wednesday, 7 August 13
  • 42. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b Wednesday, 7 August 13
  • 43. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a Wednesday, 7 August 13
  • 44. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a Case sensitive: Two objects in CF Wednesday, 7 August 13
  • 45. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a Case sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?type=png Wednesday, 7 August 13
  • 46. Query String Forwarding Forward query string to origin Multiple parameters, order/case sensitive Order sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?height=a&width=b http://d111111abcdef8.cloudfront.net/images/image.jpg?width=b&height=a Case sensitive: Two objects in CF http://d111111abcdef8.cloudfront.net/images/image.jpg?type=png http://d111111abcdef8.cloudfront.net/images/image.jpg?type=PNG Wednesday, 7 August 13
  • 48. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes Wednesday, 7 August 13
  • 49. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes If choose to forward cookies to origin, Wednesday, 7 August 13
  • 50. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes If choose to forward cookies to origin, Can forward all cookies, OR Wednesday, 7 August 13
  • 51. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes If choose to forward cookies to origin, Can forward all cookies, OR Only specified cookies Wednesday, 7 August 13
  • 52. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes If choose to forward cookies to origin, Can forward all cookies, OR Only specified cookies Object path+FC uniquely identify in CF Wednesday, 7 August 13
  • 53. Cookies Forwarding Forwarded cookies (FC): NV pairs, not attributes If choose to forward cookies to origin, Can forward all cookies, OR Only specified cookies Object path+FC uniquely identify in CF NV pair/Case sensitive Wednesday, 7 August 13
  • 55. Origin S3 Origin: Best for Static media content (Image, Video, Audio) Wednesday, 7 August 13
  • 56. Origin S3 Origin: Best for Static media content (Image, Video, Audio) Custom Origin: Best for Static application content (JS, CSS, Fonts) Wednesday, 7 August 13
  • 57. Origin S3 Origin: Best for Static media content (Image, Video, Audio) Custom Origin: Best for Static application content (JS, CSS, Fonts) Custom Origin: Best for Dynamic media content (HTML, Thumbnails) Wednesday, 7 August 13
  • 58. Make a note Wednesday, 7 August 13
  • 59. Make a note Eventual Consistency Wednesday, 7 August 13
  • 60. Make a note Eventual Consistency 10 Origin Servers per CF Distribution Wednesday, 7 August 13
  • 61. Make a note Eventual Consistency 10 Origin Servers per CF Distribution 10 Cache Behavior per CF Distribution Wednesday, 7 August 13
  • 62. Make a note Eventual Consistency 10 Origin Servers per CF Distribution 10 Cache Behavior per CF Distribution 10 CNAME per CF Distribution Wednesday, 7 August 13
  • 63. Make a note Eventual Consistency 10 Origin Servers per CF Distribution 10 Cache Behavior per CF Distribution 10 CNAME per CF Distribution 10 Cookies forwarded per Cache Behavior Wednesday, 7 August 13
  • 70. Best Practices Versioning Compression Domain Sharding Expiration Bucket Organization Logging Wednesday, 7 August 13
  • 71. Best Practices Versioning Compression Domain Sharding Expiration Bucket Organization Logging Performance Testing Wednesday, 7 August 13
  • 74. Cache Invalidation Programmatic Cache Invalidation Wednesday, 7 August 13
  • 75. Cache Invalidation Programmatic Cache Invalidation Cache Invalidation is expensive Wednesday, 7 August 13
  • 76. Cache Invalidation Programmatic Cache Invalidation Cache Invalidation is expensive Unmanageable if you have object dependencies Wednesday, 7 August 13
  • 77. Cache Invalidation Programmatic Cache Invalidation Cache Invalidation is expensive Unmanageable if you have object dependencies 3 invalidation requests at any given time Wednesday, 7 August 13
  • 78. Cache Invalidation Programmatic Cache Invalidation Cache Invalidation is expensive Unmanageable if you have object dependencies 3 invalidation requests at any given time Each invalidation request can included maximum of 1000 files Wednesday, 7 August 13
  • 80. Cache Invalidation Invalidation takes time to propagate across all edge locations (5-15 minutes) Wednesday, 7 August 13
  • 81. Cache Invalidation Invalidation takes time to propagate across all edge locations (5-15 minutes) Deal breaker: browser cache Wednesday, 7 August 13
  • 82. Cache Invalidation Invalidation takes time to propagate across all edge locations (5-15 minutes) Deal breaker: browser cache Versioning is best way to avoid the invalidation related issues Wednesday, 7 August 13
  • 84. Versioning CF relies on Origin Servers for versioning Wednesday, 7 August 13
  • 85. Versioning CF relies on Origin Servers for versioning S3 supports versioning Wednesday, 7 August 13
  • 86. Versioning CF relies on Origin Servers for versioning S3 supports versioning Version enabled Custom Origin Wednesday, 7 August 13
  • 88. Versioning Versioning using query strings Wednesday, 7 August 13
  • 89. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Wednesday, 7 August 13
  • 90. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key Wednesday, 7 August 13
  • 91. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key File name as unique key based on file content /static/712vds57tr18929812312enb.png Wednesday, 7 August 13
  • 92. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key File name as unique key based on file content /static/712vds57tr18929812312enb.png Versioning using prefix/suffix Wednesday, 7 August 13
  • 93. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key File name as unique key based on file content /static/712vds57tr18929812312enb.png Versioning using prefix/suffix File name with version prefix/suffix /static/profile_123.png Wednesday, 7 August 13
  • 94. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key File name as unique key based on file content /static/712vds57tr18929812312enb.png Versioning using prefix/suffix File name with version prefix/suffix /static/profile_123.png File name with version prefix/suffix /static/profile_ 712vds57tr18929812312enb.png Wednesday, 7 August 13
  • 95. Versioning Versioning using query strings File name plus query string with version /static/profile.png?versionID=123 Versioning using content based hash key File name as unique key based on file content /static/712vds57tr18929812312enb.png Versioning using prefix/suffix File name with version prefix/suffix /static/profile_123.png File name with version prefix/suffix /static/profile_ 712vds57tr18929812312enb.png You can use a mixed versioning approach Wednesday, 7 August 13
  • 96. Versioning using query strings Wednesday, 7 August 13
  • 97. Versioning using query strings CF supports versioning using query strings forwarding Wednesday, 7 August 13
  • 98. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) Wednesday, 7 August 13
  • 99. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content Wednesday, 7 August 13
  • 100. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id Wednesday, 7 August 13
  • 101. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id profile.png Wednesday, 7 August 13
  • 102. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id profile.png Upload to S3 Wednesday, 7 August 13
  • 103. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id profile.png Upload to S3 static/images/profile.png Wednesday, 7 August 13
  • 104. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id profile.png Upload to S3 static/images/profile.png Return x-amz-version-id Wednesday, 7 August 13
  • 105. Versioning using query strings CF supports versioning using query strings forwarding Versioning enabled Origin (Custom/S3) For S3 Content On object upload version enabled S3 bucket will return x-amz-version-id profile.png Upload to S3 static/images/profile.png Return x-amz-version-id static/images/profile.png? versionId=644c69e148 Wednesday, 7 August 13
  • 106. Versioning using query strings Wednesday, 7 August 13
  • 107. Versioning using query strings Versionify Application content Wednesday, 7 August 13
  • 108. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head Wednesday, 7 August 13
  • 109. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head photo.css, app.css, profile.css photo.js, app.js, profile.js Wednesday, 7 August 13
  • 110. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine Wednesday, 7 August 13
  • 111. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js Wednesday, 7 August 13
  • 112. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js Versionify Wednesday, 7 August 13
  • 113. Versioning using query strings Versionify Application content Use Build Number or Hash of GIT/HG Head photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js Versionify main.css?v=468df6b main.js?v=468df6b Wednesday, 7 August 13
  • 114. Versioning using query strings Wednesday, 7 August 13
  • 115. Versioning using content based hash key Wednesday, 7 August 13
  • 116. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) Wednesday, 7 August 13
  • 117. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Wednesday, 7 August 13
  • 118. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Wednesday, 7 August 13
  • 119. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Wednesday, 7 August 13
  • 120. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes Wednesday, 7 August 13
  • 121. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes profile.jpg Wednesday, 7 August 13
  • 122. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes profile.jpg MD5 Hash File Name Wednesday, 7 August 13
  • 123. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes profile.jpg MD5 Hash File Name b723eh0f0df.png Wednesday, 7 August 13
  • 124. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes profile.jpg MD5 Hash File Name b723eh0f0df.png Upload to S3 Wednesday, 7 August 13
  • 125. Versioning using content based hash key File name is an unique hash key generated from file content (MD5) For S3 content Before uploading to S3 generate MD5 hash for file Use hash as file name to upload on S3 Avoid content duplication by comparing MD5 hashes profile.jpg MD5 Hash File Name b723eh0f0df.png Upload to S3 static/images/b723eh0f0df.png Wednesday, 7 August 13
  • 126. Versioning using content based hash key Wednesday, 7 August 13
  • 127. Versioning using content based hash key For application content use a pipeline Wednesday, 7 August 13
  • 128. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content Wednesday, 7 August 13
  • 129. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content photo.css, app.css, profile.css photo.js, app.js, profile.js Wednesday, 7 August 13
  • 130. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine Wednesday, 7 August 13
  • 131. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js Wednesday, 7 August 13
  • 132. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js MD5 Hash File Name Wednesday, 7 August 13
  • 133. Versioning using content based hash key For application content use a pipeline file names generated using MD5 hash of file content photo.css, app.css, profile.css photo.js, app.js, profile.js Minify+Combine main.css main.js MD5 Hash File Name 8972bw7dyf2h.css 67bfwu9hhuw.js Wednesday, 7 August 13
  • 134. Versioning using content based hash key Wednesday, 7 August 13
  • 136. Compression Compressed content is served faster and uses less bandwidth Wednesday, 7 August 13
  • 137. Compression Compressed content is served faster and uses less bandwidth CF can serve both compressed and uncompressed version of files Wednesday, 7 August 13
  • 138. Compression Compressed content is served faster and uses less bandwidth CF can serve both compressed and uncompressed version of files Depends on viewer or browser request Wednesday, 7 August 13
  • 139. Compression Compressed content is served faster and uses less bandwidth CF can serve both compressed and uncompressed version of files Depends on viewer or browser request To receive compressed content browser must include Accept-Encoding: gzip in the request header Wednesday, 7 August 13
  • 140. Compression Compressed content is served faster and uses less bandwidth CF can serve both compressed and uncompressed version of files Depends on viewer or browser request To receive compressed content browser must include Accept-Encoding: gzip in the request header For compression CF relies on the custom origin servers Wednesday, 7 August 13
  • 141. Compression Compressed content is served faster and uses less bandwidth CF can serve both compressed and uncompressed version of files Depends on viewer or browser request To receive compressed content browser must include Accept-Encoding: gzip in the request header For compression CF relies on the custom origin servers S3 does not perform the compression Wednesday, 7 August 13
  • 143. Compression S3 can store both gzip and non-gzip versions of the file in the same bucket Wednesday, 7 August 13
  • 144. Compression S3 can store both gzip and non-gzip versions of the file in the same bucket When uploading gzip file to Amazon S3 set Content-Encoding to gzip Wednesday, 7 August 13
  • 145. Compression S3 can store both gzip and non-gzip versions of the file in the same bucket When uploading gzip file to Amazon S3 set Content-Encoding to gzip On-the-fly compression by custom origin server (Nginx, Apache) Wednesday, 7 August 13
  • 146. Compression S3 can store both gzip and non-gzip versions of the file in the same bucket When uploading gzip file to Amazon S3 set Content-Encoding to gzip On-the-fly compression by custom origin server (Nginx, Apache) Compress: HTML, CSS, JS etc Wednesday, 7 August 13
  • 147. Compression S3 can store both gzip and non-gzip versions of the file in the same bucket When uploading gzip file to Amazon S3 set Content-Encoding to gzip On-the-fly compression by custom origin server (Nginx, Apache) Compress: HTML, CSS, JS etc Compress Image: JPEG, WebP (Q= 0-100) Wednesday, 7 August 13
  • 149. Expiration Use one/both of these Wednesday, 7 August 13
  • 150. Expiration Use one/both of these On Origin server set Cache-Control max-age header Wednesday, 7 August 13
  • 151. Expiration Use one/both of these On Origin server set Cache-Control max-age header In Cache Behavior set Minimum TTL Wednesday, 7 August 13
  • 152. Expiration Use one/both of these On Origin server set Cache-Control max-age header In Cache Behavior set Minimum TTL Date header/Age header (RFC 2616) Wednesday, 7 August 13
  • 153. Expiration Use one/both of these On Origin server set Cache-Control max-age header In Cache Behavior set Minimum TTL Date header/Age header (RFC 2616) Avoid Expire header Wednesday, 7 August 13
  • 155. Expiration Browser cachability issues (known bug) Wednesday, 7 August 13
  • 156. Expiration Browser cachability issues (known bug) Set Cache-Control max-age or Minimum TTL very far future Wednesday, 7 August 13
  • 157. Expiration Browser cachability issues (known bug) Set Cache-Control max-age or Minimum TTL very far future Depending on request frequency, CloudFront might remove the object before its expiration Wednesday, 7 August 13
  • 158. Expiration Browser cachability issues (known bug) Set Cache-Control max-age or Minimum TTL very far future Depending on request frequency, CloudFront might remove the object before its expiration Default expiration 24hrs Wednesday, 7 August 13
  • 159. Expiration Browser cachability issues (known bug) Set Cache-Control max-age or Minimum TTL very far future Depending on request frequency, CloudFront might remove the object before its expiration Default expiration 24hrs Objects are cached for max {Cache-Control max-age directive, Cache Behavior Minimum TTL} Wednesday, 7 August 13
  • 161. Domain Sharding To increase client side performance Wednesday, 7 August 13
  • 162. Domain Sharding To increase client side performance On average 100+ resources on an ecommerce page Wednesday, 7 August 13
  • 163. Domain Sharding To increase client side performance On average 100+ resources on an ecommerce page Browsers limit the number of simultaneous connections to one server Wednesday, 7 August 13
  • 164. Domain Sharding To increase client side performance On average 100+ resources on an ecommerce page Browsers limit the number of simultaneous connections to one server Hence limit the parallel download from one server Wednesday, 7 August 13
  • 166. Domain Sharding Use two or more CNAME aliases to serve the content from a CF distribution Wednesday, 7 August 13
  • 167. Domain Sharding Use two or more CNAME aliases to serve the content from a CF distribution Browser treat them as different servers Wednesday, 7 August 13
  • 168. Domain Sharding Use two or more CNAME aliases to serve the content from a CF distribution Browser treat them as different servers Sharding across 2 CNAME aliases will double the parallel download (Best 2-3) Wednesday, 7 August 13
  • 169. Domain Sharding Use two or more CNAME aliases to serve the content from a CF distribution Browser treat them as different servers Sharding across 2 CNAME aliases will double the parallel download (Best 2-3) More than 4 CNAME will degrade browser performance (high CPU and memory uses) Wednesday, 7 August 13
  • 171. Domain Sharding Use CF CNAME alias feature Wednesday, 7 August 13
  • 172. Domain Sharding Use CF CNAME alias feature Use Route 53 for CNAME Aliasing Wednesday, 7 August 13
  • 173. Domain Sharding Use CF CNAME alias feature Use Route 53 for CNAME Aliasing Custom Wild Card SSL Certificate Wednesday, 7 August 13
  • 174. Domain Sharding Use CF CNAME alias feature Use Route 53 for CNAME Aliasing Custom Wild Card SSL Certificate On application side: enable CF sharding logic (template compilation etc) Wednesday, 7 August 13
  • 175. Domain Sharding <span style="width:inherit;"> <a href="http://mysite.com/about"><img src="http://cf.mycloudfront.net/about.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/blogs"><img src="http://cf.mycloudfront.net/blogs.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/contact"><img src="http://cf.mycloudfront.net/cont.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/about"><img src="http://cf1.mycloudfront.net/about.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/blogs"><img src="http://cf2.mycloudfront.net/blogs.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/contact"><img src="http://cf1.mycloudfront.net/cont.jpg" alt=""/></ a> </span> <span style="width:inherit;"> <a href="http://mysite.com/about"><img src="{{ CDN_DOMAINS }}/about.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/blogs"><img src="{{ CDN_DOMAINS }}/blogs.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/contact"><img src="{{ CDN_DOMAINS }}/cont.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/about"><img src="http://mysite.com/about.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/blogs"><img src="http://mysite.com/blogs.jpg" alt=""/></a> </span> <span style="width:inherit;"> <a href="http://mysite.com/contact"><img src="http://mysite.com/cont.jpg" alt=""/></a> </span> CDN with domain shardingCDN without domain sharding HTML Template Without CDN Compiled OR DOM Manipulation Compiled OR DOM Manipulation Wednesday, 7 August 13
  • 178. Domain Sharding Apply domain sharding only where it’s needed most Wednesday, 7 August 13
  • 179. Domain Sharding Apply domain sharding only where it’s needed most Evenly distribute the resources amongst the shards Wednesday, 7 August 13
  • 180. Domain Sharding Apply domain sharding only where it’s needed most Evenly distribute the resources amongst the shards Consider performance overhead due to the DNS lookup and connection time Wednesday, 7 August 13
  • 181. Domain Sharding Apply domain sharding only where it’s needed most Evenly distribute the resources amongst the shards Consider performance overhead due to the DNS lookup and connection time Sharding may not be good for Mobile Browsers (CPU, Battery Life) Wednesday, 7 August 13
  • 183. Bucket Organisation Limited Cache Behavior per CF Distribution Wednesday, 7 August 13
  • 184. Bucket Organisation Limited Cache Behavior per CF Distribution Plan your bucket organisation (object keys) Wednesday, 7 August 13
  • 185. Bucket Organisation Limited Cache Behavior per CF Distribution Plan your bucket organisation (object keys) Watch out for the upload paths Wednesday, 7 August 13
  • 186. Bucket Organisation Limited Cache Behavior per CF Distribution Plan your bucket organisation (object keys) Watch out for the upload paths /video/uploads/, /audio/uploads/, /images/uploads/ BAD Wednesday, 7 August 13
  • 187. Bucket Organisation Limited Cache Behavior per CF Distribution Plan your bucket organisation (object keys) Watch out for the upload paths /video/uploads/, /audio/uploads/, /images/uploads/ BAD /uploads/video/, /uploads/audio/, /uploads/image/ GOOD Wednesday, 7 August 13
  • 188. Bucket Organisation Limited Cache Behavior per CF Distribution Plan your bucket organisation (object keys) Watch out for the upload paths /video/uploads/, /audio/uploads/, /images/uploads/ BAD /uploads/video/, /uploads/audio/, /uploads/image/ GOOD Use wild card patterns (/uploads/*) Wednesday, 7 August 13
  • 190. Logging Enable logging, store access log file to S3 Wednesday, 7 August 13
  • 191. Logging Enable logging, store access log file to S3 One log file per distribution Wednesday, 7 August 13
  • 192. Logging Enable logging, store access log file to S3 One log file per distribution Combine log files and analyze logs (EMR) Wednesday, 7 August 13
  • 193. Logging Enable logging, store access log file to S3 One log file per distribution Combine log files and analyze logs (EMR) W3C extended log file format Wednesday, 7 August 13
  • 194. Logging Enable logging, store access log file to S3 One log file per distribution Combine log files and analyze logs (EMR) W3C extended log file format Streaming log vs Download log Wednesday, 7 August 13
  • 195. Logging Enable logging, store access log file to S3 One log file per distribution Combine log files and analyze logs (EMR) W3C extended log file format Streaming log vs Download log Content Analytics: Popularity, Error etc Wednesday, 7 August 13
  • 197. Performance Testing Tradition Load Testing not useful Wednesday, 7 August 13
  • 198. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Wednesday, 7 August 13
  • 199. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) Wednesday, 7 August 13
  • 200. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Wednesday, 7 August 13
  • 201. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) Wednesday, 7 August 13
  • 202. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device Wednesday, 7 August 13
  • 203. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device 3rd party service (Gomez), application monitor Wednesday, 7 August 13
  • 204. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device 3rd party service (Gomez), application monitor Load Testing (Edge Location, Elastic IP Aware) Wednesday, 7 August 13
  • 205. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device 3rd party service (Gomez), application monitor Load Testing (Edge Location, Elastic IP Aware) Clients request from different geolocations Wednesday, 7 August 13
  • 206. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device 3rd party service (Gomez), application monitor Load Testing (Edge Location, Elastic IP Aware) Clients request from different geolocations Independent DNS request, different set of IPs Wednesday, 7 August 13
  • 207. Performance Testing Tradition Load Testing not useful Same DNS request, same set of IPs Backbone Testing (Ideal Word) CDN Server → Backbone Last Mile (Real World, User Experience) CDN Server → Backbone → Device 3rd party service (Gomez), application monitor Load Testing (Edge Location, Elastic IP Aware) Clients request from different geolocations Independent DNS request, different set of IPs Distribute load across set of IPs Wednesday, 7 August 13
  • 208. Thank You Q & A Wednesday, 7 August 13