SlideShare a Scribd company logo
Caching, Scaling
, and
WordPress.com
VIP
Erick Hitter
Boston WordPress Meetup, November 28
Why Should You Care About
Anything I Have to Say?
Erick Hitter
Lead WordPress developer with Oomph!

@ethitter
http://www.ethitter.com
http://www.thinkoomph.com


Disclaimer: I started this in Google Docs, then had to switch to
PowerPoint, which explains some of the wonky formatting.
Caching

•   Serving static content to a visitor rather than
    something generated upon request.
•   Two major types in WordPress context:
    o   Page
         Whole page is static and, therefore, could be
           outdated.
    o   Fragment
         Cache pieces of a page rather than the entire
           page.
Fragment Caching Benefits

Allow dynamic and static content to coexist
Fragment Caching Benefits

Common elements can be reused throughout a site
Fragment Caching Benefits

Reduce calls to APIs
WordPress' Native Caching APIs

Transients                       Object Cache
•   Persistent out of the box    •   Not persistent without a
•   Stored in wp_options:            plugin, such as W3 Total
                                     Cache
    _transient_{key}
•   WordPress uses for           •   Storage depends on
                                     server's and plugin's
    certain internal functions
•   set_, get_, and
                                 •
                                     capabilities
                                     Used extensively within
    delete_transient()
                                     WordPress
                                 •   Cache objects can be
                                     grouped
                                 •   wp_cache_add(), _set, _g
                                     et, _delete
Fragment Caching Basics: Creating




 •   wp_cache_get() returns a boolean false if the requested cache isn't
     set or has expired.

 •   Everything that is to be cached must be accessible via a function that
     returns its results rather than echoing them, otherwise output
     buffering is needed.

 •   wp_cache_add() will not overwrite an existing, unexpired
     cache, whereas wp_cache_set() does.
Fragment Caching Basics: Clearing




Thisabove example clears a cache when anything is published or something
that is published is modified. The "something" could be a post, page, or
custom post type object.

If, instead, the cache should be rebuilt when the same event
occurs, wp_cache_delete() could be replaced with generate_cached_output().
Unpredictable Keys

• Object caching doesn’t provide a way to clear
    all caches in a given group.
•   Therefore, if the cache key is
    unpredictable, how can we clear it?

• For example, a list of recent posts to be
    displayed on an individual post, but that
    excludes the current post.
Unpredictable Keys: Recent Posts
Unpredictable Keys: Cached Array
Unpredictable Keys: Cached Array

Pros                            Cons
•   Cache can easily be         •   Object caching
    cleared because a single        configuration may limit size
    object with a predictable       of individual cache objects.
    key is set.                 •   Array corruption could
•   Cache is only rebuilt if        invalidate an entire cache
    specific post ID/quantity       object.
    key is absent from array.   •   Array can become bloated
•   Better for cache elements       if different quantities are
    that are reliably small.        used simultaneously.
•   Allows for checking
    existence of various
    keys, such as in a loop.
Unpredictable Keys: Incrementor
Where We Use Fragment Caching
•   Custom loops
•   Anytime a lot of data must be retrieved from WordPress
    and parsed.
•   Most situations where WP_Query generates a subquery
    outside of the main query.
•   Almost anything that is reused across multiple pages.
category__not_invspost__not_in




SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN (
SELECT tr.object_id FROM wp_term_relationships
AS tr INNER JOIN wp_term_taxonomy AS tt ON
tr.term_taxonomy_id = tt.term_taxonomy_id WHERE
tt.taxonomy = 'category' AND tt.term_id IN
('167') ) …
category__not_invspost__not_in
category__not_invspost__not_in



SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN (
SELECT tr.object_id FROM wp_term_relationships
AS tr INNER JOIN wp_term_taxonomy AS tt ON
tr.term_taxonomy_id = tt.term_taxonomy_id WHERE
tt.taxonomy = 'category' AND tt.term_id IN
('167') ) …
SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN (
'1','2','3','4','5' ) …
Menu Caching: No Active States
Menu Caching: Active States
Menu Caching: Keys & Clearing
•   get_queried_object_id() returns an integer representing
    the post ID or term ID.
•    Front page and custom post type archives return 0.

•   Menu caches must be cleared when four different
    actions fire to ensure consistency:
    o   wp_update_nav_menu
    o   wp_update_nav_menu_item
    o   wp_delete_nav_menu
    o   wp_setup_nav_menu_item
