SlideShare une entreprise Scribd logo
1  sur  24
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

Contenu connexe

Tendances

Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAshokkumar 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 optimizationSanjeev 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_slideshareOpevel
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Jan Helke
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and meJason Casden
 
High Performance WordPress II
High Performance WordPress IIHigh Performance WordPress II
High Performance WordPress IIBarry 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
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimizationAlmog Baku
 
Extending Stash - Jason Hinch
Extending Stash - Jason HinchExtending Stash - Jason Hinch
Extending Stash - Jason HinchAtlassian
 
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-wrappersMarcus 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.0Abhijit Jana
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applicationsEugene 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 PerformancePantheon
 

Tendances (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
 

En vedette

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 Imunify360CloudLinux
 
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 Revisedstoem
 
Content marketing @ Server Density
Content marketing @ Server DensityContent marketing @ Server Density
Content marketing @ Server DensityServer Density
 
cache concepts and varnish-cache
cache concepts and varnish-cachecache concepts and varnish-cache
cache concepts and varnish-cacheMarc Cortinas Val
 
How to optimize CloudLinux OS limits
How to optimize CloudLinux OS limitsHow to optimize CloudLinux OS limits
How to optimize CloudLinux OS limitsCloudLinux
 
how to mesure web performance metrics
how to mesure web performance metricshow to mesure web performance metrics
how to mesure web performance metricsMarc 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 graphitedamaex17
 
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 2015Datadog
 
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 customersCloudLinux
 
LVE Manager's New UI
LVE Manager's New UILVE Manager's New UI
LVE Manager's New UICloudLinux
 
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 OSCloudLinux
 
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-toDatadog
 
Datadog + VictorOps Webinar
Datadog + VictorOps WebinarDatadog + VictorOps Webinar
Datadog + VictorOps WebinarDatadog
 
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 systemsJos 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 K8SCloudLinux
 
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 cloudDatadog
 
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 particularAnton Pinchuk
 

En vedette (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
 

Similaire à 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 codeDanilo Ercoli
 
Accelerating Rails with edge caching
Accelerating Rails with edge cachingAccelerating Rails with edge caching
Accelerating Rails with edge cachingMichael May
 
Rails Caching: Secrets From the Edge
Rails Caching: Secrets From the EdgeRails Caching: Secrets From the Edge
Rails Caching: Secrets From the EdgeFastly
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeMichael May
 
Magento performance feat. core Hacks
Magento performance feat. core HacksMagento performance feat. core Hacks
Magento performance feat. core HacksDaniel Niedergesäß
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchTaylor Lovett
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshopBoston 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 TimesScott Taylor
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails applicationArrrrCamp
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
WordPress Plugins and Security
WordPress Plugins and SecurityWordPress Plugins and Security
WordPress Plugins and SecurityThink 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 TaleKayleigh 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 '14slobodanmanic
 
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 2Mizanur Rahaman Mizan
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond bloggingJulien 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 PracticesBrian Krogsgard
 

Similaire à 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
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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.

Notes de l'éditeur

  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.