SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
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?

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 
title
titletitle
title
 

Kürzlich hochgeladen

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Kürzlich hochgeladen (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

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