High Performance Drupal

Book description

How can you help your Drupal website continue to perform at the highest level as it grows to meet demand? This comprehensive guide provides best practices, examples, and in-depth explanations for solving several performance and scalability issues. You’ll learn how to apply coding and infrastructure techniques to Drupal internals, application performance, databases, web servers, and performance analysis.

Covering Drupal versions 7 and 8, this book is the ideal reference for everything from site deployment to implementing specific technologies such as Varnish, memcache, or Solr. If you have a basic understanding of Drupal and the Linux-Apache-MySQL-PHP (LAMP) stack, you’re ready to get started.

  • Establish a performance baseline and define goals for improvement
  • Optimize your website’s code and front-end performance
  • Get best and worst practices for customizing Drupal core functionality
  • Apply infrastructure design techniques to launch or expand a site
  • Use tools to configure, monitor, and optimize MySQL performance
  • Employ alternative storage and backend search options as your site grows
  • Tune your web servers through httpd and PHP configuration
  • Monitor services and perform load tests to catch problems before they become critical

Publisher resources

View/Submit Errata

Table of contents

  1. High Performance Drupal
  2. Dedication
  3. Preface
    1. Does Drupal Scale?
    2. Goals of This Book
    3. Supported Drupal Versions
    4. How This Book Is Organized
      1. Performance Analysis
      2. Application Performance
      3. Infrastructure
      4. Databases
      5. Web Servers and Reverse Proxies
      6. Ongoing Testing
      7. Where to Next?
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
      1. From Jeff
      2. From Narayan
      3. From Nat
  4. 1. Beginning a Performance Project
    1. Getting Started with Performance Improvements
    2. Establishing a Performance Baseline
    3. Setting Goals for Website Performance
    4. The Many Aspects of Drupal Performance
    5. Creating a Prioritized List of Improvements
  5. 2. Frontend Performance
    1. Limiting HTTP Requests
      1. Audits
    2. Image Requests
    3. Minification
      1. Minification On the Fly
      2. Preminification for Modules/Themes
      3. Minifying During the Build Process
    4. Compression
    5. Cacheable Headers
    6. CDNs
    7. Keep Third-Party Libraries Up to Date
      1. jQuery Update
    8. External Scripts
    9. Single Points of Failure (SPOFs)
  6. 3. Drupal Performance Out of the Box
    1. Page Caching
    2. When Should You Use Page Caching?
      1. Internal Page Caching
      2. Reverse Proxy Caching
    3. CSS and JavaScript Aggregation
    4. Logging
    5. The Cache and Other Swappable Storage
    6. Cron
    7. Views
  7. 4. Drupal Coding for Optimal Performance
    1. Context Matters
    2. False Optimizations
    3. Listing Entities
      1. entityQuery()
      2. Multiple Entity Loading
    4. Caching
      1. Static Caching
      2. Persistent Caching
        1. Cache chains
        2. Cache bins
        3. getMultiple()/setMultiple()/deleteMultiple()
        4. Cache tags
        5. CacheArray
        6. Render caching
    5. Queues and Workers
    6. Cache Stampedes and Race Conditions
  8. 5. Drupal Coding for Abysmal Performance
    1. variable_set() Abuse
    2. External Requests
    3. Sessions
    4. Excessive Cache Granularity
    5. PHP Errors
    6. Debug Code in the Code Base
    7. Development Settings
  9. 6. Verifying Changes
    1. Analyzing Frontend Performance
      1. YSlow and Google PageSpeed
      2. Waterfall Charts
      3. Real User Monitoring
    2. Analyzing Application Performance
      1. The Devel Module
        1. Page timing
        2. Memory usage
        3. Query log
      2. Xdebug
      3. XHProf
      4. strace
  10. 7. Infrastructure Design and Planning
    1. Horizontal and Vertical Scaling
    2. Service Categorization
    3. Working Well Together
    4. Example Two-Layer Configuration
    5. Example Larger-Scale Infrastructure
    6. Development and Staging Environments
    7. Internal Network Layout
    8. Utility Servers
    9. High Availability and Failover
    10. Hosting Considerations
    11. Summary
  11. 8. Service Monitoring
    1. The Importance of Monitoring Services
    2. Monitoring Alerts with Icinga
      1. What to Monitor
      2. How to Tune Monitoring
    3. Graphing Monitoring Data
    4. Internal Versus Remote Monitoring
  12. 9. “DevOps”: Breaking Down Barriers Between Development and Operations
    1. Revision Control Systems
      1. Locally Hosted or External Service
      2. Not Just for Code
    2. Configuration Management Systems
      1. Which System to Use
    3. Pulling It Together: In-Depth Example with Puppet and Git
    4. Development Virtual Machines
      1. How to Distribute Development VMs with Vagrant
    5. Deployment Workflow
      1. Example Workflow with Git
    6. Deployment with Jenkins CI
  13. 10. File Storage for Multiple Web Servers
    1. rsync
    2. GlusterFS
      1. Example Configuration
    3. Single NFS Server
    4. HA NFS Cluster
      1. Example Configuration
      2. Setting Up DRBD
      3. Setting Up Heartbeat
      4. Setting Up NFS
      5. Testing
    5. Storage Area Networks (SANs)
  14. 11. Drupal and Cloud Deployments
    1. What Is the Cloud?
    2. Why Use the Cloud?
    3. Infrastructure Overhead
    4. Prepackaged Clouds
    5. Common Issues with Cloud Deployments and Their Mitigations
  15. 12. Failover Configuration
    1. IP Failover Versus DNS Failover
    2. Service-Level Issues
    3. Heartbeat
      1. Installation
      2. Configuration
      3. Usage
  16. 13. MySQL
    1. Drupal and MySQL Engines
    2. Versions of MySQL
      1. Oracle MySQL
      2. MariaDB
      3. Percona Server
    3. General Configuration
      1. Global Configuration
      2. Per-Thread Configuration
      3. Storage Engine Configuration
    4. Replication
    5. Virtualized Deployments
  17. 14. Tools for Managing and Monitoring MySQL
    1. Percona Toolkit
    2. Openark Kit
    3. mysqlreport
    4. Percona Monitoring Plug-Ins
  18. 15. MySQL Query Optimization
    1. Index Basics
    2. Base Tables and Join Order
    3. Common Issues
      1. The ORDER BY on an Unrelated Table
      2. The Useless DISTINCT (“In Case of Accidents!”)
      3. Starfish Syndrome (All LEFT JOINS)
      4. Node Access
  19. 16. Alternative Storage and Cache Backends
    1. Cache, Lock, and Session Storage
    2. Memcache In Depth
      1. PHP Extensions for Memcache
      2. Assigning Memcached Servers and Bins
      3. Memcache Locking and Stampede Protection
      4. What to Store in Memcache
      5. Configuring the Memcache Daemon
    3. How to Break Your Site with Memcache
      1. Inconsistent Caching
      2. Constant Evictions
      3. Vanishing Sessions
    4. Entity/Field Storage
      1. EntityFieldQuery/EntityQuery
      2. CRUD
      3. MongoDB
  20. 17. Solr Search
    1. Performance and Scalability Considerations
    2. Integrating Solr with Drupal
    3. Solr Configuration
    4. Indexing Content
    5. Infrastructure Considerations
    6. Solr Replication
    7. Drupal Module Installation
  21. 18. PHP and httpd Configuration
    1. APC: PHP Opcode Cache
    2. php.ini Settings
    3. PHP Apache Module Versus CGI
    4. Apache MPM Settings
    5. Prefork Thread Settings
    6. KeepAlive
    7. Cache Headers
    8. Logging
    9. Server Signature
    10. Administrative Directory or VirtualHost
    11. Nginx
      1. Why Not Use Nginx Everywhere?
  22. 19. Reverse Proxies and Content Delivery Networks
    1. Using a Reverse Proxy with Drupal
    2. Understanding Varnish Configuration Language
      1. Defining a Backend
      2. Directors: Dealing with Multiple Backend Servers
      3. Built-in VCL Subroutines
      4. Customizing Subroutines
    3. Cookies and Varnish
    4. Caching for Authenticated Users
    5. Edge-Side Includes
    6. Serving Expired Content
    7. Error Pages
    8. Memory Allocation
    9. Logging and Monitoring Varnish
    10. Sample VCL for Drupal
    11. Content Delivery Networks
      1. Serving Static Content Through a CDN
      2. When to Use a CDN
      3. Choosing Between a CDN and a Reverse Proxy
  23. 20. Load Testing
    1. Different Types of Load Tests
    2. Creating a Valid Test
    3. When to Test
      1. Continuous Integration (CI)
      2. Periodic Testing
      3. Manual Targeted Testing
    4. Interpreting Test Results
    5. Server Monitoring During Load Tests
    6. Where to Test
    7. Example Load Test Using JMeter
      1. Global Test Settings
      2. Thread Groups
      3. Handling Cookies
      4. Login Controller
      5. Browse Controller
      6. Output Configuration
      7. Running a Test
      8. Reading Test Results
  24. 21. Where to Next?
    1. Official Book Website
    2. High Performance Drupal Group
    3. Drupal Watchdog
    4. Revision Control with Git
    5. Varnish
    6. Configuration Management
    7. Vagrant
    8. Jenkins
    9. MySQL Performance
    10. InnoDB Index Structures
  25. Index
  26. About the Authors
  27. Colophon
  28. Copyright

Product information

  • Title: High Performance Drupal
  • Author(s): Jeff Sheltren, Narayan Newton, Nathaniel Catchpole
  • Release date: October 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449392611