SlideShare uma empresa Scribd logo
1 de 29
HIGH PERFORMANCE
SITES WITH DRUPAL
AND CACHE CONTROL
MODULE
Janne Salo
Senior Developer
Outline
 Exove in brief
 What is Cache Control and how does it work?
 Easy case: Jatkoaika.com
 Anonymous users, high read/write ratio
 Hard case: Demi.fi
 Autheticated users, low read/write ratio
 Different case: Tekla Campus
 Using Cache Control with a CDN
 Discussion
Exove in Brief
ExoveisaleadingNorthernEuropeancompanyspecialisinginopen
sourcewebservicesdesignanddevelopment.
WehelpcompaniesconductbetterbusinessontheInternet
throughbest-of-breedpersonnelandsolutions.
Quickfacts:
 Founded2006
 About60people
 Servedmorethan120clients
 OfficesinFinland,Estonia,andtheUK
 CEOJanneKalliola
 Meetusatbooth38
WHAT IS CACHE CONTROL
AND HOW DOES IT WORK?
drupal.org/project/cache_control
What is Cache Control?
 Module for integrating your site with Varnish or
some other HTTP cache
 Sets appropriate Cache-Control headers in HTTP
responses from Drupal.
 Supports also content purging
 Automatic purges for e.g. node updates, hooks for
custom purges
 Comes with an admin UI for selecting cacheable
menu router paths and a VCLfile for Varnish
How does it work?
 Varnish checks if requested page is cached
 If it is, Varnish sends it to user’s browser (also for
authenticated users!)
 If it isn’t, pass the request to Drupal, execute the page
load as anonymous user and cache the response in
Varnish
 Process the response in user’s browser
 For anonymous users, show the page as is
 For authenticated users, generate personalized parts in
anAJAX back-end (get_components) and inject the
results on the page
“Personalized content?”
 You can enable Cache Control for any Drupal
block – the block will be generated for
authenticated users in the get_components
back-end
 Using Cache Control’sAPI, you can “tag” any
part of the page to be generated for in the
get_components back-end
Benefits of Cache Control
 Only the needed parts are loaded: The back-
end is significantly less burdened
 All personalized parts of the are loaded in a
single request
 The user is given something to look at while the
hard parts of the page are being loaded – the
site feels faster
What’s the catch?
 Building high-performance sites is a complex
matter. Cache Control is not a magic bullet to
solve all your performance issues
 While developing, you have to “think in Cache
Control” or you’ll be in a world of trouble
 You will most likely end up writing at least some
custom code and spending time wondering why the
site behaves differently when Cache Control is
enabled
What about ESI?
 ESI (Edge Side Includes) is a partial loading
technique supported by Varnish and some CDNs,
e.g.Akamai
 It basically makes Varnish do the partial page
loading
 Varnish first fetches the common version from cache
 Then it looks though the page to see any ESI markup
 Then it loads all the ESI marked parts of the page from
cache or from Drupal
How does Cache Control
differ from ESI?
 ESI needs to wait until the whole page is loaded
before giving anything to the user
 ESI loads all the portions of the page (still in D7,
this might change in D8) in separate HTTP
requests, thus burdening the server with even
more bootstraps than without any cache
THE EASY CASE
Jatkoaika.com
 Jatkoaika.com is the leading ice hockey site in
Finland
 200 000 unique visitors and 1.6M page loads per
week
 Page loads in Drupal are almost exclusively
done by anonymous users
 Content is read a lot more often than
written, making the site an ideal use case for
Cache Control
Jatkoaika.com – Setup
 Drupal, MySQL, SOLR, memcached, Varnish –
all running on one server
 Cache Control enabled for all content pages
(nodes, taxonomy terms, front page) with
different TTLs – no custom code required
 Server loads are minimal
THE HARD CASE
Demi.fi
 Demi.fi is the community around the Demi
magazine, targeted to teenage girls
 2.8M weekly page views
 Most page loads done by authenticated users
 1 300 – 1 500 logged-in users during busy hours
 The users generate a lot of content (forum
posts, comments, etc.)
 Keeping the cache up to date is a challenge
Demi.fi – Setup
 Drupal, MySQL (Percona), SOLR, MongoDB, nginx
