SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
DRUPAL PERFORMANCE E SCALABILITÀ
STEFANO MAINARDI - STEFANO@TWINBIT.IT
MARCO GIACOMASSI - MARCO@TWINBIT.IT
About Stefano
• Drupal developer since 2007
• Twinbit co-founder
• ILDN founder
• I’m a geek and i love Open Source software
@stefanomainardi
stefano@twinbit.it
About Marco
• web and open source consultant and developer
• interested in knowledge management, GIS, and integration of
systems with CMS
• Twinbit co-founder
@marcogiaco
marco@twinbit.it
Agenda
• Why speed is so important
• Tips for frontend optimization
• Tips for backend optimization
• Q&A time (we hope!)
What is performance?
“The delay perceived
between an action (e.g. click)
and a meaningful response”
What is performance?
Performance is money
Why do we care about it?
Why speed is so
important?
some numbers
1 Second
decrease page load time
Amazon's calculated that a
page load slowdown of just
one second could cost it
$1.6 billion in sales each
year.
Source: http://www.tagman.com/mdp-blog/2012/03/just-one-second-delay-in-page-load-can-cause-7-loss-in-customer-conversions/
Google has calculated that
by slowing its search results
by just four tenths of a
second they could lose 8
million searches per day
Source: http://www.tagman.com/mdp-blog/2012/03/just-one-second-delay-in-page-load-can-cause-7-loss-in-customer-conversions/
WHAT??
Performance golden rule
80-90%of the end-user response time is spent on the frontend.
Start there.
80-90%of the end-user response time is spent on the frontend.
Source: http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/
But first, the horrible truth
about Drupal
Drupal is
Database intensive!
!
Memory intensive!
!
Can easily become a resource hog
Why most drupal sites are slow?
Poor frontend implementation!
!
Slow mysql queries!
!
Serving dynamic contents to anonymous !
users!
!
Module bloat (“open buffet” syndrome)
Let’s focus on frontend
1. When we request a URL a DNS lookup is done
2. Download the html and start reads from top
3. CSS Block rendering. The browser starts rendering
once it has all the style declarations
4. Javascript blocks downloads. Make sure to serve
js at last
5. Circa 4/8 assets (images / js / css /fonts) are downloaded
in parallel from the same domain
www.twinbit.it ? IP = 188.40.59.145
How does a browser work?
Our goals
1. Put CSS on top (it blocks rendering)
2. Put JS on bottom (it blocks downloads)
3. Minimize the number of requests (CSS / js / images, fonts)
4. Send less data as possible
5. Spread your assets over several domains (CDN)
Put javascript on footer
Remove unneeded css
Using hook_css_alter() to limit amount of requests
Remove unneeded css
Using hook_css_alter() to limit amount of requests
Use aggregation
Built-in aggregation
Use aggregation
Advanced CSS/JS Aggregation module
http://drupal.org/project/advagg
or smart solution
Use aggregation
Advanced CSS/JS Aggregation module
http://drupal.org/project/advagg
Fully cached CSS/JS assets allow for zero file I/O if the
Aggregated file already exists. Results in better page generation
performance
On demand generation of CSS/JS Aggregates. If the file doesn't
exist it will be generated on demand.
Gzip support. All aggregated files can be pre-compressed into
a .gz file and served from Apache. This is faster then gzipping
the file on each request.
Use aggregation
Advanced CSS/JS Aggregation module
http://drupal.org/project/advagg
built-in support for !
!
HTTP Parallel Request & Threading Library
https://drupal.org/project/httprl
Image requests
1. Sprites: One file for all UI elements (1 request)
2. Use automatic tools like Compass
for generate sprites
http://compass-style.org/help/tutorials/spriting/
3. Optimize imageshttps://drupal.org/project/imageapi_optimize
4. Use font-based icons https://drupal.org/project/fontello
Keep in mind to send less data
to servers, ever!
SPREAD
your assets over several domains
use CDN module
https://drupal.org/project/cdn
2 tips
1 . DNS Prefetching
2. Cookie-less domain
set in settings.php the variable
$cookie_domain = ‘www.twinbit.it’
<head>
…
<link rel=“dns-prefetch” href=“//script.google.com”>
…
</head>
Monitor your application
Monitor your application
YSlow
Chrome and Firefox developer tools, are your
best friends
Google page speed tools
or use external services like
New relic
and know the tools
take away
“Cache saves the cache”
cache everything at every level
Let’s focus on backend
thank you for now!
Caching
Anonymous vs authenticated
Identify the type of your application in
order to
apply appropriate caching policies.
!
The more static the application is the
more it will be served by the “client-
side” caches.
!
Highly dynamic application will need
efficient “application-side” caching.
Clustered architecture
Reverse proxy
A proxy server that retrieves resources on behalf of a client from
one or more servers. These resources are then returned to the
client as though they originated from the server itself.
!
Varnish is widely adopted, open source and natively supported
by Drupal 7.x
● from 300x to 1000x faster
● serves static pages and assets
● powerful configuration language
● ESI (https://drupal.org/project/esi)
● can act as load balancer
More links
https://drupal.org/node/1054886
https://drupal.org/project/varnish
https://www.varnish-cache.org/trac/wiki/VarnishAndDrupal
!
Web servers
Drupal configuration / coding
!
● use static caching $foo = &drupal_static(__FUNCTION__);
● use cache_set/cache_get
● disable unneeded modules
● avoid variable_set() in frontend pages
and cache invalidation
● keep app logic away from template, use
hook_preprocess functions
● don’t reinvent the wheel! api.drupal.org
is your best friend!
● keep drupal performance configuration
in settings.php
!
System
!
● configure Apache MaxClients
○ ((System RAM) – (RAM used by other processes)) /
(httpd process size) = MaxClients
○ KeepAliveTimeout < 5 sec
!
● use APC
○ apc.stat ~ 0
○ apc._num_files_hint > 1000
!
● use Nginx if no proxy or CND
More links
https://groups.drupal.org/high-performance
Web servers: more is better
!
● VM-C1: 1 cpu, 2 GB ram
● VM-C2: 2 cpu, 4 GB ram
● VM-C3: 4 cpu, 8 GB ram
Web servers: more is much better
Session management
Drupal is saving sessions to database. This can be used in a cluster
but we want to save database queries.
!
To do this we can use different solutions:
!
!
!
! Memcache Redis MongoDB
pros very easy and
fast
very fast native replication
cons no native
replication
no native replication cluster configuration
Drupal
compatibility
mature medium medium
Application caching
Drupal has several caches, by default stored in database. To avoid
loading the database we can still use different solutions:
!
● memcache / redis
● mongodb
!
!
More links
https://drupal.org/project/memcache
https://drupal.org/project/mongodb
http://www.mongodb.org/
!
!
!
Memcache tips
!
● exclude cache_form and cache_views unless different bucket size
● php mod: Memcache (3.x) vs Memcached
● bucket size!!!
!
● module settings
!
memcache.hash_strategy consistent
memcached.sess_consistent_hash 1
!
● Drupal settings.php
$conf['memcache_stampede_protection'] = TRUE;
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
Application caching: memcache
Database
MySQL
!
● 3% core queries goes to slaves
● tag queries to be slave query (also using query_alter)
● tag queries to be slave query also using views UI
!
Tune innodb buffer size
!
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS
FROM (SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB' and
table_schema = ‘drupal_db’) A;
!
!
Use MySQL query cache!
Control servers
● control server: monitoring software (munin), phpmyadmin,
configuration engine (Puppet)
!
● staging server: should contain a copy of the production
environment. This is used for testing and deploying.
!
● file storage: user files
Interesting tools:
!
http://gatling-tool.org/
http://newrelic.com/
!
!
!
!
!
!
Performances
Anon users:
!
●proxy (varnish): 2000 req/s anonymous users
●60 apache processes per cpu core, 1 req/s per process
!
Auth users:
!
●web server (apache): 14 apache processes per cpu core in virtual env, 1 req/s per process
(consider clustering overhead). Could be much better using other hypervisors, with WMWARE
we reached18/20)
●web server (apache): 40MB per process
Example
Target utenti
(numero di sessioni utente aperte sul
sistema in un giorno)
300000
Peso medio hit in KB 100
Page hits per utente
(numero di pagine visitate da un utente)
10
Tot hits/giorno 3M
Carico
% utenti
intervallo ore intervallo
secondi
nell'intervallo
media (req/
sec)
triangolare
(req/sec)
normale (req/
sec)
100% 4.5 16200 185 370 332
Example
Infrastruttura
VM Tipo CPU cores RAM (GB) Numero
Tot. CPU
cores
Tot. RAM
(GB)
haproxy server 2 4 2 4 8
front-end servers
frontend, cpu
bounded 4 8 6 24 48
cache servers
memory
bound 2 4 3 6 12
mysql servers
memory
bound 4 14 2 8 28
control server 2 4 2 4 8
staging
environment 2 4 6 12 24
totale risorse 21 58 128
Processi (threads)
apache per cpu core
15
Drupal memory
footprint (MB)
64
Mysql connection
fooprint (MB)
16
Example
• caching is key to performance
• set your performance target (capacity plan)
• measure performance on changes
Conclusions
Grazie!
Grazie!

