SlideShare a Scribd company logo
Danilo Ercoli
Software Engineer
http://daniloercoli.com
Improve WordPress performance with
caching and deferred execution of code
• PHP Caching
• WordPress Page Caching
• WordPress Object Caching
• Deferred Execution of code
Agenda
Layers
Operating System
Server Hardware
Network
Layers
Operating System
Server Hardware
Network
HTTP PHP MySQL
Layers
Operating System
Server Hardware
Network
HTTP PHP MySQL
WordPress
Layers
Operating System
Server Hardware
Network
HTTP PHP MySQL
WordPress
• Use InnoDB

unless you have a good reason not to
• Use the slow query log
• Use EXPLAIN on queries,

learn what the output means
• Double, Triple check your indexes
• Learn about quirks
MySQL
• Use an opcode cache ( Zend Opcache, XCache,
APC )
• Use newer versions
• Don’t use on static files
• Be careful with preg_* functions
• Profile your code ( Xdebug,VLD, XHProf )
• Don’t re-invent native PHP functions
PHP
PHP - opcode caching
.php
Read Parse Compile Execute Output
PHP - opcode caching
.php
Execute Output
OPcache
Opcode Cache
• Reduce time per request by 4X
• Increase requests per second by 4x
• Less work, for the same result means more
capacity
PHP - opcode caching
Transients
• Persistent out of the box
• Stored in wp_options: _transient_{key}
• WordPress uses them for certain internal functions
• set_, get_, and delete_transient()
Object Cache
• Not persistent without a plugin, such as W3 Total Cache or Memcached Object Cache
• Storage depends on server's and plugin's capabilities
• Used extensively within WordPress Cache objects can be grouped wp_cache_add(), _set, _get, _delete
WordPress Native Caching APIs
• W3 Total Cache provides object level caching using disk, opcode or
memcache(d) memory stores.
• Memcached Object Cache provides a persistent backend for the
WordPress object cache. A memcached server and the PECL
memcached extension are required.
• APC Object Cache provides a persistent backend for the WordPress
object cache using APC, the default opcode and key/value cache of
PHP.
• Redis Object Cache supports the use of Predis (PHP client library),
HHVM's Redis extension and the PECL Redis extension to provide a
persistent backend for the WordPress object cache. Redis is required.
• WP File Cache implements object level persistent caching by shifting
the load from your database to your disk/file system.
Object cache - plugins
• Free & open source
• High-performance, distributed memory object
caching system
• Key / Value data storage
• In memory only, won’t survive a reboot
• http://memcached.org/
Memcached
• WordPress Object Cache 



Reduces the number of database queries 

http://wordpress.org/extend/plugins/
memcached/
WordPress + Memcached
WordPress + Memcached
Memcached
HTTP PHP MySQL
WordPress
Full Page Caching
• Batcache
• WP Super Cache
• W3 Total Cache
Batcache is a plugin to store and serve cached
versions of rendered pages.
• Batcache uses memcached as its storage and is aimed
at preventing a flood of traffic from breaking your site.
• It does this by serving old pages to new users.
• This reduces the demand on the web server CPU and
the database.
• It also means some people may see a page that is up
to 5 minutes old.
Full Page Caching - Batcache
Who receives a cached pageview?
• By default, all new users receive a cached
pageview.
• New users are defined as anybody who hasn’t
interacted with your domain —once they’ve left a
comment or logged in, their cookies will ensure they
get fresh pages.
• Note that URLs with query strings are automatically
exempt from Batcache.
Full Page Caching - Batcache
WordPress + Memcached
Memcached
HTTP PHP MySQL
WordPress
Batcache
Because Batcache caches fully rendered pages, per-user
interactions on the server-side can be problematic.
This means usage of objects/functions like:
•$_COOKIE
•setcookie
•$_SERVER['HTTP_USER_AGENT']
•Anything that’s unique to an individual user
cannot be relied on, as the values may be cached and cross-
pollution can occur.
In most cases, any user-level interactions should be moved to
client-side using JavaScript.
Full Page Caching - Batcache
WP Home page (not logged)
Requests/sec
(mean)
PHP 0.89
PHP + OPCODE 1.05
PHP + OPCODE + OBJECT CACHE
(MEMCACHED OC + MEMCACHE SERVER)
7.33
PHP + OPCODE + OBJECT CACHE + PAGE CACHE
(W3 Total Cache + MEMCACHE SERVER)
29.17
PHP + OPCODE + OBJECT CACHE + PAGE CACHE
(W3 Total Cache on Disk)
29.49
PHP + OPCODE + OBJECT CACHE + PAGE CACHE
(MEMCACHED OC + BATCACHE + MEMCACHE SERVER)
29.72
PHP + OPCODE + PAGE CACHE
(WP Super Cache)
29.57
Deferred execution of code - Asynchronous Jobs Queue
PHP executes in a single threaded manner.
That is the interpreter does A, then B, then C,
then D, then finishes, and wipes its slate clean
(shared nothing).
It does this same things for every page view on
your site.
Deferred execution of code
•Everything from spam checking, through
sending emails, Push Notifications, is not
necessary to render the HTML page.
•Those tasks could be stashed in the Jobs
system.
•Another process elsewhere on your network
will pick up the job, pull out the message,
check it for duplication, spam, language, stick
it in the db if that all passes, and then finally
send out emails / PNs to all the recipients.
Deferred execution of code
Deferred execution of code
Jobs system
• Lots of options (WP Async Task library, WP Background Processing)
• We built one for WordPress.com
• http://code.trac.wordpress.org/browser/jobs
• http://code.trac.wordpress.org/wiki/JobsDocs
• All PHP + MySQL
• Good for anything that isn’t required for rendering a
page
Deferred execution of code
• WordPress
• A new comment is posted on the blog
• WordPress does follow the normal flow, and enqueue a new Job in the Jobs system
• The Jobs Systems
• Loads the job from the DB
• Checks the userID of the author of the post.
• Checks that the Author of the post has a device registered
• Check user preferences
• Checks the type of the device (Android, iOS, Windows)
• Creates the PN object by using the device type information, and send it to the correct
remote server
• Handles errors and re-enqueue it if something went wrong
Deferred execution of code - Send Push Notifications to
Users
Improve WordPress performance with caching and deferred execution of code