+ php-fpm, memcached, Varnish – all running on
(almost) one server
 Cache Control enabled for almost all user-facing
pages and someAJAX backends as well
 Alot of personalized components per page, putting strain
on the get_components back-end
 Quite a lot custom code required in making the site
compatible and triggering cache purges when needed.
 Server loads are significant but mostly tolerable
Demi.fi – Strategy
 Avoid Drupal bootstrap and theming
 Cache Control: try to keep as much content in
Varnish cache as possible
 Fast JSON-based backends for data that changes
often (e.g. forum topic listings): offload theming to
users’browsers. Use Cache Control to cache the
results with shortTTL(30 secs or so)
 Use fast storage: SOLR for Views, MongoDB for
field storage, memcached for cache.
 Get a good sysadmin
Demi.fi – Lessons Learned
 Cache Control’s get_components back-end needs
to be fast
 Cache Control now supports MongoDB as storage
backend
 Cache Control’s front-end needs to be fast
 We had to rethink how to manipulate the page that has
lots of personalized content
 Continuous cache purging can also be a
performance issue
 Varnish 3.0-style bans take up a lot of resources, use
purges (2.0-style bans) instead
Demi.fi – More Lessons
 Building high-performance sites is hard, and it gets
harder if you don’t take performance into account
from the very beginning
 This includes design: be aware of the performance cost of
displaying a certain piece of content on a page, identify
and mitigate potential performance killers
 Cache Control is far from perfect and doesn’t alone
solve your problems
 Ironing out small glitches with e.g. cache purging
can be a lot of work
–
THE DIFFERENT CASE
Tekla Campus
 Tekla Campus is an e-learning tool and
community for engineering and construction
students
 Users come from all over the world
 Almost all of them are authenticated
 Not that much user-generated content,
moderate amount of personalized content for
logged-in users
Tekla Campus – Setup
 The site is hosted in Finland, but user base is
spread all over the world
 To mitigate latency, we needed a CDN solution
 Turns out Fastly CDN uses Varnish, so we
decided to give it a go
 Cache Control plays nicely with Fastly, even
cache purges work out of the box
 Fastly even allows you to upload your own VCL
SUMMARY
Summary
 Cache Control is a module for integrating your
site with e.g. Varnish. It works for both
anonymous and authenticated users
 It can help make your site a lot faster
 It can be easy or hard, depending on the complexity
of your site
 You can also use it to help with geographical
distribution of your site
THANK YOU!
WHAT DID YOU
THINK?
Locate this session at the
DrupalCon Prague website:
http://prague2013.drupal.org/schedule
Click the “Take the survey”
link

Mais conteúdo relacionado

Mais procurados

Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
Barry Abrahamson
 

Mais procurados (20)

Speeding Up WordPress sites
Speeding Up WordPress sitesSpeeding Up WordPress sites
Speeding Up WordPress sites
 
Show Me The Cache!
Show Me The Cache!Show Me The Cache!
Show Me The Cache!
 
Presentation1
Presentation1Presentation1
Presentation1
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & Tuning
 
The Power of a Video Library - WordCamp Raleigh
The  Power of a Video Library - WordCamp RaleighThe  Power of a Video Library - WordCamp Raleigh
The Power of a Video Library - WordCamp Raleigh
 
Speed Up Wordpress, Wordpress Horsepower
Speed Up Wordpress, Wordpress HorsepowerSpeed Up Wordpress, Wordpress Horsepower
Speed Up Wordpress, Wordpress Horsepower
 
Leeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website SpeedLeeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website Speed
 
High Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nlHigh Performance - Joomla!Days NL 2009 #jd09nl
High Performance - Joomla!Days NL 2009 #jd09nl
 
Adobe AEM Maintenance - Customer Care Office Hours
Adobe AEM Maintenance - Customer Care Office HoursAdobe AEM Maintenance - Customer Care Office Hours
Adobe AEM Maintenance - Customer Care Office Hours
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
 
Redundancy Rocks. Redundancy Rocks.
Redundancy Rocks. Redundancy Rocks.Redundancy Rocks. Redundancy Rocks.
Redundancy Rocks. Redundancy Rocks.
 
What is web hosting
What is web hostingWhat is web hosting
What is web hosting
 
