SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
High performance Drupal sites
DrupalCamp Helsinki 27.9.2011
Rami Järvinen, Exove Oy
Agenda
About Exove and myself
Caching
Scaling
Optimizing
Exove enables companies to
conduct better business on the
          Internet
through best-of-breed personnel
         and solutions
We design and implement beautiful,
  functional, and business-driven
             solutions
About myself, Rami Järvinen
Senior developer at Exove
Drupal experience from 2006. Been involved with a
wide variety of different site projects.
Drupal is slow
Why?
Drupal is slow
Why?
•  Page rendering
Drupal is slow
Why?
•  Page rendering
•  Database queries
Drupal is slow
Why?
•  Page rendering
•  Database queries
•  Programmers
Drupal is slow
Why?                  Solution
•  Page rendering     •  Caching
•  Database queries   •  Caching / Optimizing
•  Programmers        •  ???
Boosting up the performance
•  Drupal’s internal architecture
 •  Single-controller
 •  Loads a lot of code on every pageload
 •  Tends to be slower than a pure MVC-model

•  Caching
 •  Minimize the CPU usage
 •  Minimize the amount of SQL queries
 •  Ultimately – avoid running Drupal’s bootstrap
Caching layers
•  MySQL query cache
•  PHP opcode cache
•  Drupal internal caching
•  HTTP cache (reverse proxy)
•  Browser cache
•  HTML 5: Client-side storage
Caching layers – PHP opcode cache
•  Alternative PHP Cache (APC)
•  PHP code is compiled every time it is read
•  APC caches the compiled bytecode
•  Parsing and compiling PHP code is not needed, if the
bytecode is in the cache
•  Works generally everywhere and gives a major boost
in performance
Caching layers – Drupal internal caching
•  Block cache
 •  Global / per role / per user

•  Page cache
 •  For anonymous users

•  Code level caching
•  Contrib modules
 •  Boost
 •  Memcache API and Integration
Cache layers – Code level
•  1st rule of caching and optimization: Never do
something time consuming twice if you can hold onto
the results and re-use them
•  Static variables for storing data within a function for
the duration of a single page load.
 •  Use drupal_static() to utilize central static variable storage

•  Using cache_set() and cache_get() functions for
caching data more permanently.
Caching layers - Boost
•  Generated page HTML is saved as a static file
 •  Page loads never touch the database

•  For anonymous traffic and sites with a little dynamic
content
•  Easy to set up even on a cheap web hotel
 •  Enable the module, modify .htaccess and you’re done

•  Highly configurable
•  For not yet cached content, serves the page first and
saves HTML after that
•  Inbuilt crawler for cache warm-up
Caching layers – Memcached
•  High-performance, distributed memory object
caching system
•  In-memory key-value store for small chunks of
arbitrary data
•  Drop-in replacement for changing Drupal cache
backend
 •  Instead of saving cached data to DB, it goes to memcached
 •  High-traffic sites really need to save the cache to memory

•  Also for session data etc.
Caching layers – Reverse proxy
•  Varnish Cache
•  Designed from the ground up as an HTTP accelerator
•  Stores data in virtual memory
•  Configurable with VCL (Varnish Configuration
Language)
•  Edge Side Includes (ESI)
 <esi include=“/esi/some_content” />

•  ESI integration module
 •  Block template will be changed to instruct Varnish to get block
    content from e.g. http://example.com/esi/block/xxxxxx
Cache Control module
•  An alternative to ESI
•  Cheaper way to display user specific content
•  How it works
 •  For all users, we load the page with anonymous content
    hidden under a throbber
 •  JS then checks if the user is logged in (w/ cookie) and (for
    anonymous users) set the anonymous content visible
 •  For logged in users (after JS has checked the login status), it
    makes a single request to the backend to get the user-specific
    data for the page