query_posts() vspre_get_posts

query_posts()               pre_get_posts
•   Function provided to    •   Action used to modify
    modify main query.          any query.
•   Runs after main query   •   Runs before every query
    has already executed.       executes.
How Does This Factor Into Our Work
On WordPress.com VIP?
•   Page caches only last for five minutes.
•   No page caching for logged-in users.
•   Sites that publish with great frequency trigger regular
    invalidations of homepage and category pages.
•   Web servers outnumber database servers.

•   Want to know more about WordPress.com
    infrastructure? Check out http://goo.gl/lYpJH.
Questions?

erick@thinkoomph.com

@ethitter

http://www.slideshare.net/ethitter

More Related Content

What's hot

Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A
 
Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!
Ivan Chepurnyi
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
Sencha
 
Presentation on Instant page speed optimization
Presentation on Instant page speed optimizationPresentation on Instant page speed optimization
Presentation on Instant page speed optimization
Sanjeev Kumar Jaiswal
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?
Brian Moon
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
Opevel
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
Jan Helke
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
Betclic Everest Group Tech Team
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
Jason Casden
 
High Performance WordPress II
High Performance WordPress IIHigh Performance WordPress II
High Performance WordPress II
Barry Abrahamson
 
WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)
jaredwsmith
 
Asp.net caching
Asp.net cachingAsp.net caching
Asp.net caching
Mindfire Solutions
 
Caching in asp.net mvc
Caching in asp.net mvcCaching in asp.net mvc
Caching in asp.net mvc
KarthikaDevi Rajasekaran
 
Caching 101 - WordCamp OC
Caching 101 - WordCamp OCCaching 101 - WordCamp OC
Caching 101 - WordCamp OC
Eugene Kovshilovsky
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimization
Almog Baku
 
Extending Stash - Jason Hinch
Extending Stash - Jason HinchExtending Stash - Jason Hinch
Extending Stash - Jason Hinch
Atlassian
 
Drupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappers
Marcus Deglos
 
Caching Enhancement in ASP.NET 4.0
Caching Enhancement in ASP.NET 4.0Caching Enhancement in ASP.NET 4.0
Caching Enhancement in ASP.NET 4.0
Abhijit Jana
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
Eugene Lazutkin
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Pantheon
 

What's hot (20)

Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!Varnish Cache and its usage in the real world!
Varnish Cache and its usage in the real world!
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
Presentation on Instant page speed optimization
Presentation on Instant page speed optimizationPresentation on Instant page speed optimization
Presentation on Instant page speed optimization
 
Memcached: What is it and what does it do?
Memcached: What is it and what does it do?Memcached: What is it and what does it do?
Memcached: What is it and what does it do?
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
 
High Performance WordPress II
High Performance WordPress IIHigh Performance WordPress II
High Performance WordPress II
 
WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)WordPress at Peak Performance (Radio Edit)
WordPress at Peak Performance (Radio Edit)
 
Asp.net caching
Asp.net cachingAsp.net caching
Asp.net caching
 
Caching in asp.net mvc
Caching in asp.net mvcCaching in asp.net mvc
Caching in asp.net mvc
 
Caching 101 - WordCamp OC
Caching 101 - WordCamp OCCaching 101 - WordCamp OC
Caching 101 - WordCamp OC
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimization
 
Extending Stash - Jason Hinch
Extending Stash - Jason HinchExtending Stash - Jason Hinch
Extending Stash - Jason Hinch
 
Drupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappersDrupal feature proposal: two new stream-wrappers
Drupal feature proposal: two new stream-wrappers
 
Caching Enhancement in ASP.NET 4.0
Caching Enhancement in ASP.NET 4.0Caching Enhancement in ASP.NET 4.0
Caching Enhancement in ASP.NET 4.0
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress Performance
 

Viewers also liked

Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360
CloudLinux
 
Matthew Kaufman Future Of Communication With Rtmfp Final Revised
Matthew Kaufman Future Of Communication With Rtmfp Final RevisedMatthew Kaufman Future Of Communication With Rtmfp Final Revised
Matthew Kaufman Future Of Communication With Rtmfp Final Revised
stoem
 
Content marketing @ Server Density
Content marketing @ Server DensityContent marketing @ Server Density
Content marketing @ Server Density
Server Density
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
Marc Cortinas Val
 
How to optimize CloudLinux OS limits
How to optimize CloudLinux OS limitsHow to optimize CloudLinux OS limits
How to optimize CloudLinux OS limits
CloudLinux
 