CIRCUIT 2015 - Akamai: Caching and Beyond
CIRCUIT 2015 - Akamai:  Caching and BeyondCIRCUIT 2015 - Akamai:  Caching and Beyond
CIRCUIT 2015 - Akamai: Caching and Beyond
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007ServerBeach and WordPress BlogWorldExpo 2007
ServerBeach and WordPress BlogWorldExpo 2007
 
Protect Your WordPress Website - Setting Up IThemes Security
Protect Your WordPress Website - Setting Up IThemes SecurityProtect Your WordPress Website - Setting Up IThemes Security
Protect Your WordPress Website - Setting Up IThemes Security
 
Wordpress horsepower
Wordpress horsepowerWordpress horsepower
Wordpress horsepower
 
Web site loading time optimization
Web site loading time optimizationWeb site loading time optimization
Web site loading time optimization
 
23 Ways To Speed Up WordPress
23 Ways To Speed Up WordPress23 Ways To Speed Up WordPress
23 Ways To Speed Up WordPress
 
Scaling 101 test
Scaling 101 testScaling 101 test
Scaling 101 test
 

Destaque

Destaque (8)

Marketing Automation - How to Increase Customer Engagement?
Marketing Automation - How to Increase Customer Engagement?Marketing Automation - How to Increase Customer Engagement?
Marketing Automation - How to Increase Customer Engagement?
 
Switch Away from Icon Fonts to SVG
Switch Away from Icon Fonts to SVGSwitch Away from Icon Fonts to SVG
Switch Away from Icon Fonts to SVG
 
How does GDPR affect the design of user experiences?
How does GDPR affect the design of user experiences? How does GDPR affect the design of user experiences?
How does GDPR affect the design of user experiences?
 
SEO for Developers
SEO for DevelopersSEO for Developers
SEO for Developers
 
The Developer Friendly Container & Micro Services Platform
The Developer Friendly Container & Micro Services PlatformThe Developer Friendly Container & Micro Services Platform
The Developer Friendly Container & Micro Services Platform
 
Developer view on new EU privacy legislation (GDPR)
Developer view on new EU privacy legislation (GDPR)Developer view on new EU privacy legislation (GDPR)
Developer view on new EU privacy legislation (GDPR)
 
Preparing to the GDPR - the next steps
Preparing to the GDPR - the next stepsPreparing to the GDPR - the next steps
Preparing to the GDPR - the next steps
 
GDPR and technology - details matter
GDPR and technology - details matterGDPR and technology - details matter
GDPR and technology - details matter
 

Semelhante a High Performance Sites with Drupal and Cache Control Module

Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
drupalcampest
 
DOs and DONTs on the way to 10M users
DOs and DONTs on the way to 10M usersDOs and DONTs on the way to 10M users
DOs and DONTs on the way to 10M users
Yoav Avrahami
 
Drupal caching
Drupal cachingDrupal caching
Drupal caching
Exove
 
Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbs
varien
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
Artur Cistov
 

Semelhante a High Performance Sites with Drupal and Cache Control Module (20)

Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
High Performance on Drupal 7
High Performance on Drupal 7High Performance on Drupal 7
High Performance on Drupal 7
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Web Speed And Scalability
Web Speed And ScalabilityWeb Speed And Scalability
Web Speed And Scalability
 
DOs and DONTs on the way to 10M users
DOs and DONTs on the way to 10M usersDOs and DONTs on the way to 10M users
DOs and DONTs on the way to 10M users
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
 
System Architecture at DDVE
System Architecture at DDVESystem Architecture at DDVE
System Architecture at DDVE
 
Rock Solid WordPress
Rock Solid WordPressRock Solid WordPress
Rock Solid WordPress
 
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...
 
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
Site Speed = Success – Optimising WordPress from the Server Up - Presented by...
 
Drupal caching
Drupal cachingDrupal caching
Drupal caching
 
Scaling 101
Scaling 101Scaling 101
Scaling 101
 
Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbs
 
Make Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedMake Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speed
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...
Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...
Between a SPA and a JAMstack: Building Web Sites with Nuxt/Vue, Strapi and wh...
 
HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
 

Mais de Exove

Mais de Exove (20)