•  http://drupal.org/node/1155312
Scaling Drupal
•  MySQL
 •  High-performance configurations. There are many good base
    configs available – start with them
 •  Dedicated server
 •  Master-slave setup
 •  Direct some of the SQL queries to slave

•  Files
 •  Serve static files with Nginx or lighttpd
     •  Or use reverse proxy to cache them
 •  CDN if there’s a massive library of static content

•  Scaling by buying more hardware?
Hardware stack example



                      Linux,
                    Apache PHP


                     Server 1

                    memcached



                      MySQL
                      master
Hardware stack example




                 Linux,
               Apache PHP         MySQL
                                  master
                 Front      R/W

                server 1
                                   MySQL
               memcached          server 1
Hardware stack example

                             memcached
                                                 MySQL
                                                server 2
                   HTTP        Front
                  cache 1     server 2

                               Linux,           MySQL
                   Varnish                      slave
        Load                 Apache PHP    R

       balancer

       Front
                               Linux,     R/W
       server      Varnish
                             Apache PHP         MySQL
                                                master
                   HTTP        Front
                  cache 2     server 1
                                                 MySQL
                             memcached          server 1
Optimizing
•  Profiling
 •  Xdebug, XHProf and similar profiling tool to see what actually
    happens during a page load
 •  Devel module to print a summary of all database queries
    executed for page request, including how many times each
    query was executed and how long each query took

•  SQL bottlenecks
 •  Unnecessary repeating of same queries
 •  Missing indexes
 •  Temporary tables and filesort
     •  Use EXPLAIN to find out how MySQL executes your monster
        query
 •  Table locking if using MyISAM engine in MySQL
• “Is there a lot of logged in users or are most of them
anonymous?”
 •  This pretty much defines what kind of caching strategies can
    be applied

•  “What kind of things my hosting environment allows
me to do?”


•  There’s no single best solution
Thank you
  Questions?

Mais conteúdo relacionado

Mais procurados

Memcached Code Camp 2009
Memcached Code Camp 2009Memcached Code Camp 2009
Memcached Code Camp 2009NorthScale
 
캐시 분산처리 인프라
캐시 분산처리 인프라캐시 분산처리 인프라
캐시 분산처리 인프라Park Chunduck
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...Nexcess.net LLC
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimizationAlmog Baku
 
Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7Colin Charles
 
Lamp Introduction 20100419
Lamp Introduction 20100419Lamp Introduction 20100419
Lamp Introduction 20100419Vu Hung Nguyen
 
Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Brian Moon
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilitycherryhillco
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Brian Moon
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcacheChris Westin
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh thingsMarcus Deglos
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutSander Temme
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The SnailMarcus Deglos
 
Cool MariaDB Plugins
Cool MariaDB Plugins Cool MariaDB Plugins
Cool MariaDB Plugins Colin Charles
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010Mark Atwood
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera ClusterAbdul Manaf
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Colin Charles
 

Mais procurados (20)

Memcached Code Camp 2009
Memcached Code Camp 2009Memcached Code Camp 2009
Memcached Code Camp 2009
 
캐시 분산처리 인프라
캐시 분산처리 인프라캐시 분산처리 인프라
캐시 분산처리 인프라
 
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
EECI 2013 - ExpressionEngine Performance & Optimization - Laying a Solid Foun...
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimization
 
Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7Better encryption & security with MariaDB 10.1 & MySQL 5.7
Better encryption & security with MariaDB 10.1 & MySQL 5.7
 
Lamp Introduction 20100419
Lamp Introduction 20100419Lamp Introduction 20100419
Lamp Introduction 20100419
 
Varnish intro
Varnish introVarnish intro
Varnish intro
 
Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)Memcached: What is it and what does it do? (PHP Version)
Memcached: What is it and what does it do? (PHP Version)
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcache
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh things
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
 
Cool MariaDB Plugins
Cool MariaDB Plugins Cool MariaDB Plugins
Cool MariaDB Plugins
 