More Related Content

What's hot

Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress Multisite
Taylor McCaslin
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
WordCamp Cape Town
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
Mark Leusink
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
rtCamp
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
Marko Heijnen
 
WordPress Server Security
WordPress Server SecurityWordPress Server Security
WordPress Server Security
Peter Baylies
 
HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09
mihaiionescu
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.
Herman Peeren
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWP
Taylor Lovett
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
Michele Orru
 
Debugging WordPress Performance using EasyEngine
Debugging WordPress Performance using EasyEngineDebugging WordPress Performance using EasyEngine
Debugging WordPress Performance using EasyEngine
rtCamp
 
Exploring WordPress Multisite
Exploring WordPress MultisiteExploring WordPress Multisite
Exploring WordPress Multisite
Lisa Sabin-Wilson
 
Presentation1
Presentation1Presentation1
Presentation1
Rosie brown
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
Seravo
 
BP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPagesBP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPages
edm00se
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?
Andy Melichar
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
Taylor Lovett
 
A Day of REST
A Day of RESTA Day of REST
A Day of REST
Scott Taylor
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Andrea Cardinali
 
Using MAMP for Web Development
Using MAMP for Web DevelopmentUsing MAMP for Web Development
Using MAMP for Web Development
Eric Greene
 

What's hot (20)

Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress Multisite
 
Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!Anthony Somerset - Site Speed = Success!
Anthony Somerset - Site Speed = Success!
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
WordPress Server Security
WordPress Server SecurityWordPress Server Security
WordPress Server Security
 
HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09HTML5 and Google Chrome - DevFest09
HTML5 and Google Chrome - DevFest09
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWP
 
BeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-OrruBeEF_EUSecWest-2012_Michele-Orru
BeEF_EUSecWest-2012_Michele-Orru
 
Debugging WordPress Performance using EasyEngine
Debugging WordPress Performance using EasyEngineDebugging WordPress Performance using EasyEngine
Debugging WordPress Performance using EasyEngine
 
Exploring WordPress Multisite
Exploring WordPress MultisiteExploring WordPress Multisite
Exploring WordPress Multisite
 
Presentation1
Presentation1Presentation1
Presentation1
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
 
BP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPagesBP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPages
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
A Day of REST
A Day of RESTA Day of REST
A Day of REST
 
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
Gestione avanzata di WordPress con WP-CLI - WordCamp Torino 2017 - Andrea Car...
 
Using MAMP for Web Development
Using MAMP for Web DevelopmentUsing MAMP for Web Development
Using MAMP for Web Development
 

Viewers also liked