Data security in the age of GDPR – most common data security problems
Data security in the age of GDPR – most common data security problemsData security in the age of GDPR – most common data security problems
Data security in the age of GDPR – most common data security problems
 
Provisioning infrastructure to AWS using Terraform – Exove
Provisioning infrastructure to AWS using Terraform – ExoveProvisioning infrastructure to AWS using Terraform – Exove
Provisioning infrastructure to AWS using Terraform – Exove
 
Advanced custom fields in Wordpress
Advanced custom fields in WordpressAdvanced custom fields in Wordpress
Advanced custom fields in Wordpress
 
Introduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveIntroduction to Robot Framework – Exove
Introduction to Robot Framework – Exove
 
Jenkins and visual regression – Exove
Jenkins and visual regression – ExoveJenkins and visual regression – Exove
Jenkins and visual regression – Exove
 
Server-side React with Headless CMS – Exove
Server-side React with Headless CMS – ExoveServer-side React with Headless CMS – Exove
Server-side React with Headless CMS – Exove
 
WebSockets in Bravo Dashboard – Exove
WebSockets in Bravo Dashboard – ExoveWebSockets in Bravo Dashboard – Exove
WebSockets in Bravo Dashboard – Exove
 
Diversity in recruitment
Diversity in recruitmentDiversity in recruitment
Diversity in recruitment
 
Saavutettavuus liiketoimintana
Saavutettavuus liiketoimintanaSaavutettavuus liiketoimintana
Saavutettavuus liiketoimintana
 
Saavutettavuus osana Eläkeliiton verkkosivu-uudistusta
Saavutettavuus osana Eläkeliiton verkkosivu-uudistustaSaavutettavuus osana Eläkeliiton verkkosivu-uudistusta
Saavutettavuus osana Eläkeliiton verkkosivu-uudistusta
 
Mitä saavutettavuusdirektiivi pitää sisällään
Mitä saavutettavuusdirektiivi pitää sisälläänMitä saavutettavuusdirektiivi pitää sisällään
Mitä saavutettavuusdirektiivi pitää sisällään
 
Creating Landing Pages for Drupal 8
Creating Landing Pages for Drupal 8Creating Landing Pages for Drupal 8
Creating Landing Pages for Drupal 8
 
GDPR for developers
GDPR for developersGDPR for developers
GDPR for developers
 
Managing Complexity and Privacy Debt with Drupal
Managing Complexity and Privacy Debt with DrupalManaging Complexity and Privacy Debt with Drupal
Managing Complexity and Privacy Debt with Drupal
 
Life with digital services after GDPR
Life with digital services after GDPRLife with digital services after GDPR
Life with digital services after GDPR
 
GDPR - no beginning no end
GDPR - no beginning no endGDPR - no beginning no end
GDPR - no beginning no end
 
Developing truly personalised experiences
Developing truly personalised experiencesDeveloping truly personalised experiences
Developing truly personalised experiences
 
Customer Experience and Personalisation
Customer Experience and PersonalisationCustomer Experience and Personalisation
Customer Experience and Personalisation
 
Adventures In Programmatic Branding – How To Design With Algorithms And How T...
Adventures In Programmatic Branding – How To Design With Algorithms And How T...Adventures In Programmatic Branding – How To Design With Algorithms And How T...
Adventures In Programmatic Branding – How To Design With Algorithms And How T...
 
Dataohjattu asiakaskokemus
Dataohjattu asiakaskokemusDataohjattu asiakaskokemus
Dataohjattu asiakaskokemus
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

