SlideShare une entreprise Scribd logo
1  sur  25
Hold until Told
Spreadshirt TechCamp 10/2018
Martin Breest
Using content tagging and purging
to get back control over
freshness of cached content at the edge
thereby improving performance and
resilience of your services
2
Why do we cache content with
Fastly at the edge anyway?
Comparison of uncached vs cached page load of
www.spreadshirt.com on desktop from London
4
Source: https://www.webpagetest.org/
Cached page starts ~1.5 seconds earlier to render
because of faster HTML delivery
5
Cached 1 second
Uncached 2.5 seconds
Source: https://www.webpagetest.org/
Without Fastly browser communicates with data center
in Dallas and retrieves uncached HTML
6
Data Center Dallas
Browser London
7644 km/ RTT ~105 ms for desktop
influences load time
>1000 ms page creation
influences wait time
Source: https://wondernetwork.com/pings/Dallas
With Fastly browser communicates with edge node in
London and retrieves cached HTML
7
Data Center Dallas +
Fastly Shield POP
Browser London +
Fastly Edge POP
RTT ~10 ms
-> >10 times faster
~20 ms cache page retrieval
-> >50 times faster
Source: https://wondernetwork.com/pings/Dallas
Distances in US are in general higher than in Europe
8
Dallas
Los Angeles
Seattle
New York
Miami
2703 km
RTT 52 ms
2235 km
RTT 43 ms
1991km
RTT 34 ms
1787km
RTT 29 ms
Frankfurt
Paris
477 km
RTT 17 ms
Source: https://wondernetwork.com/pings/Dallas
https://wondernetwork.com/pings/Frankfurt
Load and wait times are much lower with Fastly for
cached pages compared to uncached ones
9
Uncached Cached
Source: Catchpoint CDN vs Origin www.spreadshirt.com
Great! So why don‘t we cache
everything?
10
Area of tension between static and dynamic content
11
Dynamic Content Static Content
Type HTML, API data (JSON, XML)
User related content
CSS, JS, Images
Change Frequency Medium to High No or Low
Caching No Yes
Expiry Time Edge Node None High
Expiry Time Browser No or Low Medium to High
Control over Freshness High Low
Performance Low to Medium High
Resilience on Spikes Low High
Sometimes we sacrifice freshness to get better
performance and resilience
12
Low Expiry StrategyDynamic Content Static Content
Type HTML, API data (JSON,
XML)
User related content
HTML, API data
(JSON, XML)
CSS, JS, Images
Change Frequency Medium to High Medium No or Low
Caching No Yes Yes
Expiry Time Edge Node None Low to Medium High
Expiry Time Browser No or Low No or Low Medium to High
Control over Freshness High Low Low
Performance Low to Medium High High
Resilience on Spikes Low High High
Low expiry strategy is an exercise in your tolerance for
mistakes
13
„Using the low-expiry approach has never been an optimal
caching strategy since you sacrifice good caching to hopefully
minimize how long you may serve stale content. (Also, your
fingers probably really hurt from always keeping them crossed,
since choosing these low expiry times is essentially an exercise
in your tolerance for mistakes.)“
Hooman Beheshti, VP of Technology @ Fastly
Source: https://www.fastly.com/blog/leveraging-your-cdn-cache-uncacheable-content
Can‘t we just notify the cache if content
changes, like an inversion of control?
Good idea! Because most content is actually event-
driven!
15
Event-Driven ContentDynamic Content Static Content
Type HTML, API data (JSON,
XML)
User related content
HTML, API data
CSS, JS, Images
User related
content
CSS, JS, Images
Change Frequency Medium to High Low to Medium No or Low
Caching No Yes Yes
Expiry Time Edge Node None Medium High
Expiry Time Browser No or Low No or Low Medium to High
Purge on State Change No Yes No
Control over Freshness High High Low
Performance Low to Medium High High
Resilience on Spikes Low High High
How does it work? On first browser request content gets
cached with Fastly and subsequent requests get
delivered from cache.
16
Browser
Step 1 – Load homepage to cache:
R R
1. Request homepage 1.1. Request homepage
1.2. Cache homepage with
TTL of 24 houres
1.3. Cache homepage with
TTL of 60 seconds
Fastly Origin
Browser
Step 2 – A couple of seconds later ... deliver homepage from cache:
R
2. Request homepage
2.2. Get homepage from cache2.3. Cache homepage with
TTL of 60 seconds
Fastly
On state change origin uses Purge API to notify Fastly of
changes and subsequent request fetches new content
from origin.
17
Step 3 – A couple of hours later ... notify Fastly on homepage change:
R
3. Purge homepage
3.1. Mark homepage as stale or
delete homepage from cache
Step 4 – A few seconds later ... fetch latest homepage version from origin:
Fastly Origin
Browser
R R
4. Request homepage 4.1. Request homepage
4.2. Cache homepage with
TTL of 24 houres
4.3. Cache homepage with
TTL of 60 seconds
Fastly Origin
How does a purge request look like in Fastly?
18
Purge single entry
• PURGE https://www.spreadshirt.com
Purge all entries of a Fastly service (which handles www.spreadshirt.com for
example)
• POST https://api.fastly.com/service/SJ4xrdqVxxxxCFpF2FQ6i/purge_all
Request Header:
Fastly-Key: 05ce6d7d7293ebc35bb15135426d0000
Purges can easily be triggered from your application!
Thousands of purges can be triggered per minute!
Purges are really fast and run in ~150 ms!
Documentation: https://docs.fastly.com/api/purge
Got it! But what do I do in more a realistic
scenario with multiple resources involved?
19
Content tagging and tag-based purging to the rescue!
Content can be tagged with surrogate keys
• GET https://www.spreadshirt.com/hallowen+kids+premium+t-shirt-D1100053716?sellable=106995955 (article
detail page)
• GET https://image.spreadshirtmedia.com/image-
server/v1/mp/designs/1100053716,width=178,height=178/hallowen.png (design image)
• GET https://image.spreadshirtmedia.com/image-
server/v1/mp/products/T815A2MPA1659PT17X23Y24D1100053716S38/views/1,width=800,height=800,appeara
nceId=2,backgroundColor=E8E8E8,version=1516099426/hallowen-kids-premium-t-shirt.jpg (product image)
Response Header:
Surrogate-Key: d1100053716
Content can be purged using surrogate keys (tags)
• POST https://api.fastly.com/service/SU1Z0xxxxPaozGVKXdv0eY/purge
Request Header:
Surrogate-Key: d1100053716
Fastly-Key: 05ce6d4d7793ebc35bb15135426d0000
Documentation: https://docs.fastly.com/api/purge
And that is it!
21
Conclusion
22
• Fastly‘s Purge API with instant purge capabilities allows to avoid the low expiry
strategy and implement truly event-driven content, which allows to
 Cache dynamic content at edge nodes with medium expiry times
 Improve performance and resilience (and therefore user experience)
 Keep high control on content freshness (avoid stale data)