how to mesure web performance metrics
how to mesure web performance metricshow to mesure web performance metrics
how to mesure web performance metrics
Marc Cortinas Val
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnishschoefmax
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphite
damaex17
 
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
Datadog
 
How lve stats2 works for you and your customers
How lve stats2 works for you and your customersHow lve stats2 works for you and your customers
How lve stats2 works for you and your customers
CloudLinux
 
LVE Manager's New UI
LVE Manager's New UILVE Manager's New UI
LVE Manager's New UI
CloudLinux
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
CloudLinux
 
Redis vs Memcached
Redis vs MemcachedRedis vs Memcached
Redis vs Memcached
Gaurav Agrawal
 
Monitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-toMonitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-to
Datadog
 
Datadog + VictorOps Webinar
Datadog + VictorOps WebinarDatadog + VictorOps Webinar
Datadog + VictorOps Webinar
Datadog
 
Chaos patterns - architecting for failure in distributed systems
Chaos patterns - architecting for failure in distributed systemsChaos patterns - architecting for failure in distributed systems
Chaos patterns - architecting for failure in distributed systems
Jos Boumans
 
Single tenant software to multi-tenant SaaS using K8S
Single tenant software to multi-tenant SaaS using K8SSingle tenant software to multi-tenant SaaS using K8S
Single tenant software to multi-tenant SaaS using K8S
CloudLinux
 
Monitoring kubernetes across data center and cloud
Monitoring kubernetes across data center and cloudMonitoring kubernetes across data center and cloud
Monitoring kubernetes across data center and cloud
Datadog
 
How to measure everything - a million metrics per second with minimal develop...
How to measure everything - a million metrics per second with minimal develop...How to measure everything - a million metrics per second with minimal develop...
How to measure everything - a million metrics per second with minimal develop...
Jos Boumans
 
Video Streaming. NGINX RTMP in particular
Video Streaming. NGINX RTMP in particularVideo Streaming. NGINX RTMP in particular
Video Streaming. NGINX RTMP in particular
Anton Pinchuk
 

Viewers also liked (20)

Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360Keeping web servers safe and profitable with Imunify360
Keeping web servers safe and profitable with Imunify360
 
Matthew Kaufman Future Of Communication With Rtmfp Final Revised
Matthew Kaufman Future Of Communication With Rtmfp Final RevisedMatthew Kaufman Future Of Communication With Rtmfp Final Revised
Matthew Kaufman Future Of Communication With Rtmfp Final Revised
 
Content marketing @ Server Density
Content marketing @ Server DensityContent marketing @ Server Density
Content marketing @ Server Density
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cache
 
How to optimize CloudLinux OS limits
How to optimize CloudLinux OS limitsHow to optimize CloudLinux OS limits
How to optimize CloudLinux OS limits
 
how to mesure web performance metrics
how to mesure web performance metricshow to mesure web performance metrics
how to mesure web performance metrics
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnish
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphite
 
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
Docker Usage Patterns - Meetup Docker Paris - November, 10th 2015
 
How lve stats2 works for you and your customers
How lve stats2 works for you and your customersHow lve stats2 works for you and your customers
How lve stats2 works for you and your customers
 
LVE Manager's New UI
LVE Manager's New UILVE Manager's New UI
LVE Manager's New UI
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
 
Redis vs Memcached
Redis vs MemcachedRedis vs Memcached
Redis vs Memcached
 
Monitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-toMonitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-to
 
Datadog + VictorOps Webinar
Datadog + VictorOps WebinarDatadog + VictorOps Webinar
Datadog + VictorOps Webinar
 
Chaos patterns - architecting for failure in distributed systems
Chaos patterns - architecting for failure in distributed systemsChaos patterns - architecting for failure in distributed systems
Chaos patterns - architecting for failure in distributed systems
 
Single tenant software to multi-tenant SaaS using K8S
Single tenant software to multi-tenant SaaS using K8SSingle tenant software to multi-tenant SaaS using K8S
Single tenant software to multi-tenant SaaS using K8S
 
Monitoring kubernetes across data center and cloud
Monitoring kubernetes across data center and cloudMonitoring kubernetes across data center and cloud
Monitoring kubernetes across data center and cloud
 
How to measure everything - a million metrics per second with minimal develop...
How to measure everything - a million metrics per second with minimal develop...How to measure everything - a million metrics per second with minimal develop...
How to measure everything - a million metrics per second with minimal develop...
 
