SlideShare una empresa de Scribd logo
1 de 28
Drupal Performance - Case Study
Hernâni Borges de Freitas – Drupal PT Meetup – Porto, 27th November
 Biggest online fan community about Sport
Lisboa e Benfica.
 About 10 years old, online since 01/05/2001
 Done as hobby by:
 Staff (20 people among editors and moderators)
 Members (~31 000 users, 8000 Active Members)
 Articles, blog aggregation, image gallery,
forum, press aggregation, matches and
players’ profiles.
 Average per day (October 2010)
 8000 Visits per Day
 185 000 PageViews
 12 pages per Session (!)
 3500 messages per day.
 50 blogs aggregated.
 According to Alexa.com (Oct 2010)
 150th most visited website in
Portugal.
 On top 50 portuguese websites.
 Most popular portuguese website
made in DRUPAL!
 Technology was slowing us down
 Custom designed cms, with 10 years legacy code
and cache control based in smarty.
 Site must be done by community
 Workflow and revision process was weak and
unsafe
 Developments took to much time
 Hard to implement or change existing features.
 Performance problems on traffic peaks
 Around 1700 users at same time.
 Dedicated Server
 Quad Xeon 2,4 Ghz
 4 Gb Memory
 Lighttpd/Apache as App Server
 Php with eAccelerator.
 Most of pageviews are seen by registered users.
 Most pageviews are generated by forum (based
on Simple Machines Forum).
 Cache control was made using smarty and forum
cache system.
 Development started in August 2010
 Done on spare time by 1 Drupalista.
 We went live in 24th October 2010 (2
months ...)
 Website redone from scratch
 Data migration done used custom scripts
 60k nodes, 30k users, 2,5k terms, 16 content types
 100 modules
 Portuguese/English , Web/Mobile Site
 Optimize using iterative improvements
(Progressive Doping)
 Architecture
 Profiling
 Caching
 Application diet
 WebServer Change
 Drupal Tips and Tricks
 Future Ideas
 Optimize queries and function calls
 Measure non-cached page loading times.
 Optimize heavier pages.
 Reduce http calls.
 Turn on page caching system (AuthCache)
 Replace caching backend
 Test, Optmize , Test, Optmize, Test, Optimize
!!
 Use Pressflow!
 High speed drupal fork
▪ Optimized for PHP5 and Mysql (No
wrapper functions)
▪ Designed for Database replication and
Reverse proxies.
▪ Squid / Varnish
▪ Optimized in session and path handling
▪ Non Anon-Sessions (Lazy session creation)
▪ Fast path alias detection
 Avoid tons of calls to drupal_lookup_path.
 Use Devel
 Use xdebug.profiling.
 Identify heavier pages, functions and queries.
 Start by most visited pages
 Try to identify which functions are taking most
time.
 You’ll find a non pleasant detail
 Bootstrap in a normal site can be slow.
 Great to understand how drupal core works!
 Great to measure cost vs importance
Generic Drupal cache handling
 After activate Drupal caching:
 On Bootstrap until
DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE phase
Drupal verify if user is anonymous
▪ If so check if we have a valid cached page
▪ Delivery it without load all modules, render all regions... FAST!
 Blocks and some content is also cached, and can be
served to authenticated users.
 Cached content is stored in database tables
 Tables are flushed
 Nodes and comments are posted
 Cron runs
 Explicits calls to cache_clear_all
 However most of our traffic is authenticated
 We can’t use drupal base cache
 There’s a module for that ! => authcache
 AuthCache
 Register cookie variables on login like roles, login
name and login profile.
 On page_early_cache bootstrap verify if there’s a
cached version of that page to the roles the user
belongs.
 If there isn’t do full_bootstrap , render the page and
save a rendered version on cache to future usage.
 Include a setting in settings.php:
 Configure roles and pages to cache
 We are not caching anything to
editors/moderators, neither any page in admin
section or content edition.
 Be Careful with ajax stuff..
$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
 Small problem: all page looks the same to
