SlideShare a Scribd company logo
WWLLC
What Would
Lucky Luke Code?

Create Drupal sites
with good
performance
Henrik
Developer
Mostly backend
@FrontHenrik
Frank
Web designer
Mostly front-end
@fragje
The frontkom family
Per André Rønsen

Marco Fernandes

CIO/Chief Innovation Officer

Senior Web developer

Fredrik Paus

Élio Cró

Jan-Helge Hansen

COO/Project Manager

Web Developer

Infrastructure / support

Thor André Gretland

Roberto Ornelas

Support & Training

CTO Senior developer

Fábio Neves

Geir Gulland

Hélder Mendes

Bruno Campos

CEO / Web strategist

Web Designer

Web developer

Frank Gjertsen

Elisabeth Gulland

Wilma

Web Designer

Accountant

QA Engineer ;)

Henrik Akselsen
JS/Mobile UX

Web developer
Fredrikstad | Madeira
Agenda
●
●
●
●
●
●

Why performance?
Analysis
Frontend
Server configuration
Backend
Your inputs
SHOWTIME
Why performance now?
● We got fast internet connections
● Powerful computers
● Shiny large screens
…but wait, we got mobile.
…and bad mobile connections.
…and emerging markets which are mobile only.
Web pages are getting

FAT

1.5MB
Expect to increase by 21% the next year

● Today the average page is
●

● Oakley released their new site.

80MB
When to start?
● Post-optimization is the root of all evil
● Lack of performance = Lack of planning
● Bad performance is bad business
●
●
●
●

We need our clients interest in performance
Show visually how a page loads
Make a performance budget
Plan performance from the beginning
We need to analyze this
“Yeah, it’s slow, but it’s probably just
[insert wild speculation here]”
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 80/20 rule => find low hanging fruit
Tools
●
●
●
●

Web developer tools in your browsers
PageSpeed (Google)
Yslow (Yahoo)
Quicksprout
http://www.quicksprout.com/
● WebPageTest
http://www.webpagetest.org/
Drupalcamp performance
Drupalcamp performance
Indepth analysis
Chrome Dev Tools

XHProf (Backend)

Frontend
Introduction to dev tools
http://bit.ly/discover-devtools

Find out which functions
that are using memory and
processor time

“The Breakpoint”
Paul Irish / Addy Osmani
Mobile first
Mobile first
● Start small. Add style and content as you get
more space, without limiting the user
experience.
http://bradfrostweb.com/demo/mobile-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 way…

● Or use icon fonts
○ http://iconmoon.io
○ or even better http://fontastic.me
HTML
● Take control over your markup
● Customize markup in your tpl.php
● Find design patterns and add classes to
similar elements.
● In views it can be customized directly, on
other output use template.php
<section class="panel-pane paneviews-panes pane-commons-featuredpanel-pane-1 block">...</section>
<section class="panel-pane paneviews-panes pane-commons-activitystreams-activity-panel-pane-1
block">...</section>
function theme_preprocess_panels_pane(&$vars) {
switch ($vars['pane']->pid) {
case '14':
$vars['classes_array'][] = 'box-default';
break;
case '8':
$vars['classes_array'] = array('box-default');
break;
}
}
<section class="panel-pane paneviews-panes pane-commons-featuredpanel-pane-1 block box-default">
... </section>
<section class="box-default"> ...
</section>
Useful gh-repo

http://bit.ly/template-php
by Jesper Wøldiche Rahkonen
Clean markup
● Modules
○ Clean Markup - Blocks, Panel panes, Panel regions,
Panel layouts
https://drupal.org/project/clean_markup
○ Fences - clean fields markup globaly.
https://drupal.org/project/fences
Default fields markup

<div class="field field-name-field-test
field-type-text field-label-above">
<div class="field-label">Foobar field:
&nbsp;</div>
<div class="field-items">
<div class="field-item even">Drupal
default fields markup.</div>
</div>
</div>
After fences config