Contenu connexe

Tendances

Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Chris Tankersley
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimizationStevie T
 
How We Build NG-MY Websites: Performance, SEO, CI, CD
How We Build NG-MY Websites: Performance, SEO, CI, CDHow We Build NG-MY Websites: Performance, SEO, CI, CD
How We Build NG-MY Websites: Performance, SEO, CI, CDSeven Peaks Speaks
 
GR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf
 
Pre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifyPre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifynuppla
 
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 Webphilogb
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimizationShafqat Hussain
 
AEM WITH MONGODB
AEM WITH MONGODBAEM WITH MONGODB
AEM WITH MONGODBNate Nelson
 
Drupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersDrupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersnuppla
 
The War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll CachingThe War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll CachingPeter Giacomo Lombardo
 
Client-side Website Optimization
Client-side Website OptimizationClient-side Website Optimization
Client-side Website OptimizationRadu Pintilie
 

Tendances (19)

Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Single Page Apps with Drupal 8
Single Page Apps with Drupal 8
 
Front end performance optimization
Front end performance optimizationFront end performance optimization
Front end performance optimization
 
Front End Performance
Front End PerformanceFront End Performance
Front End Performance
 
MongoDB
MongoDBMongoDB
MongoDB
 
Web performance
Web performanceWeb performance
Web performance
 
