performance for site builders - drupal · php/application “server” usually runs as apart of...
TRANSCRIPT
![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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/1.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/2.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/3.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/4.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/5.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/6.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/7.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/8.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/9.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/10.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/11.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/12.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/13.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/14.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/15.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/16.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/17.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/18.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/19.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/20.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/21.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/22.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/23.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/24.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/25.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/26.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/27.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/28.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/29.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/30.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/31.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/32.jpg)
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)](https://reader033.vdocument.in/reader033/viewer/2022042312/5eda3f6eb3745412b571057f/html5/thumbnails/33.jpg)
Questions?Where to find me?
erikwebb.net@erikwebb on Twittererikwebb on LinkedInerikwebb on SlideShare