Is that all I need to know?
23
Actually, No!
24
• Implementing event-driven content, we also need to talk about
 State change triggers and how to implement them
 Revalidation between browser and edge node to keep traffic costs low
 Decomposition strategies to handle parts of a page with different change
policies
 Vary headers to deliver different cached content on the same URL
... but that is enough content for the next presentation ...
Thanks! Questions?
25

Contenu connexe

Tendances

Composing re-useable ETL on Hadoop
Composing re-useable ETL on HadoopComposing re-useable ETL on Hadoop
Composing re-useable ETL on Hadoop
Paul Lam
 

Tendances (20)

Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for Perl
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Building Scalable Websites with Perl
Building Scalable Websites with PerlBuilding Scalable Websites with Perl
Building Scalable Websites with Perl
 
Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
Performance in business terms
Performance in business termsPerformance in business terms
Performance in business terms
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
 
Caching the uncacheable with Varnish - DevDays 2021
Caching the uncacheable with Varnish - DevDays 2021Caching the uncacheable with Varnish - DevDays 2021
Caching the uncacheable with Varnish - DevDays 2021
 
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to EverythingWordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
WordCamp Ann Arbor 2014: Site Caching, From Nothing to Everything
 
Cache is keeping you from reaching the full potential as a developer (word ca...
Cache is keeping you from reaching the full potential as a developer (word ca...Cache is keeping you from reaching the full potential as a developer (word ca...
Cache is keeping you from reaching the full potential as a developer (word ca...
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to Profiling
 
Altitude SF 2017: The power of the network
Altitude SF 2017: The power of the networkAltitude SF 2017: The power of the network
Altitude SF 2017: The power of the network
 
Composing re-useable ETL on Hadoop
Composing re-useable ETL on HadoopComposing re-useable ETL on Hadoop
Composing re-useable ETL on Hadoop
 
Site Performance Optimization for Joomla #jwc13
Site Performance Optimization for Joomla #jwc13Site Performance Optimization for Joomla #jwc13
Site Performance Optimization for Joomla #jwc13
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013
 
AcornCache Presentation at Boston Ruby Group
AcornCache Presentation at Boston Ruby GroupAcornCache Presentation at Boston Ruby Group
AcornCache Presentation at Boston Ruby Group
 
Web performance optimization - MercadoLibre
Web performance optimization - MercadoLibreWeb performance optimization - MercadoLibre
Web performance optimization - MercadoLibre
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP MeetupWeb Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
 
Rest services caching
Rest services cachingRest services caching
Rest services caching
 
Connecting to Web Services on Android
Connecting to Web Services on AndroidConnecting to Web Services on Android
Connecting to Web Services on Android
 
WordPress Need For Speed
WordPress Need For SpeedWordPress Need For Speed
WordPress Need For Speed
 

Similaire à Spreadshirt Techcamp 2018 - Hold until Told

Csdn Drdobbs Tenni Theurer Yahoo
Csdn Drdobbs Tenni Theurer YahooCsdn Drdobbs Tenni Theurer Yahoo
Csdn Drdobbs Tenni Theurer Yahoo
guestb1b95b
 

Similaire à Spreadshirt Techcamp 2018 - Hold until Told (20)

Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
 
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
 
Altitude SF 2017: Optimizing your hit rate
Altitude SF 2017: Optimizing your hit rateAltitude SF 2017: Optimizing your hit rate
Altitude SF 2017: Optimizing your hit rate
 
Client Side Performance @ Xero
Client Side Performance @ XeroClient Side Performance @ Xero
Client Side Performance @ Xero
 
Web Server SEO: Making your TTFB faster!
Web Server SEO: Making your TTFB faster!Web Server SEO: Making your TTFB faster!
Web Server SEO: Making your TTFB faster!
 
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testing
 
AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)
 
MeasureWorks - Why people hate to wait for your website to load (and how to f...
MeasureWorks - Why people hate to wait for your website to load (and how to f...MeasureWorks - Why people hate to wait for your website to load (and how to f...
MeasureWorks - Why people hate to wait for your website to load (and how to f...
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Hacking Web Performance
Hacking Web Performance Hacking Web Performance
Hacking Web Performance
 
What is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress HostingWhat is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress Hosting
 
Amp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pagesAmp your site: An intro to accelerated mobile pages
Amp your site: An intro to accelerated mobile pages
 
Web Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger Bartel
Web Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger BartelWeb Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger Bartel
Web Performance in the Age of HTTP2 - Topconf Tallinn 2016 - Holger Bartel
 
Tips tricks deliver_high_performing_secure_web_pages
Tips tricks deliver_high_performing_secure_web_pagesTips tricks deliver_high_performing_secure_web_pages
Tips tricks deliver_high_performing_secure_web_pages
 
Csdn Drdobbs Tenni Theurer Yahoo
Csdn Drdobbs Tenni Theurer YahooCsdn Drdobbs Tenni Theurer Yahoo
Csdn Drdobbs Tenni Theurer Yahoo
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
Building Faster Websites
Building Faster WebsitesBuilding Faster Websites
Building Faster Websites
 
Super speed around the globe - SearchLeeds 2018
Super speed around the globe - SearchLeeds 2018Super speed around the globe - SearchLeeds 2018
Super speed around the globe - SearchLeeds 2018
 
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
 

Dernier

6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Dernier (20)

Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 

Spreadshirt Techcamp 2018 - Hold until Told

  • 1. Hold until Told Spreadshirt TechCamp 10/2018 Martin Breest
  • 2. Using content tagging and purging to get back control over freshness of cached content at the edge thereby improving performance and resilience of your services 2
  • 3. Why do we cache content with Fastly at the edge anyway?
  • 4. Comparison of uncached vs cached page load of www.spreadshirt.com on desktop from London 4 Source: https://www.webpagetest.org/
  • 5. Cached page starts ~1.5 seconds earlier to render because of faster HTML delivery 5 Cached 1 second Uncached 2.5 seconds Source: https://www.webpagetest.org/
  • 6. Without Fastly browser communicates with data center in Dallas and retrieves uncached HTML 6 Data Center Dallas Browser London 7644 km/ RTT ~105 ms for desktop influences load time >1000 ms page creation influences wait time Source: https://wondernetwork.com/pings/Dallas
  • 7. With Fastly browser communicates with edge node in London and retrieves cached HTML 7 Data Center Dallas + Fastly Shield POP Browser London + Fastly Edge POP RTT ~10 ms -> >10 times faster ~20 ms cache page retrieval -> >50 times faster Source: https://wondernetwork.com/pings/Dallas
  • 8. Distances in US are in general higher than in Europe 8 Dallas Los Angeles Seattle New York Miami 2703 km RTT 52 ms 2235 km RTT 43 ms 1991km RTT 34 ms 1787km RTT 29 ms Frankfurt Paris 477 km RTT 17 ms Source: https://wondernetwork.com/pings/Dallas https://wondernetwork.com/pings/Frankfurt
  • 9. Load and wait times are much lower with Fastly for cached pages compared to uncached ones 9 Uncached Cached Source: Catchpoint CDN vs Origin www.spreadshirt.com
  • 10. Great! So why don‘t we cache everything? 10
  • 11. Area of tension between static and dynamic content 11 Dynamic Content Static Content Type HTML, API data (JSON, XML) User related content CSS, JS, Images Change Frequency Medium to High No or Low Caching No Yes Expiry Time Edge Node None High Expiry Time Browser No or Low Medium to High Control over Freshness High Low Performance Low to Medium High Resilience on Spikes Low High
  • 12. Sometimes we sacrifice freshness to get better performance and resilience 12 Low Expiry StrategyDynamic Content Static Content Type HTML, API data (JSON, XML) User related content HTML, API data (JSON, XML) CSS, JS, Images Change Frequency Medium to High Medium No or Low Caching No Yes Yes Expiry Time Edge Node None Low to Medium High Expiry Time Browser No or Low No or Low Medium to High Control over Freshness High Low Low Performance Low to Medium High High Resilience on Spikes Low High High
  • 13. Low expiry strategy is an exercise in your tolerance for mistakes 13 „Using the low-expiry approach has never been an optimal caching strategy since you sacrifice good caching to hopefully minimize how long you may serve stale content. (Also, your fingers probably really hurt from always keeping them crossed, since choosing these low expiry times is essentially an exercise in your tolerance for mistakes.)“ Hooman Beheshti, VP of Technology @ Fastly Source: https://www.fastly.com/blog/leveraging-your-cdn-cache-uncacheable-content
  • 14. Can‘t we just notify the cache if content changes, like an inversion of control?
  • 15. Good idea! Because most content is actually event- driven! 15 Event-Driven ContentDynamic Content Static Content Type HTML, API data (JSON, XML) User related content HTML, API data CSS, JS, Images User related content CSS, JS, Images Change Frequency Medium to High Low to Medium No or Low Caching No Yes Yes Expiry Time Edge Node None Medium High Expiry Time Browser No or Low No or Low Medium to High Purge on State Change No Yes No Control over Freshness High High Low Performance Low to Medium High High Resilience on Spikes Low High High
  • 16. How does it work? On first browser request content gets cached with Fastly and subsequent requests get delivered from cache. 16 Browser Step 1 – Load homepage to cache: R R 1. Request homepage 1.1. Request homepage 1.2. Cache homepage with TTL of 24 houres 1.3. Cache homepage with TTL of 60 seconds Fastly Origin Browser Step 2 – A couple of seconds later ... deliver homepage from cache: R 2. Request homepage 2.2. Get homepage from cache2.3. Cache homepage with TTL of 60 seconds Fastly
  • 17. On state change origin uses Purge API to notify Fastly of changes and subsequent request fetches new content from origin. 17 Step 3 – A couple of hours later ... notify Fastly on homepage change: R 3. Purge homepage 3.1. Mark homepage as stale or delete homepage from cache Step 4 – A few seconds later ... fetch latest homepage version from origin: Fastly Origin Browser R R 4. Request homepage 4.1. Request homepage 4.2. Cache homepage with TTL of 24 houres 4.3. Cache homepage with TTL of 60 seconds Fastly Origin
  • 18. How does a purge request look like in Fastly? 18 Purge single entry • PURGE https://www.spreadshirt.com Purge all entries of a Fastly service (which handles www.spreadshirt.com for example) • POST https://api.fastly.com/service/SJ4xrdqVxxxxCFpF2FQ6i/purge_all Request Header: Fastly-Key: 05ce6d7d7293ebc35bb15135426d0000 Purges can easily be triggered from your application! Thousands of purges can be triggered per minute! Purges are really fast and run in ~150 ms! Documentation: https://docs.fastly.com/api/purge
  • 19. Got it! But what do I do in more a realistic scenario with multiple resources involved? 19
  • 20. Content tagging and tag-based purging to the rescue! Content can be tagged with surrogate keys • GET https://www.spreadshirt.com/hallowen+kids+premium+t-shirt-D1100053716?sellable=106995955 (article detail page) • GET https://image.spreadshirtmedia.com/image- server/v1/mp/designs/1100053716,width=178,height=178/hallowen.png (design image) • GET https://image.spreadshirtmedia.com/image- server/v1/mp/products/T815A2MPA1659PT17X23Y24D1100053716S38/views/1,width=800,height=800,appeara nceId=2,backgroundColor=E8E8E8,version=1516099426/hallowen-kids-premium-t-shirt.jpg (product image) Response Header: Surrogate-Key: d1100053716 Content can be purged using surrogate keys (tags) • POST https://api.fastly.com/service/SU1Z0xxxxPaozGVKXdv0eY/purge Request Header: Surrogate-Key: d1100053716 Fastly-Key: 05ce6d4d7793ebc35bb15135426d0000 Documentation: https://docs.fastly.com/api/purge
  • 21. And that is it! 21
  • 22. Conclusion 22 • Fastly‘s Purge API with instant purge capabilities allows to avoid the low expiry strategy and implement truly event-driven content, which allows to  Cache dynamic content at edge nodes with medium expiry times  Improve performance and resilience (and therefore user experience)  Keep high control on content freshness (avoid stale data)
  • 23. Is that all I need to know? 23
  • 24. Actually, No! 24 • Implementing event-driven content, we also need to talk about  State change triggers and how to implement them  Revalidation between browser and edge node to keep traffic costs low  Decomposition strategies to handle parts of a page with different change policies  Vary headers to deliver different cached content on the same URL ... but that is enough content for the next presentation ...