Hppg
HppgHppg
Hppg
 
How We Build NG-MY Websites: Performance, SEO, CI, CD
How We Build NG-MY Websites: Performance, SEO, CI, CDHow We Build NG-MY Websites: Performance, SEO, CI, CD
How We Build NG-MY Websites: Performance, SEO, CI, CD
 
GR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with Grails
 
Grails and Neo4j
Grails and Neo4jGrails and Neo4j
Grails and Neo4j
 
Pre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifyPre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlify
 
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
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimization
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
 
AEM WITH MONGODB
AEM WITH MONGODBAEM WITH MONGODB
AEM WITH MONGODB
 
Drupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developersDrupalcon 2021 - Nuxt.js for drupal developers
Drupalcon 2021 - Nuxt.js for drupal developers
 
The War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll CachingThe War on ActionView with Russian Doll Caching
The War on ActionView with Russian Doll Caching
 
Drupalcampatl d7
Drupalcampatl d7Drupalcampatl d7
Drupalcampatl d7
 
Client-side Website Optimization
Client-side Website OptimizationClient-side Website Optimization
Client-side Website Optimization
 
Dc kyiv2010 jun_08
Dc kyiv2010 jun_08Dc kyiv2010 jun_08
Dc kyiv2010 jun_08
 

Similaire à Drupal Performance e Scalabilità

Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal PerformancesVladimir Ilic
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101Angus Li
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthPhilip Norton
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeededm00se
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingAshok Modi
 
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelАртем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelLEDC 2016
 
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 CompanyMarcos Labad
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on SteroidsSiteGround.com
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesExove
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Optimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksOptimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksTimur Kamanin
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoSander Mangel
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.Arshak Movsisyan
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Data has a better idea the in-memory data grid
Data has a better idea   the in-memory data gridData has a better idea   the in-memory data grid
Data has a better idea the in-memory data gridBogdan Dina
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and ScalabilityMediacurrent
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Jess Coburn
 

Similaire à Drupal Performance e Scalabilità (20)

Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
 
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
AD113  Speed Up Your Applications w/ Nginx and PageSpeedAD113  Speed Up Your Applications w/ Nginx and PageSpeed
AD113 Speed Up Your Applications w/ Nginx and PageSpeed
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
 
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheelАртем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
Артем Сильчук - Respond in 60ms. Extremal optimization with reinventing a wheel
 
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
 
Joomla! Performance on Steroids
Joomla! Performance on SteroidsJoomla! Performance on Steroids
Joomla! Performance on Steroids
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Optimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and TricksOptimizing Drupal Performance. Tips and Tricks
Optimizing Drupal Performance. Tips and Tricks
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in Magento
 
