1. Transients & Unindexed postmeta Bottlenecks
Under high concurrency, WooCommerce relies heavily on `wp_options` for session handling and `wp_postmeta` for order persistence. Standard InnoDB table locks escalate to row-level deadlocks when multiple workers update inventory (`_stock`) and session transients simultaneously.
SELECT post_id FROM wp_postmeta WHERE meta_key = '_wc_session_expires' AND meta_value < 1783584000 FOR UPDATE;
-- DEADLOCK DETECTED: Transaction waiting for X-lock on index PRIMARY of table wp_postmeta
2. Decoupling Webhook Processing
Never allow third-party payment webhooks (Stripe, PayPal) to execute synchronous database mutations inside the foreground checkout loop. Routing webhooks through an asynchronous Redis worker drops checkout completion latency from 4.2 seconds to 310 milliseconds.
// Disable transient garbage collection during checkout traffic spikes
add_action( 'init', function() {
if ( is_checkout() || is_cart() || defined( 'DOING_AJAX' ) ) {
remove_action( 'wp_scheduled_delete', 'delete_expired_transients' );
wp_suspend_cache_addition( true );
}
}, 1 );
3. Redis Session Offloading
Migrate WooCommerce customer sessions (`_wc_session_...`) out of MySQL into an in-memory Redis cluster (`wp-redis`) to eliminate relational database write bottlenecks during address validation and cart calculation.