everyone.
 We want to customize the header with a
pleasant message.
 Authcache recommendation is to do page
replacements using ajax calls => More http
calls
 To avoid http traffic I tweaked authcache
module to do a str_replace of a certain zone,
and start to store cached pages not gzipped.
 MySql is not designed to be used as a cache
backend.
 Fortunately Drupal allows pluggable cache
backends.
 We started by using cache router, using
memcached
 One bin for most cache table
 We ended up using memcache module because of
several crashs and white screens.
 Install MemCache, MemCache Pecl Extension
conf = array(
'memcache_servers' => array('localhost:11211' => 'default',
'localhost:11212' => 'cache_block',
'localhost:11213' => 'cache_page',
'localhost:11214' => 'users',
'localhost:11215' => 'session'),
'memcache_bins' => array('cache' => 'default',
'cache_block' => 'cache_block',
'cache_page' => 'cache_page',
'users'=>'users',
'session'=>'session'),
'memcache_key_prefix' => 'sb10prod',
);
$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
 On popular pages use custom cache!
 We are storing in cache_block to allow block
refresh when new content arrives.
if($content=cache_get('artigos:home:cronicas','cache_block')) {
$block->content=$content->data;
}
else {
$view=views_get_view('artigos');
$view->set_display('panel_pane_1');
$block->content=$view->render();
$block->content.='<span style="clear:both;float:right">'.l(t("View all"),'cronicas').'</span>’;
cache_set('artigos:home:cronicas',$block->content,'cache_block');
}
 Sessions Table was heavily used.
 We replace it with memcache session module.

 Serious dropdown on server load
 Pressflow already does not store sessions for
anon users => non_anon module does the
same.
UPDATE sessions SET uid = 1, cache = 0, hostname = '10.1.1.2', session = '', timestamp =
1243567406 WHERE sid = '74db42a7f35d1d54fc6b274ce840736e'
$conf['session_inc'] = './sites/all/modules/memcache/memcache-session.inc';
 In forum pages just call what is needed.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
$arg0=arg(0);
if($arg0=='forum’) {
require_once './includes/common.inc';
drupal_load('module','serbenfiquista');
drupal_load('module','filter');
drupal_load('module','locale');
require_once './includes/theme.inc';
$content=render_forum();
/*
do some load of modules when content not cached, vars will be available at theme
….
*/
require_once ('./sites/default/themes/serbenfiquista/page.tpl.php');
}
 Remember we were redirecting only non-
static content to apache
 What about css/js aggregated files and