Video Streaming. NGINX RTMP in particular
Video Streaming. NGINX RTMP in particularVideo Streaming. NGINX RTMP in particular
Video Streaming. NGINX RTMP in particular
 

Similar to Caching, Scaling, and What I've Learned from WordPress.com VIP

Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
Danilo Ercoli
 
The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
Kan Ouivirach, Ph.D.
 
Accelerating Rails with edge caching
Accelerating Rails with edge cachingAccelerating Rails with edge caching
Accelerating Rails with edge caching
Michael May
 
Rails Caching: Secrets From the Edge
Rails Caching: Secrets From the EdgeRails Caching: Secrets From the Edge
Rails Caching: Secrets From the Edge
Fastly
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the Edge
Michael May
 
Magento performance feat. core Hacks
Magento performance feat. core HacksMagento performance feat. core Hacks
Magento performance feat. core Hacks
Daniel Niedergesäß
 
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
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
David Biňovec
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
Taylor Lovett
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshop
Boston WordPress
 
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
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
ArrrrCamp
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
Taylor Lovett
 
WordPress Plugins and Security
WordPress Plugins and SecurityWordPress Plugins and Security
WordPress Plugins and Security
Think Media Inc.
 
Battling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support TaleBattling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support Tale
Kayleigh Thorpe
 
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
slobodanmanic
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2
Mizanur Rahaman Mizan
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
Julien Minguely
 
Presentation to SAIT Students - Dec 2013
Presentation to SAIT Students - Dec 2013Presentation to SAIT Students - Dec 2013
Presentation to SAIT Students - Dec 2013Think Media Inc.
 
WordPress Theming Best Practices
WordPress Theming Best PracticesWordPress Theming Best Practices
WordPress Theming Best Practices
Brian Krogsgard
 

Similar to Caching, Scaling, and What I've Learned from WordPress.com VIP (20)

Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
 
The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
 
Accelerating Rails with edge caching
Accelerating Rails with edge cachingAccelerating Rails with edge caching
Accelerating Rails with edge caching
 
Rails Caching: Secrets From the Edge
Rails Caching: Secrets From the EdgeRails Caching: Secrets From the Edge
Rails Caching: Secrets From the Edge
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the Edge
 
Magento performance feat. core Hacks
Magento performance feat. core HacksMagento performance feat. core Hacks
Magento performance feat. core Hacks
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Caching in WordPress
Caching in WordPressCaching in WordPress
Caching in WordPress
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshop
 
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
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
WordPress Plugins and Security
WordPress Plugins and SecurityWordPress Plugins and Security
WordPress Plugins and Security
 
Battling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support TaleBattling the WSOD - A Tech Support Tale
Battling the WSOD - A Tech Support Tale
 
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
Presentation to SAIT Students - Dec 2013
Presentation to SAIT Students - Dec 2013Presentation to SAIT Students - Dec 2013
Presentation to SAIT Students - Dec 2013
 
WordPress Theming Best Practices
WordPress Theming Best PracticesWordPress Theming Best Practices
WordPress Theming Best Practices
 

Recently uploaded

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 