Design without Ego — TEDxBologna Talk
Design without Ego — TEDxBologna TalkDesign without Ego — TEDxBologna Talk
Design without Ego — TEDxBologna Talk
Erin 'Folletto' Casali
 
Getting Comfortable with Child Themes
Getting Comfortable with Child ThemesGetting Comfortable with Child Themes
Getting Comfortable with Child Themes
Kathryn Presner
 
Asynchronous WordPress
Asynchronous WordPressAsynchronous WordPress
Asynchronous WordPress
Aaron Brazell
 
WCEU 2016 - 10 tips to sleep better at night
WCEU 2016 - 10 tips to sleep better at nightWCEU 2016 - 10 tips to sleep better at night
WCEU 2016 - 10 tips to sleep better at night
Maurizio Pelizzone
 
How to Build your own Medium using WordPress.com
How to Build your own Medium using WordPress.comHow to Build your own Medium using WordPress.com
How to Build your own Medium using WordPress.com
Nagesh Pai
 
The Making of WordPress·com Calypso: A Team Perspective
The Making of WordPress·com Calypso: A Team PerspectiveThe Making of WordPress·com Calypso: A Team Perspective
The Making of WordPress·com Calypso: A Team Perspective
Erin 'Folletto' Casali
 
Designing Inclusive Open Source Communities
Designing Inclusive Open Source CommunitiesDesigning Inclusive Open Source Communities
Designing Inclusive Open Source Communities
Erin 'Folletto' Casali
 
Matter March 2015
Matter March 2015Matter March 2015
Matter March 2015
brendanbaker
 
Breeam lezing knv koeltechniek jan2014
Breeam lezing knv koeltechniek jan2014Breeam lezing knv koeltechniek jan2014
Breeam lezing knv koeltechniek jan2014
Olaf Buter
 
AWS Black Belt Techシリーズ AWS OpsWorks
AWS Black Belt Techシリーズ  AWS OpsWorksAWS Black Belt Techシリーズ  AWS OpsWorks
AWS Black Belt Techシリーズ AWS OpsWorks
Amazon Web Services Japan
 
Due diligence for early stage investing
Due diligence for early stage investingDue diligence for early stage investing
Due diligence for early stage investing
FunderNation
 
Foliensatz der RWTH 2014
Foliensatz der RWTH 2014Foliensatz der RWTH 2014
Foliensatz der RWTH 2014
RWTH Aachen University
 
The Psychology Behind Pair Designing
The Psychology Behind Pair DesigningThe Psychology Behind Pair Designing
The Psychology Behind Pair Designing
Karl Dotter
 
SAP Inside Track Wroclow - Bluetooth the World
SAP Inside Track Wroclow - Bluetooth the WorldSAP Inside Track Wroclow - Bluetooth the World
SAP Inside Track Wroclow - Bluetooth the World
Craig Cmehil
 
Venture-Capital-Broschüre. Wenn Ideen groß werden
Venture-Capital-Broschüre. Wenn Ideen groß werdenVenture-Capital-Broschüre. Wenn Ideen groß werden
Venture-Capital-Broschüre. Wenn Ideen groß werden
BVK
 
dda-12-2009
dda-12-2009dda-12-2009
dda-12-2009
Ron A. Hillmann ✘
 
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionalsOnline Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
Holger Spielberg
 
REAL ESTATE BRAND BOOK 2015 mediadaten
REAL ESTATE BRAND BOOK 2015 mediadatenREAL ESTATE BRAND BOOK 2015 mediadaten
REAL ESTATE BRAND BOOK 2015 mediadaten
EUREB-Institute
 
Designing The User Experience Curve 2.0
Designing The User Experience Curve 2.0Designing The User Experience Curve 2.0
Designing The User Experience Curve 2.0
Andy Budd
 
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
Thilo Stadelmann
 

Viewers also liked (20)

Design without Ego — TEDxBologna Talk
Design without Ego — TEDxBologna TalkDesign without Ego — TEDxBologna Talk
Design without Ego — TEDxBologna Talk
 
Getting Comfortable with Child Themes
Getting Comfortable with Child ThemesGetting Comfortable with Child Themes
Getting Comfortable with Child Themes
 
Asynchronous WordPress
Asynchronous WordPressAsynchronous WordPress
Asynchronous WordPress
 
WCEU 2016 - 10 tips to sleep better at night
WCEU 2016 - 10 tips to sleep better at nightWCEU 2016 - 10 tips to sleep better at night
WCEU 2016 - 10 tips to sleep better at night
 