imagecache files ? => They were going to
apache also..
$HTTP["url"] !~ ".(js|css|png|gif|jpg|ico|txt|swf)$" {
proxy.server = ( "" => (
(
"host" => ”localhost ", "port" => 81)
)
)
}
07/Nov/2010 –Things went bad
 Apache was handling too much connections.
 We were runnning out of memory, and no
more connections available...
 After that nightmare by night we decide to
switch to nginx.
.
 Using php in php-fpm mode
 Configuration based on perusio’s examples:
 https://github.com/perusio/drupal-with-nginx
 Using eAccelerator 0.9.5.3 as opcode cache to use shared
keys in memory used by SMF.
extension="eaccelerator.so”
eaccelerator.shm_size="300"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime=“0” #avoids to check if file has changed
eaccelerator.shm_max=”0
 Don’t forget to use Css and JS aggregation to avoid http
connections
 Index customization (Use EXPLAIN on your queries)
 Run cron twice a day
 Do not use cron to import feeds
 Use Apache Solr to index your content.
0 */12 * * * cd /var/www/html/ && drush core-cron >> /var/log/crondrupal
*/10 * * * * cd /var/www/html/ && drush feeds-refresh blogs >> /var/log/cronblogs
select title,created,nid from node use index(node_status_type) where status=1 and
type='usernews' order by created desc limit 0,4
 We have load peaks when some content is changed: most of
cached content is erased.
 Control in detail what is cached and expire only what is
invalid.
 Pre-Cache most page details.
 Use Cache Actions and Rules to clean specific views/blocks
/panes.
 When page is regenerated its components are already
rendered.
 I wish we could be more elastic by serving content from S3 or
other smaller webservers.
SerBenfiquista.com by:
Alberto Rodrigues, André Garcia, André
Sabino, André Marques, António Alves,
António Costa, Bernardo Azevedo,
Diogo Sarmento, Élvio da Silva,Filipe
Varela, Francisco Castro, Hugo Manita,
Hernâni Freitas, João Pessoa Jorge,
João Cunha, João Mariz, José Barata,
Isabel Cutileiro,, Luis Correia,Miguel
Ferreira, Nelson Vidal, Nuno Silva,
Paulo Paulos, Pedro Lança, Pedro
Neto, Rafael Santos, Rodrigo Marques,
Ricardo Martins, Ricardo Solnado,
Valter Gouveia
and plenty others !

Más contenido relacionado

La actualidad más candente

HPPG - high performance photo gallery
HPPG - high performance photo galleryHPPG - high performance photo gallery
HPPG - high performance photo galleryRemigijus Kiminas
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialWim Godden
 
Continuous deployment of puppet modules
Continuous deployment of puppet modulesContinuous deployment of puppet modules
Continuous deployment of puppet modulesWilliam O'Neill
 
Apache hadoop 2_installation
Apache hadoop 2_installationApache hadoop 2_installation
Apache hadoop 2_installationsushantbit04
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011Alfred Ayache
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Jun Hong Kim
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Serverwebhostingguy
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itOtto Kekäläinen
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeWim Godden
 
Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?Zaar Hai
 

La actualidad más candente (18)

Hppg
HppgHppg
Hppg
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
 
Memory Management in WordPress
Memory Management in WordPressMemory Management in WordPress
Memory Management in WordPress
 
HPPG - high performance photo gallery
HPPG - high performance photo galleryHPPG - high performance photo gallery
HPPG - high performance photo gallery
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Continuous deployment of puppet modules
Continuous deployment of puppet modulesContinuous deployment of puppet modules
Continuous deployment of puppet modules
 
Apache hadoop 2_installation
Apache hadoop 2_installationApache hadoop 2_installation
Apache hadoop 2_installation
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Cake php
Cake phpCake php
Cake php
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Server
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
 
Apache
ApacheApache
Apache
 
My sql administration
My sql administrationMy sql administration
My sql administration
 
My SQL 101
My SQL 101My SQL 101
My SQL 101
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?Apache ignite - a do-it-all key-value db?
Apache ignite - a do-it-all key-value db?
 

Destacado

Intro to drupal
Intro to drupalIntro to drupal
Intro to drupalhernanibf
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp Londonhernanibf
 
Drupal8 : novedades y nuevas funcionalidades
Drupal8 : novedades y nuevas funcionalidadesDrupal8 : novedades y nuevas funcionalidades
Drupal8 : novedades y nuevas funcionalidadesAlberto Permuy Leal
 
Obradoiro Drupal de 0 a 100 - Vigo 2015
Obradoiro Drupal de 0 a 100 - Vigo 2015Obradoiro Drupal de 0 a 100 - Vigo 2015
Obradoiro Drupal de 0 a 100 - Vigo 2015Alberto Permuy Leal
 
Drupal architectures for flexible content - Drupalcon Barcelona
Drupal architectures for flexible content - Drupalcon BarcelonaDrupal architectures for flexible content - Drupalcon Barcelona
Drupal architectures for flexible content - Drupalcon Barcelonahernanibf
 
A Cultura da Auga no proxecto Abeancos.gal
A Cultura da Auga no proxecto Abeancos.galA Cultura da Auga no proxecto Abeancos.gal
A Cultura da Auga no proxecto Abeancos.galAlberto Permuy Leal
 
Acquia Company Update on Drupal 8.2/8.3/OCTO
Acquia Company Update on Drupal 8.2/8.3/OCTOAcquia Company Update on Drupal 8.2/8.3/OCTO
Acquia Company Update on Drupal 8.2/8.3/OCTOAngela Byron
 
El universo JavaScript en Drupal 8
El universo JavaScript en Drupal 8El universo JavaScript en Drupal 8
El universo JavaScript en Drupal 8Ymbra
 
Drupal Developer Days Keynote
Drupal Developer Days KeynoteDrupal Developer Days Keynote
Drupal Developer Days KeynoteAngela Byron
 

Destacado (9)

Intro to drupal
Intro to drupalIntro to drupal
Intro to drupal
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp London
 
Drupal8 : novedades y nuevas funcionalidades
Drupal8 : novedades y nuevas funcionalidadesDrupal8 : novedades y nuevas funcionalidades
Drupal8 : novedades y nuevas funcionalidades
 
Obradoiro Drupal de 0 a 100 - Vigo 2015
Obradoiro Drupal de 0 a 100 - Vigo 2015Obradoiro Drupal de 0 a 100 - Vigo 2015
Obradoiro Drupal de 0 a 100 - Vigo 2015
 
Drupal architectures for flexible content - Drupalcon Barcelona
Drupal architectures for flexible content - Drupalcon BarcelonaDrupal architectures for flexible content - Drupalcon Barcelona
Drupal architectures for flexible content - Drupalcon Barcelona
 
A Cultura da Auga no proxecto Abeancos.gal
A Cultura da Auga no proxecto Abeancos.galA Cultura da Auga no proxecto Abeancos.gal
A Cultura da Auga no proxecto Abeancos.gal
 
Acquia Company Update on Drupal 8.2/8.3/OCTO
Acquia Company Update on Drupal 8.2/8.3/OCTOAcquia Company Update on Drupal 8.2/8.3/OCTO
Acquia Company Update on Drupal 8.2/8.3/OCTO
 
El universo JavaScript en Drupal 8
El universo JavaScript en Drupal 8El universo JavaScript en Drupal 8
El universo JavaScript en Drupal 8
 
Drupal Developer Days Keynote
Drupal Developer Days KeynoteDrupal Developer Days Keynote
Drupal Developer Days Keynote
 

Similar a Drupal Performance - SerBenfiquista.com Case Study

Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and ScalabilityMediacurrent
 
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelАртем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelLEDC 2016
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceAshok Modi
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Wim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
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
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Serversupertom
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101Angus Li
 
Optimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksOptimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksTimur Kamanin
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Thijs Feryn
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Codemotion
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019Anam Ahmed
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkBryan Ollendyke
 
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web SitesRavi Raj
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersSeravo
 
Challenges when building high profile editorial sites
Challenges when building high profile editorial sitesChallenges when building high profile editorial sites
Challenges when building high profile editorial sitesYann Malet
 

Similar a Drupal Performance - SerBenfiquista.com Case Study (20)

Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelАртем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performance
 
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ phpBenelux 2011
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
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
 
Apache Traffic Server
Apache Traffic ServerApache Traffic Server
Apache Traffic Server
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Optimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksOptimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and Tricks
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Pure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talkPure Speed Drupal 4 Gov talk
Pure Speed Drupal 4 Gov talk
 
High Performance Web Sites
High Performance Web SitesHigh Performance Web Sites
High Performance Web Sites
 
Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
Challenges when building high profile editorial sites
Challenges when building high profile editorial sitesChallenges when building high profile editorial sites
Challenges when building high profile editorial sites
 

Más de hernanibf

Drupal Europe 2018: Hackers automate but the drupal community still downloads...
Drupal Europe 2018: Hackers automate but the drupal community still downloads...Drupal Europe 2018: Hackers automate but the drupal community still downloads...
Drupal Europe 2018: Hackers automate but the drupal community still downloads...hernanibf
 
Aiming for automatic updates - Drupal Dev Days Lisbon 2018
Aiming for automatic updates - Drupal Dev Days Lisbon 2018Aiming for automatic updates - Drupal Dev Days Lisbon 2018
Aiming for automatic updates - Drupal Dev Days Lisbon 2018hernanibf
 
Deployer - Deployment tool for PHP
Deployer - Deployment tool for PHPDeployer - Deployment tool for PHP
Deployer - Deployment tool for PHPhernanibf
 
Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibilityhernanibf
 
One drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp CaceresOne drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp Cacereshernanibf
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon praguehernanibf
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013hernanibf
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Oxford DrupalCamp 2012 - The things we found in your website
Oxford DrupalCamp 2012 - The things we found in your websiteOxford DrupalCamp 2012 - The things we found in your website
Oxford DrupalCamp 2012 - The things we found in your websitehernanibf
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your websitehernanibf
 
Acquia Commons
Acquia CommonsAcquia Commons
Acquia Commonshernanibf
 
Drupal + selenium
Drupal + seleniumDrupal + selenium
Drupal + seleniumhernanibf
 
Drupal Recipe
Drupal RecipeDrupal Recipe
Drupal Recipehernanibf
 

Más de hernanibf (13)

Drupal Europe 2018: Hackers automate but the drupal community still downloads...
Drupal Europe 2018: Hackers automate but the drupal community still downloads...Drupal Europe 2018: Hackers automate but the drupal community still downloads...
Drupal Europe 2018: Hackers automate but the drupal community still downloads...
 
Aiming for automatic updates - Drupal Dev Days Lisbon 2018
Aiming for automatic updates - Drupal Dev Days Lisbon 2018Aiming for automatic updates - Drupal Dev Days Lisbon 2018
Aiming for automatic updates - Drupal Dev Days Lisbon 2018
 
Deployer - Deployment tool for PHP
Deployer - Deployment tool for PHPDeployer - Deployment tool for PHP
Deployer - Deployment tool for PHP
 
Drupal content editor flexibility
Drupal content editor flexibilityDrupal content editor flexibility
Drupal content editor flexibility
 
One drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp CaceresOne drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp Caceres
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon prague
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013
 
My site is slow
My site is slowMy site is slow
My site is slow
 
Oxford DrupalCamp 2012 - The things we found in your website
Oxford DrupalCamp 2012 - The things we found in your websiteOxford DrupalCamp 2012 - The things we found in your website
Oxford DrupalCamp 2012 - The things we found in your website
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your website
 
Acquia Commons
Acquia CommonsAcquia Commons
Acquia Commons
 
Drupal + selenium
Drupal + seleniumDrupal + selenium
Drupal + selenium
 
Drupal Recipe
Drupal RecipeDrupal Recipe
Drupal Recipe
 

Último

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Último (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Drupal Performance - SerBenfiquista.com Case Study

  • 1. Drupal Performance - Case Study Hernâni Borges de Freitas – Drupal PT Meetup – Porto, 27th November
  • 2.  Biggest online fan community about Sport Lisboa e Benfica.  About 10 years old, online since 01/05/2001  Done as hobby by:  Staff (20 people among editors and moderators)  Members (~31 000 users, 8000 Active Members)  Articles, blog aggregation, image gallery, forum, press aggregation, matches and players’ profiles.
  • 3.  Average per day (October 2010)  8000 Visits per Day  185 000 PageViews  12 pages per Session (!)  3500 messages per day.  50 blogs aggregated.
  • 4.  According to Alexa.com (Oct 2010)  150th most visited website in Portugal.  On top 50 portuguese websites.  Most popular portuguese website made in DRUPAL!
  • 5.  Technology was slowing us down  Custom designed cms, with 10 years legacy code and cache control based in smarty.  Site must be done by community  Workflow and revision process was weak and unsafe  Developments took to much time  Hard to implement or change existing features.  Performance problems on traffic peaks  Around 1700 users at same time.
  • 6.  Dedicated Server  Quad Xeon 2,4 Ghz  4 Gb Memory  Lighttpd/Apache as App Server  Php with eAccelerator.  Most of pageviews are seen by registered users.  Most pageviews are generated by forum (based on Simple Machines Forum).  Cache control was made using smarty and forum cache system.
  • 7.  Development started in August 2010  Done on spare time by 1 Drupalista.  We went live in 24th October 2010 (2 months ...)  Website redone from scratch  Data migration done used custom scripts  60k nodes, 30k users, 2,5k terms, 16 content types  100 modules  Portuguese/English , Web/Mobile Site
  • 8.  Optimize using iterative improvements (Progressive Doping)  Architecture  Profiling  Caching  Application diet  WebServer Change  Drupal Tips and Tricks  Future Ideas
  • 9.  Optimize queries and function calls  Measure non-cached page loading times.  Optimize heavier pages.  Reduce http calls.  Turn on page caching system (AuthCache)  Replace caching backend  Test, Optmize , Test, Optmize, Test, Optimize !!
  • 10.  Use Pressflow!  High speed drupal fork ▪ Optimized for PHP5 and Mysql (No wrapper functions) ▪ Designed for Database replication and Reverse proxies. ▪ Squid / Varnish ▪ Optimized in session and path handling ▪ Non Anon-Sessions (Lazy session creation) ▪ Fast path alias detection  Avoid tons of calls to drupal_lookup_path.
  • 11.  Use Devel  Use xdebug.profiling.  Identify heavier pages, functions and queries.  Start by most visited pages  Try to identify which functions are taking most time.  You’ll find a non pleasant detail  Bootstrap in a normal site can be slow.  Great to understand how drupal core works!  Great to measure cost vs importance
  • 13.  After activate Drupal caching:  On Bootstrap until DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE phase Drupal verify if user is anonymous ▪ If so check if we have a valid cached page ▪ Delivery it without load all modules, render all regions... FAST!  Blocks and some content is also cached, and can be served to authenticated users.  Cached content is stored in database tables  Tables are flushed  Nodes and comments are posted  Cron runs  Explicits calls to cache_clear_all
  • 14.  However most of our traffic is authenticated  We can’t use drupal base cache  There’s a module for that ! => authcache  AuthCache  Register cookie variables on login like roles, login name and login profile.  On page_early_cache bootstrap verify if there’s a cached version of that page to the roles the user belongs.  If there isn’t do full_bootstrap , render the page and save a rendered version on cache to future usage.
  • 15.  Include a setting in settings.php:  Configure roles and pages to cache  We are not caching anything to editors/moderators, neither any page in admin section or content edition.  Be Careful with ajax stuff.. $conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
  • 16.  Small problem: all page looks the same to everyone.  We want to customize the header with a pleasant message.  Authcache recommendation is to do page replacements using ajax calls => More http calls  To avoid http traffic I tweaked authcache module to do a str_replace of a certain zone, and start to store cached pages not gzipped.
  • 17.  MySql is not designed to be used as a cache backend.  Fortunately Drupal allows pluggable cache backends.  We started by using cache router, using memcached  One bin for most cache table  We ended up using memcache module because of several crashs and white screens.
  • 18.  Install MemCache, MemCache Pecl Extension conf = array( 'memcache_servers' => array('localhost:11211' => 'default', 'localhost:11212' => 'cache_block', 'localhost:11213' => 'cache_page', 'localhost:11214' => 'users', 'localhost:11215' => 'session'), 'memcache_bins' => array('cache' => 'default', 'cache_block' => 'cache_block', 'cache_page' => 'cache_page', 'users'=>'users', 'session'=>'session'), 'memcache_key_prefix' => 'sb10prod', ); $conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
  • 19.  On popular pages use custom cache!  We are storing in cache_block to allow block refresh when new content arrives. if($content=cache_get('artigos:home:cronicas','cache_block')) { $block->content=$content->data; } else { $view=views_get_view('artigos'); $view->set_display('panel_pane_1'); $block->content=$view->render(); $block->content.='<span style="clear:both;float:right">'.l(t("View all"),'cronicas').'</span>’; cache_set('artigos:home:cronicas',$block->content,'cache_block'); }
  • 20.  Sessions Table was heavily used.  We replace it with memcache session module.   Serious dropdown on server load  Pressflow already does not store sessions for anon users => non_anon module does the same. UPDATE sessions SET uid = 1, cache = 0, hostname = '10.1.1.2', session = '', timestamp = 1243567406 WHERE sid = '74db42a7f35d1d54fc6b274ce840736e' $conf['session_inc'] = './sites/all/modules/memcache/memcache-session.inc';
  • 21.  In forum pages just call what is needed. require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); $arg0=arg(0); if($arg0=='forum’) { require_once './includes/common.inc'; drupal_load('module','serbenfiquista'); drupal_load('module','filter'); drupal_load('module','locale'); require_once './includes/theme.inc'; $content=render_forum(); /* do some load of modules when content not cached, vars will be available at theme …. */ require_once ('./sites/default/themes/serbenfiquista/page.tpl.php'); }
  • 22.  Remember we were redirecting only non- static content to apache  What about css/js aggregated files and imagecache files ? => They were going to apache also.. $HTTP["url"] !~ ".(js|css|png|gif|jpg|ico|txt|swf)$" { proxy.server = ( "" => ( ( "host" => ”localhost ", "port" => 81) ) ) }
  • 24.  Apache was handling too much connections.  We were runnning out of memory, and no more connections available...  After that nightmare by night we decide to switch to nginx. .
  • 25.  Using php in php-fpm mode  Configuration based on perusio’s examples:  https://github.com/perusio/drupal-with-nginx  Using eAccelerator 0.9.5.3 as opcode cache to use shared keys in memory used by SMF. extension="eaccelerator.so” eaccelerator.shm_size="300" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime=“0” #avoids to check if file has changed eaccelerator.shm_max=”0
  • 26.  Don’t forget to use Css and JS aggregation to avoid http connections  Index customization (Use EXPLAIN on your queries)  Run cron twice a day  Do not use cron to import feeds  Use Apache Solr to index your content. 0 */12 * * * cd /var/www/html/ && drush core-cron >> /var/log/crondrupal */10 * * * * cd /var/www/html/ && drush feeds-refresh blogs >> /var/log/cronblogs select title,created,nid from node use index(node_status_type) where status=1 and type='usernews' order by created desc limit 0,4
  • 27.  We have load peaks when some content is changed: most of cached content is erased.  Control in detail what is cached and expire only what is invalid.  Pre-Cache most page details.  Use Cache Actions and Rules to clean specific views/blocks /panes.  When page is regenerated its components are already rendered.  I wish we could be more elastic by serving content from S3 or other smaller webservers.
  • 28. SerBenfiquista.com by: Alberto Rodrigues, André Garcia, André Sabino, André Marques, António Alves, António Costa, Bernardo Azevedo, Diogo Sarmento, Élvio da Silva,Filipe Varela, Francisco Castro, Hugo Manita, Hernâni Freitas, João Pessoa Jorge, João Cunha, João Mariz, José Barata, Isabel Cutileiro,, Luis Correia,Miguel Ferreira, Nelson Vidal, Nuno Silva, Paulo Paulos, Pedro Lança, Pedro Neto, Rafael Santos, Rodrigo Marques, Ricardo Martins, Ricardo Solnado, Valter Gouveia and plenty others !

Notas del editor

  1. Verificar como é que os blocos são cached
  2. Verificar como é que os blocos são cached Verificar em que fase do bootstrap sao feitas as verificações
  3. Verificar como é que os blocos são cached Verificar em que fase do bootstrap sao feitas as verificações
  4. Verificar como é que os blocos são cached Verificar em que fase do bootstrap sao feitas as verificações
  5. Estudar diferença entre bins e servers
  6. Ver que código quero mostrar.