<h3 class="field-label">Foobar
field</h3>
<div class="field-foobar">Leaner markup
means better front-end performance.
</div>
Clean markup
● Modules
○ Clean Markup - Blocks, Panel panes, Panel regions,
Panel layouts
https://drupal.org/project/clean_markup
○ Fences - clean fields markup globaly.
https://drupal.org/project/fences

● Themes
○ Mothership
https://drupal.org/project/mothership
○ Aurora
https://drupal.org/project/aurora
CSS
● Write as little as possible
● Use classes instad of tags
○ ul li a {}
○ .nav-main .nav-item {}
○ http://bit.ly/quick-selectors

● Css can get out of control and hard to
manage when a page scales
.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 free
http://smacss.com
http://pattern-lab.info
by Brad Frost
Preprocess that CSS
● LESS
● Stylus
● Sass
○
○
○
○

WARNING!

Compass - Sass mixins library and much more
Breakpoint - Really Simple Media Queries with Sass
Toolkit - swiss army knife for PE and RWD
Singularity - Grids withoutyour output
Always check limits
.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;
}
Javascript
● Don’t load js before css
● Don’t load libraries you don’t need, and if
possible make custom builds to your needs.
E.g. Modernizr.
● Try to move most of your js at the bottom of
your page, just before </body>. There is a
special Drupal module for this.
● Avoid unnecessary dom manipulations
MAGIC

https://drupal.org/project/magic
Avoid calculations in loops
var div = document.getElementById("to-measure"),
lis = document.getElementsByTagName('li'),
i, len;
for (i = 0, len = lis.length; i < len; i++) {
lis[i].style.width = div.offsetWidth + 'px';
}
Improve Perceived performance
● Edge side includes
● Image lazy loading
Configuration
Tweak it up
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 & MySQL
PHP version: newer is better
InnoDB > Myisam
APC
- Opcode cache
- Easy setup, huge performance win
- See https://drupal.org/node/1777090 for
configuration tips for Drupal
- Remember to assign enough memory, or the
cache will not have any effect
Memcache(d)
Improves editor experience + faster site
building
Memcache module not needed, just include in
settings.php
Alternative: Redis
// the path to the core cache file
include_once('./includes/cache.inc');
// the path to the memcache cache file
include_once
('./sites/all/modules/contrib/memcache/memcache.inc');
// make MemCacheDrupal the default cache class
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_servers'] = array('127.0.0.1:11211' =>
'default');
$conf['memcache_bins'] = array('cache' => 'default');
$conf['memcache_key_prefix'] = 'mysite';
First time using memcache
Varnish

Boost
(poor man’s
Varnish)

Gzip
High performance with cloud
● CDN
● Amazon AWS for static files and images
● Web Application Streaming
○ new tech, possible “CDN killer”)
○ from InstartLogic
Drupal
Drupalcamp performance
Drupalcamp performance
Drupalcamp performance
Good places to hang out
● high performance group on d.o
● Contrib modules
Module strategy
● 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 before/after 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)
Watch the Logs

● 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
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
Drupalcamp performance
Be kind to the theme layer
● 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
Drupalcamp performance
Views queries
Drupalcamp performance
Find candidates for optimizing
[mysqld]
log_slow_queries=/Applications/MAMP/logs/mys
ql_sql_slow.log
long_query_time=0.5
LOTS OF JOINS
SELECT * FROM mother_of_all_huge_tables
Keep an eye on

PAGERS DISTINCT COUNT JOINS
Optimize Views Queries
Battle plan: Find JOINS
and see if you can do
the same within SELECT
Tip: use EXPLAIN on
views sql
How many evaluations
No JOIN
select nid FROM node;
200005 rows in set (0.08 sec)