How to Build your own Medium using WordPress.com
How to Build your own Medium using WordPress.comHow to Build your own Medium using WordPress.com
How to Build your own Medium using WordPress.com
 
The Making of WordPress·com Calypso: A Team Perspective
The Making of WordPress·com Calypso: A Team PerspectiveThe Making of WordPress·com Calypso: A Team Perspective
The Making of WordPress·com Calypso: A Team Perspective
 
Designing Inclusive Open Source Communities
Designing Inclusive Open Source CommunitiesDesigning Inclusive Open Source Communities
Designing Inclusive Open Source Communities
 
Matter March 2015
Matter March 2015Matter March 2015
Matter March 2015
 
Breeam lezing knv koeltechniek jan2014
Breeam lezing knv koeltechniek jan2014Breeam lezing knv koeltechniek jan2014
Breeam lezing knv koeltechniek jan2014
 
AWS Black Belt Techシリーズ AWS OpsWorks
AWS Black Belt Techシリーズ  AWS OpsWorksAWS Black Belt Techシリーズ  AWS OpsWorks
AWS Black Belt Techシリーズ AWS OpsWorks
 
Due diligence for early stage investing
Due diligence for early stage investingDue diligence for early stage investing
Due diligence for early stage investing
 
Foliensatz der RWTH 2014
Foliensatz der RWTH 2014Foliensatz der RWTH 2014
Foliensatz der RWTH 2014
 
The Psychology Behind Pair Designing
The Psychology Behind Pair DesigningThe Psychology Behind Pair Designing
The Psychology Behind Pair Designing
 
SAP Inside Track Wroclow - Bluetooth the World
SAP Inside Track Wroclow - Bluetooth the WorldSAP Inside Track Wroclow - Bluetooth the World
SAP Inside Track Wroclow - Bluetooth the World
 
Venture-Capital-Broschüre. Wenn Ideen groß werden
Venture-Capital-Broschüre. Wenn Ideen groß werdenVenture-Capital-Broschüre. Wenn Ideen groß werden
Venture-Capital-Broschüre. Wenn Ideen groß werden
 
dda-12-2009
dda-12-2009dda-12-2009
dda-12-2009
 
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionalsOnline Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
Online Karrieretag Hamburg 2013 - eBay, Inc overview for young professionals
 
REAL ESTATE BRAND BOOK 2015 mediadaten
REAL ESTATE BRAND BOOK 2015 mediadatenREAL ESTATE BRAND BOOK 2015 mediadaten
REAL ESTATE BRAND BOOK 2015 mediadaten
 
Designing The User Experience Curve 2.0
Designing The User Experience Curve 2.0Designing The User Experience Curve 2.0
Designing The User Experience Curve 2.0
 
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
Wie die Swiss Alliance for Data-Intensive Services datenbasierte Mehrwerte sc...
 

Similar to Improve WordPress performance with caching and deferred execution of code

Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
Jurriaan Persyn
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
reeder29
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
Taylor Lovett
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
Taylor Lovett
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
David Newman
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
Jason Davies
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
Brian DeShong
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
Jonathan Klein
 
Live Coverage at The New York Times
Live Coverage at The New York TimesLive Coverage at The New York Times
Live Coverage at The New York Times
Scott Taylor
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
vmaximiuk
 
Scaling WordPress
Scaling WordPressScaling WordPress
Scaling WordPress
Joseph Scott
 
Building faster websites: web performance with WordPress
Building faster websites: web performance with WordPressBuilding faster websites: web performance with WordPress
Building faster websites: web performance with WordPress
Johannes Siipola
 
hardenning Operating System Server Berbasis Linux
hardenning Operating System Server Berbasis Linuxhardenning Operating System Server Berbasis Linux
hardenning Operating System Server Berbasis Linux
jokerman16
 
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Atwix
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Otto Kekäläinen
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
Marko Heijnen
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
Marcus Deglos
 
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
edm00se
 
<?php + WordPress
<?php + WordPress<?php + WordPress
<?php + WordPress
Christopher Reding
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHP
Taylor Lovett
 

Similar to Improve WordPress performance with caching and deferred execution of code (20)

Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
Top ten-list
Top ten-listTop ten-list
Top ten-list
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
Live Coverage at The New York Times
Live Coverage at The New York TimesLive Coverage at The New York Times
Live Coverage at The New York Times
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
 
Scaling WordPress
Scaling WordPressScaling WordPress
Scaling WordPress
 