Caching, Scaling, and What I've Learned from WordPress.com VIP

  • 1. Caching, Scaling , and WordPress.com VIP Erick Hitter Boston WordPress Meetup, November 28
  • 2. Why Should You Care About Anything I Have to Say? Erick Hitter Lead WordPress developer with Oomph! @ethitter http://www.ethitter.com http://www.thinkoomph.com Disclaimer: I started this in Google Docs, then had to switch to PowerPoint, which explains some of the wonky formatting.
  • 3. Caching • Serving static content to a visitor rather than something generated upon request. • Two major types in WordPress context: o Page  Whole page is static and, therefore, could be outdated. o Fragment  Cache pieces of a page rather than the entire page.
  • 4. Fragment Caching Benefits Allow dynamic and static content to coexist
  • 5. Fragment Caching Benefits Common elements can be reused throughout a site
  • 7. WordPress' Native Caching APIs Transients Object Cache • Persistent out of the box • Not persistent without a • Stored in wp_options: plugin, such as W3 Total Cache _transient_{key} • WordPress uses for • Storage depends on server's and plugin's certain internal functions • set_, get_, and • capabilities Used extensively within delete_transient() WordPress • Cache objects can be grouped • wp_cache_add(), _set, _g et, _delete
  • 8. Fragment Caching Basics: Creating • wp_cache_get() returns a boolean false if the requested cache isn't set or has expired. • Everything that is to be cached must be accessible via a function that returns its results rather than echoing them, otherwise output buffering is needed. • wp_cache_add() will not overwrite an existing, unexpired cache, whereas wp_cache_set() does.
  • 9. Fragment Caching Basics: Clearing Thisabove example clears a cache when anything is published or something that is published is modified. The "something" could be a post, page, or custom post type object. If, instead, the cache should be rebuilt when the same event occurs, wp_cache_delete() could be replaced with generate_cached_output().
  • 10. Unpredictable Keys • Object caching doesn’t provide a way to clear all caches in a given group. • Therefore, if the cache key is unpredictable, how can we clear it? • For example, a list of recent posts to be displayed on an individual post, but that excludes the current post.
  • 13. Unpredictable Keys: Cached Array Pros Cons • Cache can easily be • Object caching cleared because a single configuration may limit size object with a predictable of individual cache objects. key is set. • Array corruption could • Cache is only rebuilt if invalidate an entire cache specific post ID/quantity object. key is absent from array. • Array can become bloated • Better for cache elements if different quantities are that are reliably small. used simultaneously. • Allows for checking existence of various keys, such as in a loop.
  • 15. Where We Use Fragment Caching • Custom loops • Anytime a lot of data must be retrieved from WordPress and parsed. • Most situations where WP_Query generates a subquery outside of the main query. • Almost anything that is reused across multiple pages.
  • 16. category__not_invspost__not_in SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN ( SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ('167') ) …
  • 18. category__not_invspost__not_in SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN ( SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ('167') ) … SELECT … WHERE 1=1 ANDwp_posts.ID NOT IN ( '1','2','3','4','5' ) …
  • 19. Menu Caching: No Active States
  • 21. Menu Caching: Keys & Clearing • get_queried_object_id() returns an integer representing the post ID or term ID. • Front page and custom post type archives return 0. • Menu caches must be cleared when four different actions fire to ensure consistency: o wp_update_nav_menu o wp_update_nav_menu_item o wp_delete_nav_menu o wp_setup_nav_menu_item
  • 22. query_posts() vspre_get_posts query_posts() pre_get_posts • Function provided to • Action used to modify modify main query. any query. • Runs after main query • Runs before every query has already executed. executes.
  • 23. How Does This Factor Into Our Work On WordPress.com VIP? • Page caches only last for five minutes. • No page caching for logged-in users. • Sites that publish with great frequency trigger regular invalidations of homepage and category pages. • Web servers outnumber database servers. • Want to know more about WordPress.com infrastructure? Check out http://goo.gl/lYpJH.

Editor's Notes

  1. To clear, must know both post ID and quantity originally requested.
  2. WordPress.com permits caches no larger than 1MB.Array of related posts for site with lots of content can exceed that easily.For VentureBeat, certain ad options are cached into an array so that a default can be provided.
  3. Overcomes the limitations of array cache objectDeleting incrementor invalidates any existing caches, which will be pushed out of the object cache over time.
  4. Custom loops – InvestorPlace Press CenterData retrieval – CACHE WRAPPERS FOR WORDPRESS FUNCTIONS - term data, including term objects and, especially, term relationships - large blocks of post meta - certain uses of user meta - show VentureBeat/functions/misc.php lines 1432 - 1488Subqueries – excluding taxonomy terms. Will cache data that subquery produces and pass through post__not_in or post__in when possible.Reusable – widgets, menus, common header or footer elements (VentureBeat)
  5. Eliminates subquery and its two joinsDropped execution time from roughly 45ms to 30ms.Caching imparts additional performance increase
  6. Menu items exist as objects in wp_posts table, organized by the nav_menu taxonomy.Since menu items are in a taxonomy, all taxonomy tables must be joined to posts table to retrieve menu items.If active menu states are unnecessary, the output or wp_nav_menu() can be cached directly.
  7. If using custom post types, must create own unique identifierCan add previously-discussed cache incrementor if invalidation is necessary.
  8. query_posts() discards a query without using it, then runs a new query. Unnecessarily inefficient.Not intended for creating new loops.
  9. First three in context of fragment caching for complex items such as VB menus and footer elementsWeb servers in context of reducing subqueriesWordPress.com infrastructure 1,500+ servers in 3 data centers 25 million sites 2 petabytes of storage 100% using nginxBatcache for page cachingMemcached for object caching Almost all database and caching servers use SSDs.