Data from astonishdesign.com
1 JOIN
select n.nid, s.
field_school_name_format
FROM node n
LEFT JOIN
field_data_field_school_name s ON
n.nid = s.entity_id;
200005 rows in set (1.09 sec)
2 JOINS
select n.nid, s.field_school_name_format,
si.field_school_id_value
FROM node n
LEFT JOIN field_data_field_school_name s ON
n.nid = s.entity_id
LEFT JOIN field_data_field_school_id si on
n.nid = si.entity_id;
200005 rows in set (2.03 sec)
3 JOINS
select n.nid, s.field_school_name_format, si.
field_school_id_value,
sp.field_school_phone_value
FROM node n
LEFT JOIN field_data_field_school_name s ON n.nid = s.
entity_id
LEFT JOIN field_data_field_school_id si on n.nid = si.
entity_id
LEFT JOIN field_data_field_school_phone sp on n.nid = sp.
entity_id;
200005 rows in set (

5.03 sec)
Optimize Views Queries
● Optimize in hook_views_query_alter() and
hook_view_query_substitutions()

● Consider making views into a module
○ Easier to optimize + easier version control
Specific use cases
● Defer heavy tasks
○ Push heavy tasks to cron
○ Batch API

● Fast 404
Good PHP habits
http://www.phpbench.com/
Stats
Performance module
New Relic
Load testing with jMeter (+Blazemeter)
Bring out the big guns

● Ditch the theme
layer
● Example: NewsFront
Now it’s your turn ;-)
Ad

More Related Content

What's hot (17)

collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
tutorialsruby
 
HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using BootstrapStop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
freshlybakedpixels
 
Web Fundamentals Crash Course
Web Fundamentals Crash CourseWeb Fundamentals Crash Course
Web Fundamentals Crash Course
MrAbas
 
Forensic Theming for Drupal
Forensic Theming for DrupalForensic Theming for Drupal
Forensic Theming for Drupal
Emma Jane Hogbin Westby
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Emma Jane Hogbin Westby
 
HTML5
HTML5HTML5
HTML5
Brad Touesnard
 
Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016
Cristina Chumillas
 
Web Performance: 3 Stages to Success
Web Performance: 3 Stages to SuccessWeb Performance: 3 Stages to Success
Web Performance: 3 Stages to Success
Austin Gil
 
Backbone
BackboneBackbone
Backbone
Ynon Perek
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
Vittorio Vittori
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSS
Todd Anglin
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
philogb
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)
Zoe Gillenwater
 
Improving Drupal's Page Loading Performance
Improving Drupal's Page Loading PerformanceImproving Drupal's Page Loading Performance
Improving Drupal's Page Loading Performance
Wim Leers
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
Joe Seifi
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
tutorialsruby
 
HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using BootstrapStop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
freshlybakedpixels
 
Web Fundamentals Crash Course
Web Fundamentals Crash CourseWeb Fundamentals Crash Course
Web Fundamentals Crash Course
MrAbas
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Emma Jane Hogbin Westby
 
Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016Improving the Responsive Web Design Process in 2016
Improving the Responsive Web Design Process in 2016
Cristina Chumillas
 
Web Performance: 3 Stages to Success
Web Performance: 3 Stages to SuccessWeb Performance: 3 Stages to Success
Web Performance: 3 Stages to Success
Austin Gil
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
Vittorio Vittori
 
Doing More with LESS for CSS
Doing More with LESS for CSSDoing More with LESS for CSS
Doing More with LESS for CSS
Todd Anglin
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
philogb
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)
Zoe Gillenwater
 
Improving Drupal's Page Loading Performance
Improving Drupal's Page Loading PerformanceImproving Drupal's Page Loading Performance
Improving Drupal's Page Loading Performance
Wim Leers
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
Joe Seifi
 

Similar to Drupalcamp performance (20)

Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
Twinbit
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Extending CMS Made Simple
Extending CMS Made SimpleExtending CMS Made Simple
Extending CMS Made Simple
cmsmssjg
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Toronto
dmethvin
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
Marcos Labad
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
Angus Li
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
nuppla
 
Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...
MilanAryal
 
