Scaling WooCommerce

23
Scaling WooCommerce in the way that matters most

Transcript of Scaling WooCommerce

Scaling WooCommercein the way that matters most

Patrick Garman@pmgarman

Yet ANOTHER talk about scaling WordPress

Caching

Lots of Traffic

* Assuming very low conversion rate

● Static cache is your friend

● Find a solution for serving logged in visitors cached pages

● Remove header/sidebar carts where possible

Lots of Products ● Static cache is your friend

● Paginate or limit customer reviews being shown

● Disable “Show verified owner label for customer reviews” option for product reviews

● Replace WordPress search

Scaling WooCommerce

Changes the Conversation

How do you scale a high traffic blog?

● Full page caches● Object caches● Fragment caches● Cache database queries● Database replication

What can’t save you when your site survives a flood of new traffic thanks to caching and they all want to place an order?

● Cache

What can break WooCommerce in the most glorious way possible?

● Replication Lag

Can WooCommerce Scale?

Yes *

* Not overnight, not without careful planning, not without help.

Lots of Orders

?

Coupons

70,000The number of times a coupon can be used before things break.

wp_postmeta

38The number of inserts to wp_postmeta by WooCommerce on checkout.

Deployed code combining 29 wp_postmeta inserts into 3 SQL queries https://core.trac.wordpress.org/ticket/34848

My Account

?The number of people who can open the My Account page at once.

Inefficient Queries

$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(

'numberposts' => $order_count,'meta_key' => '_customer_user','meta_value' => get_current_user_id(),'post_type' => wc_get_order_types( 'view-orders' ),'post_status' => array_keys( wc_get_order_statuses() )

) ) );

wp_postmeta grows exponentially

meta_value is not indexed

Inefficient QueriesSELECT wp_posts.IDFROM wp_posts INNER JOIN wp_postmetaON ( wp_posts.ID = wp_postmeta.post_id )WHERE 1=1 AND ( ( wp_postmeta.meta_key = '_customer_user'AND CAST(wp_postmeta.meta_value AS CHAR) = '1' ) )AND wp_posts.post_type IN ('shop_order', 'shop_order_refund')AND ((wp_posts.post_status = 'wc-pending'OR wp_posts.post_status = 'wc-processing'OR wp_posts.post_status = 'wc-on-hold'OR wp_posts.post_status = 'wc-completed'OR wp_posts.post_status = 'wc-cancelled'OR wp_posts.post_status = 'wc-refunded'OR wp_posts.post_status = 'wc-failed'))GROUP BY wp_posts.IDORDER BY wp_posts.post_date DESCLIMIT 0, 15

* Thanks Zach!

Perfect Example

March 14, 2016 - March 15, 2016

March 21, 2016 11:40 AM (CST) https://github.com/garmanio/wc-customer-order-index

Moving Forward With WooCommerce

@pmgarman

[email protected]

https://pmgarman.me

Patrick Garman