Building high performance web apps.
Building high performance web apps.Building high performance web apps.
Building high performance web apps.
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Data has a better idea the in-memory data grid
Data has a better idea   the in-memory data gridData has a better idea   the in-memory data grid
Data has a better idea the in-memory data grid
 
Performance and Scalability
Performance and ScalabilityPerformance and Scalability
Performance and Scalability
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11
 

Plus de Twinbit

Drupal 7 : theming avanzato
Drupal 7 : theming avanzatoDrupal 7 : theming avanzato
Drupal 7 : theming avanzatoTwinbit
 
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISE
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISEDrupal Agile: DRUPAL ED IL MERCATO ENTERPRISE
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISETwinbit
 
Managing Spatial Information and Services with Drupal: the GEO-MOOD approach
Managing Spatial Information and Services with Drupal: the GEO-MOOD approachManaging Spatial Information and Services with Drupal: the GEO-MOOD approach
Managing Spatial Information and Services with Drupal: the GEO-MOOD approachTwinbit
 
Which base theme for your Drupal project
Which base theme for your Drupal projectWhich base theme for your Drupal project
Which base theme for your Drupal projectTwinbit
 
Mobile Drupal
Mobile DrupalMobile Drupal
Mobile DrupalTwinbit
 
Thinking spatially with your open data
Thinking spatially with your open dataThinking spatially with your open data
Thinking spatially with your open dataTwinbit
 
When Drupal meets OpenData
When Drupal meets OpenDataWhen Drupal meets OpenData
When Drupal meets OpenDataTwinbit
 
Drupal in the Cloud
Drupal in the CloudDrupal in the Cloud
Drupal in the CloudTwinbit
 
Drupal + Facebook @ DrupalSocialCulb
Drupal + Facebook @ DrupalSocialCulbDrupal + Facebook @ DrupalSocialCulb
Drupal + Facebook @ DrupalSocialCulbTwinbit
 
Sviluppare applicazioni Facebook utilizzando Drupal
Sviluppare applicazioni Facebook utilizzando DrupalSviluppare applicazioni Facebook utilizzando Drupal
Sviluppare applicazioni Facebook utilizzando DrupalTwinbit
 

Plus de Twinbit (10)

Drupal 7 : theming avanzato
Drupal 7 : theming avanzatoDrupal 7 : theming avanzato
Drupal 7 : theming avanzato
 
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISE
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISEDrupal Agile: DRUPAL ED IL MERCATO ENTERPRISE
Drupal Agile: DRUPAL ED IL MERCATO ENTERPRISE
 
Managing Spatial Information and Services with Drupal: the GEO-MOOD approach
Managing Spatial Information and Services with Drupal: the GEO-MOOD approachManaging Spatial Information and Services with Drupal: the GEO-MOOD approach
Managing Spatial Information and Services with Drupal: the GEO-MOOD approach
 
Which base theme for your Drupal project
Which base theme for your Drupal projectWhich base theme for your Drupal project
Which base theme for your Drupal project
 
Mobile Drupal
Mobile DrupalMobile Drupal
Mobile Drupal
 
Thinking spatially with your open data
Thinking spatially with your open dataThinking spatially with your open data
Thinking spatially with your open data
 
When Drupal meets OpenData
When Drupal meets OpenDataWhen Drupal meets OpenData
When Drupal meets OpenData
 
Drupal in the Cloud
Drupal in the CloudDrupal in the Cloud
Drupal in the Cloud
 
Drupal + Facebook @ DrupalSocialCulb
Drupal + Facebook @ DrupalSocialCulbDrupal + Facebook @ DrupalSocialCulb
Drupal + Facebook @ DrupalSocialCulb
 
Sviluppare applicazioni Facebook utilizzando Drupal
Sviluppare applicazioni Facebook utilizzando DrupalSviluppare applicazioni Facebook utilizzando Drupal
Sviluppare applicazioni Facebook utilizzando Drupal
 

Dernier

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 

