Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of...

33
Performance for Site Builders Erik Webb Senior Technical Consultant Acquia Erik Webb @erikwebb Senior Technical Consultant Acquia

Transcript of Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of...

Page 1: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Performance for Site Builders

Erik WebbSenior Technical Consultant

Acquia

Erik Webb@erikwebbSenior Technical ConsultantAcquia

Page 2: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Agenda

IntroductionEvaluating ModulesWhat to Look ForTypes of CachingConfiguring DrupalPerformance-related Tools

Page 3: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

About Me

Senior Technical ConsultantFocus on Performance, Infrastructure, and Scalability

5+ years with Drupal10+ years with LAMP

Red Hat Certified Engineer

Worked previously at Georgia Tech, IBM

Page 4: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

We’re hiring!

Page 5: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Bad Performance Advice

Drupal is slow.If it runs out of memory, give it more.Don’t use CCK/Views/Panels/whatever.If you don’t install X, your site will be slow.You need multiple servers.

You should have MySQL slave servers.Varnish will solve all of your problems.*

http://www.diesoft.net/blog/2012/04/10/first-aid-drupal

Page 6: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Evaluating Modules

Page 7: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

General Evaluation

1. Supported version(s)2. Maintainer reputation3. Total usage4. Number of open issues5. Usage change over time

Page 8: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Performance Evaluation

Record baseline before installationRecord usage immediately after installationUse ongoing memory monitoring to correlate

Use tag “Performance” in issue queueTypically improvementsWeeds out “My site is slow” issuesExample: http://drupal.org/project/issues/search/views?issue_tags=Performance

Page 9: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Questions to Ask?

When does this module “run”?Examples: Login, Content update, Periodically/cron

How does this module scale?Examples: Per node, per user, per request

What happens if this module fails?If this module fails, no user can login.If this module fails, no content will have functioning slideshows.

Does my site care about performance?Is my site visited entirely by anonymous users?Is this site internal and low-traffic only?

Do I really need this module?

Page 10: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

What to Look For

Page 11: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Identifying the Problem

When does it occur?All pages? Anonymous and/or authenticated?Only when saving content? Only when logging in?Under heavy load? Random times during the day?

When did it start?Avoid the “it feels faster/slower” problemRecord performance numbersMaintain release notes (or retain logs)

Who is to blame?Test against regression between featuresTake note of any infrastructure changes

Page 12: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Where Problems Occur

Page building modulesViews and Panels

External web servicesUser loginsAny 3rd-party integration

Overall complexityTotal number of modulesViews within Panels within Panels within...

Misconfigured componentsDefault is uncached (for developers)Understand what is being cached

Page 13: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Managing Performance

Keep records of performance over timeBe analytical, don’t feelNote any milestones of activity or feature developmentCorrelate improvements and regressions

Establish a performance metricSet a level of acceptabilityExample: 80% of pages should return in 500ms or render in 3s

Adopt a “Definition of Done” (DoD)Agile concept - aspects needing satisfaction before completionPerformance is part of QA

Don’t hide behind infrastructureSlow Drupal is cheap, hardware is not

Page 14: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Types of Caches

Page 15: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Application-level Caching

Move along, nothing to see here.Not configurableShould never result in “staleness”Can only be enhanced by improving backend

Examples: Filter, Menu, Path, Filter (not FORM!)

Page 16: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Component-level Caching

Stores user-facing componentsBest speedup for authenticated users

Limited effectiveness without more configurationMostly disabled by default

Varying degrees of contents, HTML to serialized objectsSome implementations more effective than others

Examples: Block, Views, Panels

Page 17: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Page-level Caching

Most efficient possible cacheCombine with reverse proxy

Only applicable for anonymous users*Stored as full HTMLpage_cache_fastpath() in D6

Not supported by default cache backendBypasses database connection and full bootstrap

Page 18: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Configuring Drupal

Page 19: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Performance page

Use block caching!*Disabled by node accessBiggest speedup for auth users

Content changes clear block and page cache

Use “Minimum cache lifetime”Using a reverse proxy?

Use “Expiration of cached pages”

Aggregation/compression only on production

$conf[‘preprocess_css’] = 1;

Page 20: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Fast 404

Added in Drupal 7.9 (currently being backported to D6)See http://drupal.org/node/76824

Configured in settings.phpAvoid performance hit from404 errors

Page 21: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Other Notes

Understand what Drupal does and does not cacheHelps understand when to troubleshoot

Don’t forget the frontend!Do not enable “UI modules” on production

Unneeded memory usageExamples: Field UI, Rules Admin, Views UI

Avoid Database Logging (if you have an alternative)Examples: Syslog, log4php

Unnoticed PHP errors slow down executionIncrease PHP logging on non-production environments

Page 22: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Performance-related Tools

Page 23: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Drupal Modules

DevelExecution time and memory usageQuery logging

BoostFlat file page cachingDesigned for shared hosting (infrastructure neutral)

MemcacheReplace database caching with MemcachedIn-memory cache, reduces DB load

Page 24: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Drupal Modules

Entity CacheDrupal 7 onlyStores created objects a.k.a. “entities” (users, nodes, comments, etc.)

Path CachePressflow (D6) or Drupal 7

Block Cache AlterMaximize effectiveness of block cachingFine-grained control per block

Page 25: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Drupal Modules

Views LitepagerSlow pagers on Views with large DB tables

Views Content CacheStore saved Views based on content changes rather than expirationExample: Clear a View display when a new “Article” node is created

Cache ActionsMore generalized approach than Views Content CacheWorks with Drupal cache, CSS/JS aggregation, Views, and PanelsRequires the Rules module

Page 26: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

3rd-Party Tools

Web optimization toolsYahoo! Smush.itSpriteMe

Web testing toolsWebPagetest.orgGoogle PageSpeed Online

Browser-basedFirebug/Web InspectorYSlow!Google PageSpeed

SaaS productsNew RelicYottaa

Page 27: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Infrastructure Overview

Page 28: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Apache/Web Server

Handles web requests for PHPMost common bottleneck

Application should be memory-boundLeast performance considerations

Serves static files alongside PHP scripts

Scalable: Horizontal and verticalAlternative: Nginx

Page 29: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

PHP/Application “Server”

Usually runs as apart of Apache (mod_php)

Most common configuration by farUse Alternative PHP Cache (APC)

Saves interpreted PHP files in memory

Can run as separate process - PHP-FPM (5.3.3+)

Scale independent of ApacheBetter privilege separation

Page 30: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

MySQL/Database Server

Sole datastore for Drupal“Natural” LAMP bottleneck

Hard to solve problemMost tunable component

Scalable: VerticalAlternatives: Percona Server and MariaDB

Page 31: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Caching Server

Two main advantagesFaster access than MySQLReduce overall load on MySQL

Significant for authenticated usersEasily configured through Drupal or PHPRequires PHP extensions

Scalable: Horizontal and verticalExamples: Memcached, Redis

Page 32: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Varnish/Reverse Proxy

Store entire pages for quick retrievalExtremely configurable

Load balancing and traffic managementVarnish Configuration Language (VCL)

Scalable: Horizontal* and vertical

Page 33: Performance for Site Builders - Drupal · PHP/Application “Server” Usually runs as apart of Apache (mod_php) Most common configuration by far Use Alternative PHP Cache (APC)

Questions?Where to find me?

erikwebb.net@erikwebb on Twittererikwebb on LinkedInerikwebb on SlideShare