Performance Issues
Symptoms
Section titled “Symptoms”- Pages with Commerce blocks load slowly (>3 seconds)
- Product sync operations time out
- Server CPU/memory spikes during sync
- Admin dashboard sluggish when viewing products
- “Maximum execution time exceeded” errors
Common Causes
Section titled “Common Causes”1. Resource Limits Exceeded
Section titled “1. Resource Limits Exceeded”- PHP memory limit too low for catalog size
- Execution time insufficient for large syncs
- Database queries not optimized
- Too many products syncing simultaneously
2. Inefficient Caching
Section titled “2. Inefficient Caching”- WordPress® object cache not configured
- Page cache disabled or misconfigured
- BigCommerce API responses not cached
- Repeated unnecessary API calls
3. Large Media Files
Section titled “3. Large Media Files”- Product images not optimized
- Original BigCommerce images served directly
- No lazy loading for images
- Missing responsive image sizes
4. Database Performance
Section titled “4. Database Performance”- Missing database indexes
- Too many plugin/theme queries
- Large product catalog (1,000+ products)
- Unoptimized product queries
Solutions
Section titled “Solutions”Optimize Resource Limits
Section titled “Optimize Resource Limits”Configure PHP for Commerce Connect’s needs:
In wp-config.php:
// Memory limit for admin/sync operationsdefine('WP_MEMORY_LIMIT', '512M');define('WP_MAX_MEMORY_LIMIT', '512M');
// Increase max execution timeset_time_limit(300); // 5 minutesIn php.ini (if accessible):
memory_limit = 512Mmax_execution_time = 300max_input_time = 300Verify settings:
wp eval 'echo "Memory: " . WP_MEMORY_LIMIT . "\nMax: " . WP_MAX_MEMORY_LIMIT;'php -i | grep memory_limitMonitor Resource Usage During Sync
Section titled “Monitor Resource Usage During Sync”The plugin tracks resource consumption and backs off at 85% thresholds:
-
Check logs for resource warnings:
Terminal window tail -f wp-content/debug.log | grep "backing off" -
Look for these patterns:
Product sync backing off due to resource limitsmemory_ratio: 0.87(87% memory used - triggering backoff)execution_time_ratio: 0.89(89% time used - triggering backoff)
-
If consistently hitting 85%:
- Increase memory/time limits
- Reduce cron frequency (if customized)
- Contact hosting provider for plan upgrade
Enable Object Caching
Section titled “Enable Object Caching”Significantly speeds up product queries:
Install Redis or Memcached:
# Redis (recommended)wp plugin install redis-cache --activatewp redis enable
# OR Memcachedwp plugin install memcached --activateVerify object cache active:
wp cache typeExpected output: redis or memcached (not default)
Monitor cache hit rate:
wp redis infoLook for keyspace_hits vs keyspace_misses ratio (>80% hit rate is good)
Configure Page Caching
Section titled “Configure Page Caching”Use a caching plugin for static pages:
Options:
- WP Super Cache (simple, effective)
- W3 Total Cache (advanced features)
- LiteSpeed Cache (if using LiteSpeed server)
Commerce Connect compatibility notes:
- Cache product pages - Safe, products sync updates cache
- Cache cart page - Use edge-side includes or disable
- Exclude checkout - Never cache checkout/cart API endpoints
Exclude these from cache:
/wp-json/commerce-connect/*/cart/*/checkout/*Optimize Image Loading
Section titled “Optimize Image Loading”Product images can slow pages significantly:
Enable lazy loading (WordPress® 5.5+):
// Automatic for <img> tags// Verify in page source:// <img loading="lazy" src="..." />Use responsive images:
# Regenerate product image sizeswp media regenerate --yesConsider CDN for images:
- Configure BigCommerce to serve optimized images
- Or use WordPress® CDN plugin (Cloudflare, etc.)
- Enable WebP format if server supports it
Image optimization plugin (optional):
wp plugin install ewww-image-optimizer --activateReduce Product Sync Frequency
Section titled “Reduce Product Sync Frequency”If syncing too often causes load:
Default: Every 1 minute
To reduce frequency (advanced):
// In theme functions.php or custom pluginadd_filter('cron_schedules', function($schedules) { $schedules['every_five_minutes'] = [ 'interval' => 300, 'display' => __('Every 5 Minutes') ]; return $schedules;});
// Then re-register cron with new schedule// Note: Requires custom code modification⚠️ Warning: Reducing sync frequency means product updates take longer to appear.
Optimize Database
Section titled “Optimize Database”For large catalogs, database performance matters:
Add missing indexes (if needed):
-- Check current indexesSHOW INDEX FROM wp_posts WHERE Key_name LIKE '%post_type%';
-- Add custom index if beneficialALTER TABLE wp_postsADD INDEX idx_product_sync (post_type, post_status, post_modified);Clean up transients:
wp transient delete --allOptimize tables:
wp db optimizeMonitor Cron Performance
Section titled “Monitor Cron Performance”Cron jobs should complete quickly (<60 seconds):
Check cron event timing:
wp cron event list --fields=hook,next_run,recurrenceTest cron execution time:
time wp cron event run commerce_connect_sync_productsExpected: <30 seconds for medium catalogs (<500 products)
If consistently >60 seconds:
- Increase server resources
- Enable object caching
- Check for conflicting cron jobs
- Monitor concurrent cron executions
Verification
Section titled “Verification”After optimizations:
-
Clear all caches (object, page, browser)
-
Test page load speed:
Terminal window curl -w "@curl-format.txt" -o /dev/null -s https://yoursite.com/product-page/Create
curl-format.txt:time_total: %{time_total}s -
Verify resource usage stayed below 85% during sync:
Terminal window tail -f wp-content/debug.log | grep "resource" -
Check browser performance:
- Open DevTools → Network
- Reload product page
- Total load time should be <2 seconds
- Largest Contentful Paint (LCP) <2.5 seconds
-
Run speed test (optional):
- GTmetrix: https://gtmetrix.com
- Google PageSpeed Insights
- WebPageTest
Prevention
Section titled “Prevention”Ongoing Monitoring
Section titled “Ongoing Monitoring”Weekly checks:
- Monitor error logs for resource warnings
- Check page load times with real user monitoring
- Review server resource usage graphs (CPU, memory, I/O)
- Test checkout flow on slow connection
Monthly optimizations:
- Clear old transients and cached data
- Optimize database tables
- Review and prune unused plugins
- Update PHP to latest stable version
Capacity Planning
Section titled “Capacity Planning”For growing catalogs:
| Catalog Size | Recommended Memory | Recommended Setup |
|---|---|---|
| <100 products | 256MB | Shared hosting OK |
| 100-500 products | 512MB | VPS or managed WordPress® |
| 500-2,000 products | 1GB | Managed WordPress® + object cache |
| 2,000+ products | 2GB+ | Dedicated resources + CDN |
Scale indicators:
- Consistent 85% resource usage warnings
- Cron jobs taking >60 seconds
- Page load times increasing over time
- Customer complaints about speed
Best Practices
Section titled “Best Practices”For optimal performance:
- Enable object caching - Single biggest impact
- Use page caching - Except dynamic pages (cart, checkout)
- Optimize images - Lazy load, responsive sizes, WebP
- Monitor resource limits - Increase before hitting caps
- Keep WordPress® updated - Core, plugins, PHP version
- Limit active plugins - Deactivate unused plugins
- Use quality hosting - Managed WordPress® hosts optimize for performance
Advanced Debugging
Section titled “Advanced Debugging”Resource Monitor Metrics
Section titled “Resource Monitor Metrics”The plugin tracks these during sync:
{ "memory_used": 134217728, // bytes "memory_limit": 536870912, // bytes "memory_ratio": 0.25, // 25% used "execution_time": 45.3, // seconds "max_execution_time": 300, // seconds "execution_time_ratio": 0.15, // 15% used "cron_interval": 60, // seconds "time_until_next_cron": 12.4, // seconds "should_back_off": false // OK to continue}Interpret these values:
memory_ratio> 0.85 → Increase memory limitexecution_time_ratio> 0.85 → Increase timeouttime_until_next_cron< 10 → Sync taking too long, optimizeshould_back_off: true→ Already at capacity, scale up
Product Processing Time Tracking
Section titled “Product Processing Time Tracking”Plugin predicts if time exists for next product:
- Tracks max processing time per product (worst case)
- Predicts if current time remaining > max product time
- Stops processing if prediction fails (prevents incomplete sync)
To view timing data (requires debug logging):
grep "max_product_processing_time" wp-content/debug.logExponential Backoff State
Section titled “Exponential Backoff State”After sync failures, backoff prevents API hammering:
Check current backoff state:
wp option get commerce_connect_sync_backoff --format=jsonExample output:
{ "attempts": 3, "last_failure": 1654876543, "delay": 240}Interpretation:
attempts: 3→ 3rd consecutive failuredelay: 240→ Wait 240 seconds (4 min) before retrylast_failure→ Unix timestamp of last failure
Reset backoff manually (if issue resolved):
wp option delete commerce_connect_sync_backoffQuery Monitor Analysis
Section titled “Query Monitor Analysis”Use Query Monitor plugin for deep insights:
wp plugin install query-monitor --activateCheck for:
- Slow database queries (>1 second) during product load
- Duplicate queries (N+1 query problem)
- HTTP API calls - Should be minimal on cached pages
- PHP errors/warnings - May indicate code issues
Performance Profiling
Section titled “Performance Profiling”For persistent issues, profile with Xdebug:
- Enable Xdebug on staging site (never production)
- Run product sync with profiling
- Analyze cachegrind output with tools like KCacheGrind
- Identify bottlenecks in code execution
Or use New Relic/DataDog APM for production monitoring.