Dernier (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 

Drupal Performance e Scalabilità

  • 1. DRUPAL PERFORMANCE E SCALABILITÀ STEFANO MAINARDI - STEFANO@TWINBIT.IT MARCO GIACOMASSI - MARCO@TWINBIT.IT
  • 2. About Stefano • Drupal developer since 2007 • Twinbit co-founder • ILDN founder • I’m a geek and i love Open Source software @stefanomainardi stefano@twinbit.it
  • 3. About Marco • web and open source consultant and developer • interested in knowledge management, GIS, and integration of systems with CMS • Twinbit co-founder @marcogiaco marco@twinbit.it
  • 4. Agenda • Why speed is so important • Tips for frontend optimization • Tips for backend optimization • Q&A time (we hope!)
  • 6. “The delay perceived between an action (e.g. click) and a meaningful response” What is performance?
  • 7. Performance is money Why do we care about it?
  • 8. Why speed is so important?
  • 11. Amazon's calculated that a page load slowdown of just one second could cost it $1.6 billion in sales each year. Source: http://www.tagman.com/mdp-blog/2012/03/just-one-second-delay-in-page-load-can-cause-7-loss-in-customer-conversions/
  • 12. Google has calculated that by slowing its search results by just four tenths of a second they could lose 8 million searches per day Source: http://www.tagman.com/mdp-blog/2012/03/just-one-second-delay-in-page-load-can-cause-7-loss-in-customer-conversions/
  • 15. 80-90%of the end-user response time is spent on the frontend.
  • 16. Start there. 80-90%of the end-user response time is spent on the frontend. Source: http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/
  • 17. But first, the horrible truth about Drupal
  • 18.
  • 19. Drupal is Database intensive! ! Memory intensive! ! Can easily become a resource hog
  • 20. Why most drupal sites are slow? Poor frontend implementation! ! Slow mysql queries! ! Serving dynamic contents to anonymous ! users! ! Module bloat (“open buffet” syndrome)
  • 21. Let’s focus on frontend
  • 22. 1. When we request a URL a DNS lookup is done 2. Download the html and start reads from top 3. CSS Block rendering. The browser starts rendering once it has all the style declarations 4. Javascript blocks downloads. Make sure to serve js at last 5. Circa 4/8 assets (images / js / css /fonts) are downloaded in parallel from the same domain www.twinbit.it ? IP = 188.40.59.145 How does a browser work?
  • 23. Our goals 1. Put CSS on top (it blocks rendering) 2. Put JS on bottom (it blocks downloads) 3. Minimize the number of requests (CSS / js / images, fonts) 4. Send less data as possible 5. Spread your assets over several domains (CDN)
  • 25. Remove unneeded css Using hook_css_alter() to limit amount of requests
  • 26. Remove unneeded css Using hook_css_alter() to limit amount of requests
  • 28. Use aggregation Advanced CSS/JS Aggregation module http://drupal.org/project/advagg or smart solution
  • 29. Use aggregation Advanced CSS/JS Aggregation module http://drupal.org/project/advagg Fully cached CSS/JS assets allow for zero file I/O if the Aggregated file already exists. Results in better page generation performance On demand generation of CSS/JS Aggregates. If the file doesn't exist it will be generated on demand. Gzip support. All aggregated files can be pre-compressed into a .gz file and served from Apache. This is faster then gzipping the file on each request.
  • 30. Use aggregation Advanced CSS/JS Aggregation module http://drupal.org/project/advagg built-in support for ! ! HTTP Parallel Request & Threading Library https://drupal.org/project/httprl
  • 31. Image requests 1. Sprites: One file for all UI elements (1 request) 2. Use automatic tools like Compass for generate sprites http://compass-style.org/help/tutorials/spriting/ 3. Optimize imageshttps://drupal.org/project/imageapi_optimize 4. Use font-based icons https://drupal.org/project/fontello
  • 32. Keep in mind to send less data to servers, ever!
  • 33. SPREAD your assets over several domains
  • 35. 2 tips 1 . DNS Prefetching 2. Cookie-less domain set in settings.php the variable $cookie_domain = ‘www.twinbit.it’ <head> … <link rel=“dns-prefetch” href=“//script.google.com”> … </head>
  • 37. Monitor your application YSlow Chrome and Firefox developer tools, are your best friends Google page speed tools or use external services like New relic and know the tools
  • 38. take away “Cache saves the cache” cache everything at every level
  • 39. Let’s focus on backend thank you for now!
  • 41. Anonymous vs authenticated Identify the type of your application in order to apply appropriate caching policies. ! The more static the application is the more it will be served by the “client- side” caches. ! Highly dynamic application will need efficient “application-side” caching.
  • 43. Reverse proxy A proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as though they originated from the server itself. ! Varnish is widely adopted, open source and natively supported by Drupal 7.x ● from 300x to 1000x faster ● serves static pages and assets ● powerful configuration language ● ESI (https://drupal.org/project/esi) ● can act as load balancer More links https://drupal.org/node/1054886 https://drupal.org/project/varnish https://www.varnish-cache.org/trac/wiki/VarnishAndDrupal !
  • 44. Web servers Drupal configuration / coding ! ● use static caching $foo = &drupal_static(__FUNCTION__); ● use cache_set/cache_get ● disable unneeded modules ● avoid variable_set() in frontend pages and cache invalidation ● keep app logic away from template, use hook_preprocess functions ● don’t reinvent the wheel! api.drupal.org is your best friend! ● keep drupal performance configuration in settings.php ! System ! ● configure Apache MaxClients ○ ((System RAM) – (RAM used by other processes)) / (httpd process size) = MaxClients ○ KeepAliveTimeout < 5 sec ! ● use APC ○ apc.stat ~ 0 ○ apc._num_files_hint > 1000 ! ● use Nginx if no proxy or CND More links https://groups.drupal.org/high-performance
  • 45. Web servers: more is better
  • 46. ! ● VM-C1: 1 cpu, 2 GB ram ● VM-C2: 2 cpu, 4 GB ram ● VM-C3: 4 cpu, 8 GB ram Web servers: more is much better
  • 47. Session management Drupal is saving sessions to database. This can be used in a cluster but we want to save database queries. ! To do this we can use different solutions: ! ! ! ! Memcache Redis MongoDB pros very easy and fast very fast native replication cons no native replication no native replication cluster configuration Drupal compatibility mature medium medium
  • 48. Application caching Drupal has several caches, by default stored in database. To avoid loading the database we can still use different solutions: ! ● memcache / redis ● mongodb ! ! More links https://drupal.org/project/memcache https://drupal.org/project/mongodb http://www.mongodb.org/ ! ! !
  • 49. Memcache tips ! ● exclude cache_form and cache_views unless different bucket size ● php mod: Memcache (3.x) vs Memcached ● bucket size!!! ! ● module settings ! memcache.hash_strategy consistent memcached.sess_consistent_hash 1 ! ● Drupal settings.php $conf['memcache_stampede_protection'] = TRUE; $conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc'; Application caching: memcache
  • 50. Database MySQL ! ● 3% core queries goes to slaves ● tag queries to be slave query (also using query_alter) ● tag queries to be slave query also using views UI ! Tune innodb buffer size ! SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM (SELECT SUM(data_length+index_length) Total_InnoDB_Bytes FROM information_schema.tables WHERE engine='InnoDB' and table_schema = ‘drupal_db’) A; ! ! Use MySQL query cache!
  • 51. Control servers ● control server: monitoring software (munin), phpmyadmin, configuration engine (Puppet) ! ● staging server: should contain a copy of the production environment. This is used for testing and deploying. ! ● file storage: user files Interesting tools: ! http://gatling-tool.org/ http://newrelic.com/ ! ! ! ! ! !
  • 52. Performances Anon users: ! ●proxy (varnish): 2000 req/s anonymous users ●60 apache processes per cpu core, 1 req/s per process ! Auth users: ! ●web server (apache): 14 apache processes per cpu core in virtual env, 1 req/s per process (consider clustering overhead). Could be much better using other hypervisors, with WMWARE we reached18/20) ●web server (apache): 40MB per process
  • 53. Example Target utenti (numero di sessioni utente aperte sul sistema in un giorno) 300000 Peso medio hit in KB 100 Page hits per utente (numero di pagine visitate da un utente) 10 Tot hits/giorno 3M
  • 54. Carico % utenti intervallo ore intervallo secondi nell'intervallo media (req/ sec) triangolare (req/sec) normale (req/ sec) 100% 4.5 16200 185 370 332 Example
  • 55. Infrastruttura VM Tipo CPU cores RAM (GB) Numero Tot. CPU cores Tot. RAM (GB) haproxy server 2 4 2 4 8 front-end servers frontend, cpu bounded 4 8 6 24 48 cache servers memory bound 2 4 3 6 12 mysql servers memory bound 4 14 2 8 28 control server 2 4 2 4 8 staging environment 2 4 6 12 24 totale risorse 21 58 128 Processi (threads) apache per cpu core 15 Drupal memory footprint (MB) 64 Mysql connection fooprint (MB) 16 Example
  • 56. • caching is key to performance • set your performance target (capacity plan) • measure performance on changes Conclusions