Building faster websites: web performance with WordPress
Building faster websites: web performance with WordPressBuilding faster websites: web performance with WordPress
Building faster websites: web performance with WordPress
 
hardenning Operating System Server Berbasis Linux
hardenning Operating System Server Berbasis Linuxhardenning Operating System Server Berbasis Linux
hardenning Operating System Server Berbasis Linux
 
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
 
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
 
<?php + WordPress
<?php + WordPress<?php + WordPress
<?php + WordPress
 
You Got React.js in My PHP
You Got React.js in My PHPYou Got React.js in My PHP
You Got React.js in My PHP
 

Recently uploaded

Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
neshakor5152
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
attueb
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
bhumivarma35300
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
SOCRadar
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Aardwolf Security
 
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
Srinivas Dukka
 
welcome to presentation on Google Apps
welcome to   presentation on Google Appswelcome to   presentation on Google Apps
welcome to presentation on Google Apps
AsifKarimJim
 
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to KnowThe Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
onemonitarsoftware
 
Mobile App Development Company in Noida - Drona Infotech
Mobile App Development Company in Noida - Drona InfotechMobile App Development Company in Noida - Drona Infotech
Mobile App Development Company in Noida - Drona Infotech
Mobile App Development Company in Noida - Drona Infotech
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
singhlata50dh
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
OnePlan Solutions
 
Google ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learningGoogle ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learning
VishrutGoyani1
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
sofiafernandezon
 
Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)
miso_uam
 
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdfIoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
mohitd6
 
655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf
KhnhTrn343305
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
confluent
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
ThousandEyes
 

Recently uploaded (20)

Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
 
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
Independent Girls call Service Pune 000XX00000 Provide Best And Top Girl Serv...
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 
Top Chinese Government-backed APT Groups
Top Chinese Government-backed APT GroupsTop Chinese Government-backed APT Groups
Top Chinese Government-backed APT Groups
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
 
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
 
welcome to presentation on Google Apps
welcome to   presentation on Google Appswelcome to   presentation on Google Apps
welcome to presentation on Google Apps
 
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to KnowThe Ultimate Guide to Phone Spy Apps: Everything You Need to Know
The Ultimate Guide to Phone Spy Apps: Everything You Need to Know
 
Mobile App Development Company in Noida - Drona Infotech
Mobile App Development Company in Noida - Drona InfotechMobile App Development Company in Noida - Drona Infotech
Mobile App Development Company in Noida - Drona Infotech
 
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
High Girls Call Chennai 000XX00000 Provide Best And Top Girl Service And No1 ...
 
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
Maximizing Efficiency and Profitability: Optimizing Data Systems, Enhancing C...
 