Memcached, presented to LCA2010
Memcached, presented to LCA2010Memcached, presented to LCA2010
Memcached, presented to LCA2010
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera Cluster
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 

Destaque (9)

Using Git
Using GitUsing Git
Using Git
 
D7 Entities
D7 EntitiesD7 Entities
D7 Entities
 
WordPress to Drupal
WordPress to DrupalWordPress to Drupal
WordPress to Drupal
 
Windows Azure Platform
Windows Azure PlatformWindows Azure Platform
Windows Azure Platform
 
Node Stream
Node StreamNode Stream
Node Stream
 
2
22
2
 
Drupal vs Sharepoint
Drupal vs SharepointDrupal vs Sharepoint
Drupal vs Sharepoint
 
Antibióticos Beta-lactâmicos; Penicilinas
Antibióticos Beta-lactâmicos; PenicilinasAntibióticos Beta-lactâmicos; Penicilinas
Antibióticos Beta-lactâmicos; Penicilinas
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Semelhante a High Performance Drupal Sites

Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesExove
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Tech4Africa - Tuning LAMP, and beyond LAMP
Tech4Africa - Tuning LAMP, and beyond LAMPTech4Africa - Tuning LAMP, and beyond LAMP
Tech4Africa - Tuning LAMP, and beyond LAMPJason Norwood-Young
 
Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3epee
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachLiving with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachJeremy Zawodny
 
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Atwix
 
Open stack ha design & deployment kilo
Open stack ha design & deployment   kiloOpen stack ha design & deployment   kilo
Open stack ha design & deployment kiloSteven Li
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
Performance_Out.pptx
Performance_Out.pptxPerformance_Out.pptx
Performance_Out.pptxsanjanabal
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance out
Performance outPerformance out
Performance outJack Huang
 