Neoito — How modern browsers work
Neoito — How modern browsers workNeoito — How modern browsers work
Neoito — How modern browsers work
Neoito
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
JavaScript Meetup HCMC
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
Alessandro Molina
 
Does my DIV look big in this?
Does my DIV look big in this?Does my DIV look big in this?
Does my DIV look big in this?
glen_a_smith
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
David Zapateria Besteiro
 
To build a WordPress Theme: Wordcamp Denmark 2014
To build a WordPress Theme: Wordcamp Denmark 2014To build a WordPress Theme: Wordcamp Denmark 2014
To build a WordPress Theme: Wordcamp Denmark 2014
James Bonham
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
Nicolas Embleton
 
Tech meetup: Web Applications Performance
Tech meetup: Web Applications PerformanceTech meetup: Web Applications Performance
Tech meetup: Web Applications Performance
Santex Group
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
Philip Norton
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
Philip Norton
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
Twinbit
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Extending CMS Made Simple
Extending CMS Made SimpleExtending CMS Made Simple
Extending CMS Made Simple
cmsmssjg
 
jQuery Conference Toronto
jQuery Conference TorontojQuery Conference Toronto
jQuery Conference Toronto
dmethvin
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
Marcos Labad
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
Angus Li
 
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal StackDecoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
nuppla
 
Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...
MilanAryal
 
Neoito — How modern browsers work
Neoito — How modern browsers workNeoito — How modern browsers work
Neoito — How modern browsers work
Neoito
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
Alessandro Molina
 
Does my DIV look big in this?
Does my DIV look big in this?Does my DIV look big in this?
Does my DIV look big in this?
glen_a_smith
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
David Zapateria Besteiro
 
To build a WordPress Theme: Wordcamp Denmark 2014
To build a WordPress Theme: Wordcamp Denmark 2014To build a WordPress Theme: Wordcamp Denmark 2014
To build a WordPress Theme: Wordcamp Denmark 2014
James Bonham
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
Nicolas Embleton
 
Tech meetup: Web Applications Performance
Tech meetup: Web Applications PerformanceTech meetup: Web Applications Performance
Tech meetup: Web Applications Performance
Santex Group
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
Philip Norton
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
Philip Norton
 
Ad

Recently uploaded (20)

#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Ad