High Performance Sites with Drupal and Cache Control Module

  • 1. HIGH PERFORMANCE SITES WITH DRUPAL AND CACHE CONTROL MODULE Janne Salo Senior Developer
  • 2. Outline  Exove in brief  What is Cache Control and how does it work?  Easy case: Jatkoaika.com  Anonymous users, high read/write ratio  Hard case: Demi.fi  Autheticated users, low read/write ratio  Different case: Tekla Campus  Using Cache Control with a CDN  Discussion
  • 4. WHAT IS CACHE CONTROL AND HOW DOES IT WORK? drupal.org/project/cache_control
  • 5. What is Cache Control?  Module for integrating your site with Varnish or some other HTTP cache  Sets appropriate Cache-Control headers in HTTP responses from Drupal.  Supports also content purging  Automatic purges for e.g. node updates, hooks for custom purges  Comes with an admin UI for selecting cacheable menu router paths and a VCLfile for Varnish
  • 6. How does it work?  Varnish checks if requested page is cached  If it is, Varnish sends it to user’s browser (also for authenticated users!)  If it isn’t, pass the request to Drupal, execute the page load as anonymous user and cache the response in Varnish  Process the response in user’s browser  For anonymous users, show the page as is  For authenticated users, generate personalized parts in anAJAX back-end (get_components) and inject the results on the page
  • 7. “Personalized content?”  You can enable Cache Control for any Drupal block – the block will be generated for authenticated users in the get_components back-end  Using Cache Control’sAPI, you can “tag” any part of the page to be generated for in the get_components back-end
  • 8. Benefits of Cache Control  Only the needed parts are loaded: The back- end is significantly less burdened  All personalized parts of the are loaded in a single request  The user is given something to look at while the hard parts of the page are being loaded – the site feels faster
  • 9. What’s the catch?  Building high-performance sites is a complex matter. Cache Control is not a magic bullet to solve all your performance issues  While developing, you have to “think in Cache Control” or you’ll be in a world of trouble  You will most likely end up writing at least some custom code and spending time wondering why the site behaves differently when Cache Control is enabled
  • 10. What about ESI?  ESI (Edge Side Includes) is a partial loading technique supported by Varnish and some CDNs, e.g.Akamai  It basically makes Varnish do the partial page loading  Varnish first fetches the common version from cache  Then it looks though the page to see any ESI markup  Then it loads all the ESI marked parts of the page from cache or from Drupal
  • 11. How does Cache Control differ from ESI?  ESI needs to wait until the whole page is loaded before giving anything to the user  ESI loads all the portions of the page (still in D7, this might change in D8) in separate HTTP requests, thus burdening the server with even more bootstraps than without any cache
  • 13. Jatkoaika.com  Jatkoaika.com is the leading ice hockey site in Finland  200 000 unique visitors and 1.6M page loads per week  Page loads in Drupal are almost exclusively done by anonymous users  Content is read a lot more often than written, making the site an ideal use case for Cache Control
  • 14.
  • 15. Jatkoaika.com – Setup  Drupal, MySQL, SOLR, memcached, Varnish – all running on one server  Cache Control enabled for all content pages (nodes, taxonomy terms, front page) with different TTLs – no custom code required  Server loads are minimal
  • 17. Demi.fi  Demi.fi is the community around the Demi magazine, targeted to teenage girls  2.8M weekly page views  Most page loads done by authenticated users  1 300 – 1 500 logged-in users during busy hours  The users generate a lot of content (forum posts, comments, etc.)  Keeping the cache up to date is a challenge
  • 18.
  • 19. Demi.fi – Setup  Drupal, MySQL (Percona), SOLR, MongoDB, nginx + php-fpm, memcached, Varnish – all running on (almost) one server  Cache Control enabled for almost all user-facing pages and someAJAX backends as well  Alot of personalized components per page, putting strain on the get_components back-end  Quite a lot custom code required in making the site compatible and triggering cache purges when needed.  Server loads are significant but mostly tolerable
  • 20. Demi.fi – Strategy  Avoid Drupal bootstrap and theming  Cache Control: try to keep as much content in Varnish cache as possible  Fast JSON-based backends for data that changes often (e.g. forum topic listings): offload theming to users’browsers. Use Cache Control to cache the results with shortTTL(30 secs or so)  Use fast storage: SOLR for Views, MongoDB for field storage, memcached for cache.  Get a good sysadmin
  • 21. Demi.fi – Lessons Learned  Cache Control’s get_components back-end needs to be fast  Cache Control now supports MongoDB as storage backend  Cache Control’s front-end needs to be fast  We had to rethink how to manipulate the page that has lots of personalized content  Continuous cache purging can also be a performance issue  Varnish 3.0-style bans take up a lot of resources, use purges (2.0-style bans) instead
  • 22. Demi.fi – More Lessons  Building high-performance sites is hard, and it gets harder if you don’t take performance into account from the very beginning  This includes design: be aware of the performance cost of displaying a certain piece of content on a page, identify and mitigate potential performance killers  Cache Control is far from perfect and doesn’t alone solve your problems  Ironing out small glitches with e.g. cache purging can be a lot of work –
  • 24. Tekla Campus  Tekla Campus is an e-learning tool and community for engineering and construction students  Users come from all over the world  Almost all of them are authenticated  Not that much user-generated content, moderate amount of personalized content for logged-in users
  • 25.
  • 26. Tekla Campus – Setup  The site is hosted in Finland, but user base is spread all over the world  To mitigate latency, we needed a CDN solution  Turns out Fastly CDN uses Varnish, so we decided to give it a go  Cache Control plays nicely with Fastly, even cache purges work out of the box  Fastly even allows you to upload your own VCL
  • 28. Summary  Cache Control is a module for integrating your site with e.g. Varnish. It works for both anonymous and authenticated users  It can help make your site a lot faster  It can be easy or hard, depending on the complexity of your site  You can also use it to help with geographical distribution of your site
  • 29. THANK YOU! WHAT DID YOU THINK? Locate this session at the DrupalCon Prague website: http://prague2013.drupal.org/schedule Click the “Take the survey” link