Google ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learningGoogle ML-Kit - Understanding on-device machine learning
Google ML-Kit - Understanding on-device machine learning
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
 
Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)Software development... for all? (keynote at ICSOFT'2024)
Software development... for all? (keynote at ICSOFT'2024)
 
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdfIoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
IoT In Manufacturing_ Use Cases, Benefits, and Challenges.pdf
 
655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf655221243123332131-Complete-MERN-stack.pdf
655221243123332131-Complete-MERN-stack.pdf
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
 

Improve WordPress performance with caching and deferred execution of code

  • 1. Danilo Ercoli Software Engineer http://daniloercoli.com Improve WordPress performance with caching and deferred execution of code
  • 2. • PHP Caching • WordPress Page Caching • WordPress Object Caching • Deferred Execution of code Agenda
  • 7. • Use InnoDB
 unless you have a good reason not to • Use the slow query log • Use EXPLAIN on queries,
 learn what the output means • Double, Triple check your indexes • Learn about quirks MySQL
  • 8. • Use an opcode cache ( Zend Opcache, XCache, APC ) • Use newer versions • Don’t use on static files • Be careful with preg_* functions • Profile your code ( Xdebug,VLD, XHProf ) • Don’t re-invent native PHP functions PHP
  • 9. PHP - opcode caching .php Read Parse Compile Execute Output
  • 10. PHP - opcode caching .php Execute Output OPcache Opcode Cache
  • 11. • Reduce time per request by 4X • Increase requests per second by 4x • Less work, for the same result means more capacity PHP - opcode caching
  • 12. Transients • Persistent out of the box • Stored in wp_options: _transient_{key} • WordPress uses them for certain internal functions • set_, get_, and delete_transient() Object Cache • Not persistent without a plugin, such as W3 Total Cache or Memcached Object Cache • Storage depends on server's and plugin's capabilities • Used extensively within WordPress Cache objects can be grouped wp_cache_add(), _set, _get, _delete WordPress Native Caching APIs
  • 13. • W3 Total Cache provides object level caching using disk, opcode or memcache(d) memory stores. • Memcached Object Cache provides a persistent backend for the WordPress object cache. A memcached server and the PECL memcached extension are required. • APC Object Cache provides a persistent backend for the WordPress object cache using APC, the default opcode and key/value cache of PHP. • Redis Object Cache supports the use of Predis (PHP client library), HHVM's Redis extension and the PECL Redis extension to provide a persistent backend for the WordPress object cache. Redis is required. • WP File Cache implements object level persistent caching by shifting the load from your database to your disk/file system. Object cache - plugins
  • 14. • Free & open source • High-performance, distributed memory object caching system • Key / Value data storage • In memory only, won’t survive a reboot • http://memcached.org/ Memcached
  • 15. • WordPress Object Cache 
 
 Reduces the number of database queries 
 http://wordpress.org/extend/plugins/ memcached/ WordPress + Memcached
  • 17. Full Page Caching • Batcache • WP Super Cache • W3 Total Cache
  • 18. Batcache is a plugin to store and serve cached versions of rendered pages. • Batcache uses memcached as its storage and is aimed at preventing a flood of traffic from breaking your site. • It does this by serving old pages to new users. • This reduces the demand on the web server CPU and the database. • It also means some people may see a page that is up to 5 minutes old. Full Page Caching - Batcache
  • 19. Who receives a cached pageview? • By default, all new users receive a cached pageview. • New users are defined as anybody who hasn’t interacted with your domain —once they’ve left a comment or logged in, their cookies will ensure they get fresh pages. • Note that URLs with query strings are automatically exempt from Batcache. Full Page Caching - Batcache
  • 20. WordPress + Memcached Memcached HTTP PHP MySQL WordPress Batcache
  • 21. Because Batcache caches fully rendered pages, per-user interactions on the server-side can be problematic. This means usage of objects/functions like: •$_COOKIE •setcookie •$_SERVER['HTTP_USER_AGENT'] •Anything that’s unique to an individual user cannot be relied on, as the values may be cached and cross- pollution can occur. In most cases, any user-level interactions should be moved to client-side using JavaScript. Full Page Caching - Batcache
  • 22. WP Home page (not logged) Requests/sec (mean) PHP 0.89 PHP + OPCODE 1.05 PHP + OPCODE + OBJECT CACHE (MEMCACHED OC + MEMCACHE SERVER) 7.33 PHP + OPCODE + OBJECT CACHE + PAGE CACHE (W3 Total Cache + MEMCACHE SERVER) 29.17 PHP + OPCODE + OBJECT CACHE + PAGE CACHE (W3 Total Cache on Disk) 29.49 PHP + OPCODE + OBJECT CACHE + PAGE CACHE (MEMCACHED OC + BATCACHE + MEMCACHE SERVER) 29.72 PHP + OPCODE + PAGE CACHE (WP Super Cache) 29.57
  • 23. Deferred execution of code - Asynchronous Jobs Queue
  • 24. PHP executes in a single threaded manner. That is the interpreter does A, then B, then C, then D, then finishes, and wipes its slate clean (shared nothing). It does this same things for every page view on your site. Deferred execution of code
  • 25. •Everything from spam checking, through sending emails, Push Notifications, is not necessary to render the HTML page. •Those tasks could be stashed in the Jobs system. •Another process elsewhere on your network will pick up the job, pull out the message, check it for duplication, spam, language, stick it in the db if that all passes, and then finally send out emails / PNs to all the recipients. Deferred execution of code
  • 26. Deferred execution of code Jobs system
  • 27. • Lots of options (WP Async Task library, WP Background Processing) • We built one for WordPress.com • http://code.trac.wordpress.org/browser/jobs • http://code.trac.wordpress.org/wiki/JobsDocs • All PHP + MySQL • Good for anything that isn’t required for rendering a page Deferred execution of code
  • 28. • WordPress • A new comment is posted on the blog • WordPress does follow the normal flow, and enqueue a new Job in the Jobs system • The Jobs Systems • Loads the job from the DB • Checks the userID of the author of the post. • Checks that the Author of the post has a device registered • Check user preferences • Checks the type of the device (Android, iOS, Windows) • Creates the PN object by using the device type information, and send it to the correct remote server • Handles errors and re-enqueue it if something went wrong Deferred execution of code - Send Push Notifications to Users