Drupalcamp performance

  • 1. WWLLC What Would Lucky Luke Code? Create Drupal sites with good performance
  • 4. The frontkom family Per André Rønsen Marco Fernandes CIO/Chief Innovation Officer Senior Web developer Fredrik Paus Élio Cró Jan-Helge Hansen COO/Project Manager Web Developer Infrastructure / support Thor André Gretland Roberto Ornelas Support & Training CTO Senior developer Fábio Neves Geir Gulland Hélder Mendes Bruno Campos CEO / Web strategist Web Designer Web developer Frank Gjertsen Elisabeth Gulland Wilma Web Designer Accountant QA Engineer ;) Henrik Akselsen JS/Mobile UX Web developer
  • 8. Why performance now? ● We got fast internet connections ● Powerful computers ● Shiny large screens …but wait, we got mobile. …and bad mobile connections. …and emerging markets which are mobile only.
  • 9. Web pages are getting FAT 1.5MB Expect to increase by 21% the next year ● Today the average page is ● ● Oakley released their new site. 80MB
  • 10. When to start? ● Post-optimization is the root of all evil ● Lack of performance = Lack of planning ● Bad performance is bad business ● ● ● ● We need our clients interest in performance Show visually how a page loads Make a performance budget Plan performance from the beginning
  • 11. We need to analyze this
  • 12. “Yeah, it’s slow, but it’s probably just [insert wild speculation here]”
  • 13. 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 80/20 rule => find low hanging fruit
  • 14. Tools ● ● ● ● Web developer tools in your browsers PageSpeed (Google) Yslow (Yahoo) Quicksprout http://www.quicksprout.com/ ● WebPageTest http://www.webpagetest.org/
  • 17. Indepth analysis Chrome Dev Tools XHProf (Backend) Frontend Introduction to dev tools http://bit.ly/discover-devtools Find out which functions that are using memory and processor time “The Breakpoint” Paul Irish / Addy Osmani
  • 19. Mobile first ● Start small. Add style and content as you get more space, without limiting the user experience. http://bradfrostweb.com/demo/mobile-first ● Build systems instead of individual pages ● Write reusable code
  • 20. 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 way… ● Or use icon fonts ○ http://iconmoon.io ○ or even better http://fontastic.me
  • 21. HTML ● Take control over your markup ● Customize markup in your tpl.php ● Find design patterns and add classes to similar elements. ● In views it can be customized directly, on other output use template.php
  • 22. <section class="panel-pane paneviews-panes pane-commons-featuredpanel-pane-1 block">...</section> <section class="panel-pane paneviews-panes pane-commons-activitystreams-activity-panel-pane-1 block">...</section>
  • 23. function theme_preprocess_panels_pane(&$vars) { switch ($vars['pane']->pid) { case '14': $vars['classes_array'][] = 'box-default'; break; case '8': $vars['classes_array'] = array('box-default'); break; } }
  • 24. <section class="panel-pane paneviews-panes pane-commons-featuredpanel-pane-1 block box-default"> ... </section> <section class="box-default"> ... </section>
  • 26. Clean markup ● Modules ○ Clean Markup - Blocks, Panel panes, Panel regions, Panel layouts https://drupal.org/project/clean_markup ○ Fences - clean fields markup globaly. https://drupal.org/project/fences
  • 27. Default fields markup <div class="field field-name-field-test field-type-text field-label-above"> <div class="field-label">Foobar field: &nbsp;</div> <div class="field-items"> <div class="field-item even">Drupal default fields markup.</div> </div> </div>
  • 28. After fences config <h3 class="field-label">Foobar field</h3> <div class="field-foobar">Leaner markup means better front-end performance. </div>
  • 29. Clean markup ● Modules ○ Clean Markup - Blocks, Panel panes, Panel regions, Panel layouts https://drupal.org/project/clean_markup ○ Fences - clean fields markup globaly. https://drupal.org/project/fences ● Themes ○ Mothership https://drupal.org/project/mothership ○ Aurora https://drupal.org/project/aurora
  • 30. CSS ● Write as little as possible ● Use classes instad of tags ○ ul li a {} ○ .nav-main .nav-item {} ○ http://bit.ly/quick-selectors ● Css can get out of control and hard to manage when a page scales
  • 31. .btn-default, .btn-cta { text-align: center; display: inline-block; background-color: gray; padding: 5px 10px; color: white; } .btn-cta { background-color: dodgerblue; }
  • 32. SMACSS ● A must read for all working with css ● Part of the book is available online for free http://smacss.com
  • 34. Preprocess that CSS ● LESS ● Stylus ● Sass ○ ○ ○ ○ WARNING! Compass - Sass mixins library and much more Breakpoint - Really Simple Media Queries with Sass Toolkit - swiss army knife for PE and RWD Singularity - Grids withoutyour output Always check limits
  • 35. .btn-default { text-align: center; display: inline-block; background-color: gray; padding: 5px 10px; color: white; } .btn-cta { @extend .btn-default; background-color: dodgerblue; }
  • 36. .btn-default, .btn-cta { text-align: center; display: inline-block; background-color: gray; padding: 5px 10px; color: white; } .btn-cta { background-color: dodgerblue; }
  • 37. Javascript ● Don’t load js before css ● Don’t load libraries you don’t need, and if possible make custom builds to your needs. E.g. Modernizr. ● Try to move most of your js at the bottom of your page, just before </body>. There is a special Drupal module for this. ● Avoid unnecessary dom manipulations
  • 39. Avoid calculations in loops var div = document.getElementById("to-measure"), lis = document.getElementsByTagName('li'), i, len; for (i = 0, len = lis.length; i < len; i++) { lis[i].style.width = div.offsetWidth + 'px'; }
  • 40. Improve Perceived performance ● Edge side includes ● Image lazy loading
  • 42. 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)
  • 43. PHP & MySQL PHP version: newer is better InnoDB > Myisam
  • 44. APC - Opcode cache - Easy setup, huge performance win - See https://drupal.org/node/1777090 for configuration tips for Drupal - Remember to assign enough memory, or the cache will not have any effect
  • 45. Memcache(d) Improves editor experience + faster site building Memcache module not needed, just include in settings.php Alternative: Redis
  • 46. // the path to the core cache file include_once('./includes/cache.inc'); // the path to the memcache cache file include_once ('./sites/all/modules/contrib/memcache/memcache.inc'); // make MemCacheDrupal the default cache class $conf['cache_default_class'] = 'MemCacheDrupal'; $conf['memcache_servers'] = array('127.0.0.1:11211' => 'default'); $conf['memcache_bins'] = array('cache' => 'default'); $conf['memcache_key_prefix'] = 'mysite';
  • 47. First time using memcache
  • 49. High performance with cloud ● CDN ● Amazon AWS for static files and images ● Web Application Streaming ○ new tech, possible “CDN killer”) ○ from InstartLogic
  • 54. Good places to hang out ● high performance group on d.o ● Contrib modules
  • 55. Module strategy ● 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 before/after install ○ Dive into xhprof ○ Disable suspected performance hogs
  • 56. 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)
  • 57. Watch the Logs ● 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
  • 58. 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
  • 60. Be kind to the theme layer ● 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
  • 64. Find candidates for optimizing [mysqld] log_slow_queries=/Applications/MAMP/logs/mys ql_sql_slow.log long_query_time=0.5 LOTS OF JOINS SELECT * FROM mother_of_all_huge_tables
  • 65. Keep an eye on PAGERS DISTINCT COUNT JOINS
  • 66. Optimize Views Queries Battle plan: Find JOINS and see if you can do the same within SELECT Tip: use EXPLAIN on views sql How many evaluations
  • 67. No JOIN select nid FROM node; 200005 rows in set (0.08 sec) Data from astonishdesign.com
  • 68. 1 JOIN select n.nid, s. field_school_name_format FROM node n LEFT JOIN field_data_field_school_name s ON n.nid = s.entity_id; 200005 rows in set (1.09 sec)
  • 69. 2 JOINS select n.nid, s.field_school_name_format, si.field_school_id_value FROM node n LEFT JOIN field_data_field_school_name s ON n.nid = s.entity_id LEFT JOIN field_data_field_school_id si on n.nid = si.entity_id; 200005 rows in set (2.03 sec)
  • 70. 3 JOINS select n.nid, s.field_school_name_format, si. field_school_id_value, sp.field_school_phone_value FROM node n LEFT JOIN field_data_field_school_name s ON n.nid = s. entity_id LEFT JOIN field_data_field_school_id si on n.nid = si. entity_id LEFT JOIN field_data_field_school_phone sp on n.nid = sp. entity_id; 200005 rows in set ( 5.03 sec)
  • 71. Optimize Views Queries ● Optimize in hook_views_query_alter() and hook_view_query_substitutions() ● Consider making views into a module ○ Easier to optimize + easier version control
  • 72. Specific use cases ● Defer heavy tasks ○ Push heavy tasks to cron ○ Batch API ● Fast 404
  • 74. Stats Performance module New Relic Load testing with jMeter (+Blazemeter)
  • 75. Bring out the big guns ● Ditch the theme layer ● Example: NewsFront
  • 76. Now it’s your turn ;-)