Semelhante a High Performance Drupal Sites (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
 
Tech4Africa - Tuning LAMP, and beyond LAMP
Tech4Africa - Tuning LAMP, and beyond LAMPTech4Africa - Tuning LAMP, and beyond LAMP
Tech4Africa - Tuning LAMP, and beyond LAMP
 
Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachLiving with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Performance out
Performance outPerformance out
Performance out
 
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
 
Open stack ha design & deployment kilo
Open stack ha design & deployment   kiloOpen stack ha design & deployment   kilo
Open stack ha design & deployment kilo
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
Performance_Out.pptx
Performance_Out.pptxPerformance_Out.pptx
Performance_Out.pptx
 
2 7
2 72 7
2 7
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 

Último

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
 
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 Takeoffsammart93
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

High Performance Drupal Sites

  • 1. High performance Drupal sites DrupalCamp Helsinki 27.9.2011 Rami Järvinen, Exove Oy
  • 2. Agenda About Exove and myself Caching Scaling Optimizing
  • 3. Exove enables companies to conduct better business on the Internet through best-of-breed personnel and solutions
  • 4. We design and implement beautiful, functional, and business-driven solutions
  • 5. About myself, Rami Järvinen Senior developer at Exove Drupal experience from 2006. Been involved with a wide variety of different site projects.
  • 7. Drupal is slow Why? •  Page rendering
  • 8. Drupal is slow Why? •  Page rendering •  Database queries
  • 9. Drupal is slow Why? •  Page rendering •  Database queries •  Programmers
  • 10. Drupal is slow Why? Solution •  Page rendering •  Caching •  Database queries •  Caching / Optimizing •  Programmers •  ???
  • 11. Boosting up the performance •  Drupal’s internal architecture •  Single-controller •  Loads a lot of code on every pageload •  Tends to be slower than a pure MVC-model •  Caching •  Minimize the CPU usage •  Minimize the amount of SQL queries •  Ultimately – avoid running Drupal’s bootstrap
  • 12. Caching layers •  MySQL query cache •  PHP opcode cache •  Drupal internal caching •  HTTP cache (reverse proxy) •  Browser cache •  HTML 5: Client-side storage
  • 13. Caching layers – PHP opcode cache •  Alternative PHP Cache (APC) •  PHP code is compiled every time it is read •  APC caches the compiled bytecode •  Parsing and compiling PHP code is not needed, if the bytecode is in the cache •  Works generally everywhere and gives a major boost in performance
  • 14. Caching layers – Drupal internal caching •  Block cache •  Global / per role / per user •  Page cache •  For anonymous users •  Code level caching •  Contrib modules •  Boost •  Memcache API and Integration
  • 15. Cache layers – Code level •  1st rule of caching and optimization: Never do something time consuming twice if you can hold onto the results and re-use them •  Static variables for storing data within a function for the duration of a single page load. •  Use drupal_static() to utilize central static variable storage •  Using cache_set() and cache_get() functions for caching data more permanently.
  • 16. Caching layers - Boost •  Generated page HTML is saved as a static file •  Page loads never touch the database •  For anonymous traffic and sites with a little dynamic content •  Easy to set up even on a cheap web hotel •  Enable the module, modify .htaccess and you’re done •  Highly configurable •  For not yet cached content, serves the page first and saves HTML after that •  Inbuilt crawler for cache warm-up
  • 17. Caching layers – Memcached •  High-performance, distributed memory object caching system •  In-memory key-value store for small chunks of arbitrary data •  Drop-in replacement for changing Drupal cache backend •  Instead of saving cached data to DB, it goes to memcached •  High-traffic sites really need to save the cache to memory •  Also for session data etc.
  • 18. Caching layers – Reverse proxy •  Varnish Cache •  Designed from the ground up as an HTTP accelerator •  Stores data in virtual memory •  Configurable with VCL (Varnish Configuration Language) •  Edge Side Includes (ESI) <esi include=“/esi/some_content” /> •  ESI integration module •  Block template will be changed to instruct Varnish to get block content from e.g. http://example.com/esi/block/xxxxxx
  • 19. Cache Control module •  An alternative to ESI •  Cheaper way to display user specific content •  How it works •  For all users, we load the page with anonymous content hidden under a throbber •  JS then checks if the user is logged in (w/ cookie) and (for anonymous users) set the anonymous content visible •  For logged in users (after JS has checked the login status), it makes a single request to the backend to get the user-specific data for the page •  http://drupal.org/node/1155312
  • 20. Scaling Drupal •  MySQL •  High-performance configurations. There are many good base configs available – start with them •  Dedicated server •  Master-slave setup •  Direct some of the SQL queries to slave •  Files •  Serve static files with Nginx or lighttpd •  Or use reverse proxy to cache them •  CDN if there’s a massive library of static content •  Scaling by buying more hardware?
  • 21. Hardware stack example Linux, Apache PHP Server 1 memcached MySQL master
  • 22. Hardware stack example Linux, Apache PHP MySQL master Front R/W server 1 MySQL memcached server 1
  • 23. Hardware stack example memcached MySQL server 2 HTTP Front cache 1 server 2 Linux, MySQL Varnish slave Load Apache PHP R balancer Front Linux, R/W server Varnish Apache PHP MySQL master HTTP Front cache 2 server 1 MySQL memcached server 1
  • 24. Optimizing •  Profiling •  Xdebug, XHProf and similar profiling tool to see what actually happens during a page load •  Devel module to print a summary of all database queries executed for page request, including how many times each query was executed and how long each query took •  SQL bottlenecks •  Unnecessary repeating of same queries •  Missing indexes •  Temporary tables and filesort •  Use EXPLAIN to find out how MySQL executes your monster query •  Table locking if using MyISAM engine in MySQL
  • 25. • “Is there a lot of logged in users or are most of them anonymous?” •  This pretty much defines what kind of caching strategies can be applied •  “What kind of things my hosting environment allows me to do?” •  There’s no single best solution