WWLLC
Create Drupal sites with good
performance
What Would Lucky Luke Code
HenrikDeveloperMostly backendFrontHenrik
FrankWeb designerMostly front-endfragje
Per Andreacute RoslashnsenCIOChief Innovation Officer
Fredrik PausCOOProject Manager
Thor Andreacute GretlandSupport amp Training
Geir GullandCEO Web strategist
Frank GjertsenWeb Designer
Eacutelio CroacuteWeb Developer
Roberto OrnelasCTO Senior developer
Heacutelder MendesWeb Designer
Elisabeth GullandAccountant
Henrik AkselsenJSMobile UX
Jan-Helge HansenInfrastructure support
Faacutebio NevesWeb developer
Marco Fernandes Senior Web developer
Bruno CamposWeb developer
WilmaQA Engineer )
The frontkom family
Fredrikstad | Madeira
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
HenrikDeveloperMostly backendFrontHenrik
FrankWeb designerMostly front-endfragje
Per Andreacute RoslashnsenCIOChief Innovation Officer
Fredrik PausCOOProject Manager
Thor Andreacute GretlandSupport amp Training
Geir GullandCEO Web strategist
Frank GjertsenWeb Designer
Eacutelio CroacuteWeb Developer
Roberto OrnelasCTO Senior developer
Heacutelder MendesWeb Designer
Elisabeth GullandAccountant
Henrik AkselsenJSMobile UX
Jan-Helge HansenInfrastructure support
Faacutebio NevesWeb developer
Marco Fernandes Senior Web developer
Bruno CamposWeb developer
WilmaQA Engineer )
The frontkom family
Fredrikstad | Madeira
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
FrankWeb designerMostly front-endfragje
Per Andreacute RoslashnsenCIOChief Innovation Officer
Fredrik PausCOOProject Manager
Thor Andreacute GretlandSupport amp Training
Geir GullandCEO Web strategist
Frank GjertsenWeb Designer
Eacutelio CroacuteWeb Developer
Roberto OrnelasCTO Senior developer
Heacutelder MendesWeb Designer
Elisabeth GullandAccountant
Henrik AkselsenJSMobile UX
Jan-Helge HansenInfrastructure support
Faacutebio NevesWeb developer
Marco Fernandes Senior Web developer
Bruno CamposWeb developer
WilmaQA Engineer )
The frontkom family
Fredrikstad | Madeira
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Per Andreacute RoslashnsenCIOChief Innovation Officer
Fredrik PausCOOProject Manager
Thor Andreacute GretlandSupport amp Training
Geir GullandCEO Web strategist
Frank GjertsenWeb Designer
Eacutelio CroacuteWeb Developer
Roberto OrnelasCTO Senior developer
Heacutelder MendesWeb Designer
Elisabeth GullandAccountant
Henrik AkselsenJSMobile UX
Jan-Helge HansenInfrastructure support
Faacutebio NevesWeb developer
Marco Fernandes Senior Web developer
Bruno CamposWeb developer
WilmaQA Engineer )
The frontkom family
Fredrikstad | Madeira
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Fredrikstad | Madeira
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Agenda
Why performance Analysis Frontend Server configuration Backend Your inputs
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
SHOWTIME
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
We got fast internet connections Powerful computers Shiny large screens
hellipbut wait we got mobilehellipand bad mobile connectionshellipand emerging markets which are mobile only
Why performance now
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Today the average page is 15MB Expect to increase by 21 the next year
Oakley released their new site 80MB
Web pages are getting FAT
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
When to start
We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
Post-optimization is the root of all evil Lack of performance = Lack of planning Bad performance is bad business
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
We need to analyze this
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
ldquoYeah itrsquos slow but itrsquos probably just [insert wild speculation here]rdquo
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Hold your assumptions
A lot of the time your assumption will be wrong and cause a lot of wasted effort
Let the data guide the optimizing process Use the 8020 rule =gt find low hanging fruit
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Tools
Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout
httpwwwquicksproutcom WebPageTest
httpwwwwebpagetestorg
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Chrome Dev Tools
FrontendIntroduction to dev toolshttpbitlydiscover-devtools
ldquoThe Breakpointrdquo Paul Irish Addy Osmani
Indepth analysis
XHProf (Backend)
Find out which functions that are using memory and processor time
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Mobile first
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Start small Add style and content as you get more space without limiting the user experiencehttpbradfrostwebcomdemomobile-first
Build systems instead of individual pages Write reusable code
Mobile first
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Download as few MB as possible Reduce requested files Images css js Concatenate and minify css and js Make sprites
Compass does this in a smart wayhellip Or use icon fonts
httpiconmoonio or even better httpfontasticme
Mobile first
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
HTML
Take control over your markup Customize markup in your tplphp Find design patterns and add classes to
similar elements In views it can be customized directly on
other output use templatephp
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 blockgtltsectiongt
ltsection class=panel-pane pane-views-panes pane-commons-activity-streams-activity-panel-pane-1 blockgtltsectiongt
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
function theme_preprocess_panels_pane(amp$vars)
switch ($vars[pane]-gtpid)
case 14
$vars[classes_array][] = box-default
break
case 8
$vars[classes_array] = array(box-default)
break
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
ltsection class=panel-pane pane-views-panes pane-commons-featured-panel-pane-1 block box-defaultgt ltsectiongt
ltsection class=box-defaultgt ltsectiongt
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Useful gh-repohttpbitlytemplate-php
by Jesper Woslashldiche Rahkonen
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
ltdiv class=field field-name-field-test field-type-text field-label-abovegt
ltdiv class=field-labelgtFoobar fieldampnbspltdivgt
ltdiv class=field-itemsgt
ltdiv class=field-item evengtDrupal default fields markupltdivgt
ltdivgt
ltdivgt
Default fields markup
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
lth3 class=field-labelgtFoobar fieldlth3gt
ltdiv class=field-foobargtLeaner markup means better front-end performanceltdivgt
After fences config
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Modules Clean Markup - Blocks Panel panes Panel regions
Panel layoutshttpsdrupalorgprojectclean_markup
Fences - clean fields markup globalyhttpsdrupalorgprojectfences
Clean markup
Themes Mothership
httpsdrupalorgprojectmothership Aurora
httpsdrupalorgprojectaurora
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Write as little as possible Use classes instad of tags
ul li a nav-main nav-item httpbitlyquick-selectors
Css can get out of control and hard to manage when a page scales
CSS
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
SMACSS A must read for all
working with css Part of the book is
available online for freehttpsmacsscom
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
by Brad Frost
httppattern-labinfo
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
LESS Stylus Sass
Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids without limits
Preprocess that CSS
WARNINGAlways check your output
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
btn-default
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
extend btn-default
background-color dodgerblue
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
btn-default btn-cta
text-align center
display inline-block
background-color gray
padding 5px 10px
color white
btn-cta
background-color dodgerblue
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Donrsquot load js before css Donrsquot load libraries you donrsquot need and if
possible make custom builds to your needs Eg Modernizr
Try to move most of your js at the bottom of your page just before ltbodygt There is a special Drupal module for this
Avoid unnecessary dom manipulations
Javascript
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
MAGIChttpsdrupalorgprojectmagic
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
var div = documentgetElementById(to-measure) lis = documentgetElementsByTagName(li) i len
for (i = 0 len = lislength i lt len i++) lis[i]stylewidth = divoffsetWidth + px
Avoid calculations in loops
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Edge side includes Image lazy loading
Improve Perceived performance
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Tweak it up
Configuration
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Hosting
Geography - Closer is better (Sorry New Zealand)
SSD is awesome Quick and good support
(Sorry New Zealand) Consider dedicated Drupal hosting
Fx Pantheon (has great workflow)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
PHP amp MySQL
PHP version newer is betterInnoDB gt Myisam
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
- Opcode cache- Easy setup huge performance win- See httpsdrupalorgnode1777090 for configuration tips for Drupal- Remember to assign enough memory or the cache will not have any effect
APC
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Improves editor experience + faster site building
Memcache module not needed just include in settingsphp
Alternative Redis
Memcache(d)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
the path to the core cache file
include_once(includescacheinc)
the path to the memcache cache file
include_once
(sitesallmodulescontribmemcachememcacheinc)
make MemCacheDrupal the default cache class
$conf[cache_default_class] = MemCacheDrupal
$conf[memcache_servers] = array(12700111211 =gt default)
$conf[memcache_bins] = array(cache =gt default)
$conf[memcache_key_prefix] = mysite
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
First time using memcache
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
VarnishBoost(poor manrsquos Varnish)
Gzip
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
CDN Amazon AWS for static files and images Web Application Streaming
new tech possible ldquoCDN killerrdquo) from InstartLogic
High performance with cloud
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Drupal
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Good places to hang out
high performance group on do Contrib modules
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
As few modules as possible Avoid the buffet syndrome
Check which hooks are used hook_init() is more important to watch than
hook_openid_normalization_method_info_alter() Preferred Measure beforeafter install
Dive into xhprof Disable suspected performance hogs
Module strategy
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Check that page cache is not being disabled drupal_page_is_cacheable(FALSE) $GLOBALS[conf][cache] = 0 $GLOBALS[conf][cache] = CACHE_DISABLED $conf[cache] = FALSE flags module captcha module
(This may have to be necessary but at least know that it is happening)
Module strategy
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Keep an eye on the dblogs May slow down disk if constantly logging
errors May point to underlying errors Bad Karma Tip Get sent an email on each log error
Watch the Logs
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Cache
Views Cache PHP blocks breaks cache D7 contrib provides a lot D8 Much more flexible out of the box
pluggable CSS and JavaScript optimization personalize through JavaScript Entity Cache
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Avoid logic in the theme layer hurts page cache
Avoid heavy processes in the theme layer node_load sql queries
Tip Switch to another theme and do performance tests again
Be kind to the theme layer
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Views queries
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Find candidates for optimizing
[mysqld]
log_slow_queries=ApplicationsMAMPlogsmysql_sql_slowlog
long_query_time=05
LOTS OF JOINS
SELECT FROM mother_of_all_huge_tables
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Keep an eye on
PAGERS DISTINCT COUNT JOINS
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Battle plan Find JOINS and see if you can do the same within SELECT
Tip use EXPLAIN on views sql
How many evaluations
Optimize Views Queries
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
No JOIN
select nid FROM node
200005 rows in set (008 sec)
Data from astonishdesigncom
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
1 JOIN
select nnid sfield_school_name_format
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
200005 rows in set (109 sec)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
2 JOINS
select nnid sfield_school_name_format sifield_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
200005 rows in set (203 sec)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
3 JOINSselect nnid sfield_school_name_format sifield_school_id_value
spfield_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON nnid = sentity_id
LEFT JOIN field_data_field_school_id si on nnid = sientity_id
LEFT JOIN field_data_field_school_phone sp on nnid = spentity_id
200005 rows in set (503 sec)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Optimize in hook_views_query_alter() and hook_view_query_substitutions()
Consider making views into a module Easier to optimize + easier version control
Optimize Views Queries
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Defer heavy tasks Push heavy tasks to cron Batch API
Fast 404
Specific use cases
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Good PHP habits
httpwwwphpbenchcom
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Stats
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Bring out the big guns
Ditch the theme layer
Example NewsFront
Now itrsquos your turn -)
Now itrsquos your turn -)
Recommended