Notas do Editor

  1. -CC: not going to go in details
  2. -60 people, most of which developers-JanneKalliola is the chair of Business and Strategy track
  3. -address to the project page, check out the code if you like
  4. -I’ll be talking about Varnish, because it’s most familiar to us (tested also with nginx cache, doesn’t support purges)-purges: consider listings on e.g. the front page (+compare purges with the Columbia Law School Tag! session from before)-You can also select TTL per path
  5. -context switch made if page is 1) set cacheable in the ui 2) accessible by anonymous user 3) other details not worth mentioning
  6. -some technical details: for each personalized component, store function and arguments that are needed to generate the data, also html id
  7. some bootstrapping + heavy theming is avoidedget_components still requires bootstrap, run with the current user session (NOT CACHED) in some cases, the site feeling faster is really just a feeling
  8. - complex matter: using Varnish isn’t the only thing you need to do- ”thinking in cache control”: what’s going to be personalized, can something be done differently etc. Do this as early as possible!- custom code: call hook_cache_control for tagging components (unobtrusive, you can disable cc at any time because of this), load some js and css. Why site looks different? Because Drupal
  9. -when we released Cache Control, one of the first questions was about ESI
  10. -might have changed, haven’t checked for a while
  11. -forum notDrupal-cache control disabled for admins
  12. news, teams, results, statistics…
  13. -no purges (except for automatic ones)-content propagation mostly handled with low TTLs (front page etc.)
  14. -around since 1998 or so, this is the fourth incarnation, huge migration, 250 000 registered users, millions of nodes (threads, community pages, blog posts)-teenage girls really let you know if something’s wrong-every page has a lot of personalized components, which is a challenge
  15. -forum listing, json backend-personalized content on the right
  16. -almost one server: php-fpm partly offloaded to another server-custom code: js/css loading, purging, redirects so that purges work (Cache Control at its worst)
  17. -json-backend: not directly related to cc, but is an example of the fact that cc alone doesn’t solve your problems-mention front themer?-sysadmin: most Drupaldevs are not in their comfort zone with Varnish, db optimization, server configuration etc.
  18. -mongodb panic rewrite-varnish loads-form cache + memcached -> problems with our number of forms (space just runs out) -> move to mysql -> loads skyrocket
  19. -glitches: redirects, messages, css/js-don’t really know if this can be avoided due to the way Drupal handles things
  20. -support forum is probably the most user-generated content there is
  21. -very simple: lessons to use the tools
  22. -in addition,fastly has good coverage of nodes throughout the world-other options: Akamai – trouble with POST requests (?)-seems happy, but is not as happy as Jatkoaika: some custom code was needed
  23. it does this by manipulating cache-control HTTP headers (integration with Varnish), caches anonymous pages, personalizes on AJAXeasy = not that much personalized content (or personalized content), few purges, hard = custom code, personalized content, lots of purges, small js/css glitchesgeographical distribution = together with a suitable CDN