Magento Performance Issues | Blue Frog Docs

Magento Performance Issues

Troubleshoot and resolve performance issues on Magento websites.

Magento Performance Issues

Platform-specific guides for diagnosing and fixing Core Web Vitals and performance issues on Magento.

Core Web Vitals

Largest Contentful Paint (LCP)

Fix slow main content loading on Magento. Target: under 2.5 seconds.

Cumulative Layout Shift (CLS)

Resolve visual stability issues causing layout shifts. Target: under 0.1.

Common Magento Performance Issues

Database Performance

Magento is database-intensive, making database optimization critical for performance.

Common issues:

  • Unindexed product catalogs
  • Fragmented database tables
  • Slow EAV (Entity-Attribute-Value) queries
  • Large log tables
  • Missing database indexes
  • Inefficient custom queries

Optimization strategies:

  • Run Magento indexers regularly (Real-time or scheduled)
  • Optimize MySQL configuration for Magento workloads
  • Enable query caching
  • Clean log tables regularly
  • Add custom indexes for frequently queried attributes
  • Use flat catalog for products and categories

Magento indexer management:

# Check indexer status
php bin/magento indexer:status

# Reindex all
php bin/magento indexer:reindex

# Set indexers to update on schedule
php bin/magento indexer:set-mode schedule

# Clean and reindex
php bin/magento cache:clean && php bin/magento indexer:reindex

MySQL optimization for Magento:

# my.cnf recommended settings
[mysqld]
innodb_buffer_pool_size = 4G
innodb_log_file_size = 512M
innodb_flush_log_at_trx_commit = 2
query_cache_size = 128M
query_cache_type = 1
tmp_table_size = 256M
max_heap_table_size = 256M
join_buffer_size = 8M

Caching Strategies

Magento's multi-layer caching system is essential for performance.

Built-in cache types:

  • Full Page Cache (FPC) - Critical for frontend performance
  • Block HTML output - Caches individual block content
  • Configuration - System configuration cache
  • Collections Data - Database query results
  • EAV types and attributes - Product attribute cache
  • Layouts - Layout building instructions

Enable and manage caches:

# Enable all caches
php bin/magento cache:enable

# Flush cache
php bin/magento cache:flush

# Clean cache
php bin/magento cache:clean

# Check cache status
php bin/magento cache:status

Varnish configuration (recommended for production):

  • Varnish provides superior full-page caching
  • Magento includes Varnish VCL configuration
  • Significantly faster than built-in FPC
  • Essential for high-traffic stores

Enable Varnish:

# Generate VCL for Varnish
php bin/magento varnish:vcl:generate --export-version=6 > varnish.vcl

# Configure Magento to use Varnish
Stores > Configuration > Advanced > System > Full Page Cache > Varnish

Redis for session and cache storage:

// app/etc/env.php
'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'Cm_Cache_Backend_Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => '6379',
                'database' => '0',
                'compress_data' => '1'
            ]
        ],
        'page_cache' => [
            'backend' => 'Cm_Cache_Backend_Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => '6379',
                'database' => '1',
                'compress_data' => '0'
            ]
        ]
    ]
],
'session' => [
    'save' => 'redis',
    'redis' => [
        'host' => '127.0.0.1',
        'port' => '6379',
        'database' => '2'
    ]
]

Theme and Template Performance

Magento themes can be resource-intensive.

Common issues:

  • Heavy default themes (Luma, Blank)
  • Excessive JavaScript and CSS
  • Unoptimized PHTML templates
  • Multiple layout XML files
  • RequireJS configuration overhead

Optimization techniques:

  • Use lightweight custom themes instead of heavy default themes
  • Enable JavaScript bundling and minification
  • Enable CSS merging and minification
  • Remove unused theme components
  • Optimize layout XML files
  • Implement critical CSS for above-the-fold content

Enable asset optimization:

# Production mode enables optimizations
php bin/magento deploy:mode:set production

# Or enable specific optimizations in Admin:
# Stores > Configuration > Advanced > Developer
# - Merge JavaScript Files: Yes
# - Merge CSS Files: Yes
# - Minify JavaScript Files: Yes
# - Minify CSS Files: Yes

Extension Performance

Third-party Magento extensions can severely impact performance.

Performance-heavy extensions:

  • Customer reviews and ratings
  • Product recommendations
  • Live chat widgets
  • Social media integrations
  • Advanced search extensions
  • Email marketing integrations

Best practices:

  • Audit installed extensions quarterly
  • Remove unused extensions completely
  • Check extension code quality before installation
  • Monitor extension impact on page load times
  • Use lightweight alternatives when possible
  • Prefer native Magento features over extensions

Disable unused modules:

# List all modules
php bin/magento module:status

# Disable specific module
php bin/magento module:disable Vendor_Module

# Disable multiple modules
php bin/magento module:disable Vendor_Module1 Vendor_Module2

Image Optimization

Product images are critical for e-commerce and must be optimized.

Best practices:

  • Resize product images to exact display dimensions
  • Use appropriate formats (JPG for photos, PNG for graphics)
  • Compress images (75-85% quality for JPG)
  • Enable image lazy loading
  • Use responsive images with srcset
  • Implement WebP format with fallbacks
  • Use Magento's image resize functionality

Magento image configuration:

# Resize product images
php bin/magento catalog:images:resize

# Clear generated images
php bin/magento catalog:image:cache:clean

Install WebP image support:

  • Use extensions like WebP Images by Mageplaza
  • Configure automatic WebP conversion
  • Implement fallbacks for unsupported browsers

JavaScript Performance

Magento uses RequireJS which can create performance bottlenecks.

Optimization strategies:

  • Enable JavaScript bundling in production
  • Use JavaScript minification
  • Remove unused JavaScript files
  • Defer non-critical JavaScript
  • Optimize RequireJS configuration
  • Consider moving to Magento PWA Studio for modern frontend

RequireJS optimization:

<!-- app/design/frontend/Vendor/theme/Magento_Theme/layout/default_head_blocks.xml -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <remove src="mage/calendar.js"/>
        <!-- Remove other unused scripts -->
    </head>
</page>

Magento-Specific Performance Features

Full Page Cache (FPC)

Magento's FPC is critical for performance.

Configuration:

  • Enable FPC in Admin: Stores > Configuration > Advanced > System > Full Page Cache
  • Choose Varnish for best performance (or built-in for development)
  • Configure cache lifetime (86400 seconds recommended)
  • Set up cache warming after deployments

Cache hole fixing:

  • Identify uncacheable blocks causing full-page cache bypass
  • Move dynamic content to AJAX-loaded sections
  • Use customer-specific sections for personalized content
  • Minimize use of cacheable="false" in layout XML

Flat Catalog

Flat catalog improves query performance for large catalogs.

Enable flat catalog:

# Admin: Stores > Configuration > Catalog > Catalog > Storefront
# - Use Flat Catalog Category: Yes
# - Use Flat Catalog Product: Yes

# Reindex after enabling
php bin/magento indexer:reindex catalog_category_flat catalog_product_flat

Considerations:

  • Increases database size
  • Improves frontend query performance
  • Essential for catalogs >5000 products
  • Requires reindexing after changes

Production Mode

Running Magento in production mode enables critical optimizations.

Enable production mode:

# Switch to production mode
php bin/magento deploy:mode:set production

# This enables:
# - Static file caching
# - Error logging instead of display
# - Automatic code compilation
# - Symlink deployment

Elasticsearch

Elasticsearch provides superior search performance over MySQL.

Benefits:

  • Faster catalog search
  • Better search relevance
  • Reduced database load
  • Advanced filtering capabilities
  • Faceted search performance

Configuration:

# Install Elasticsearch module
composer require elasticsearch/elasticsearch

# Configure in Admin:
# Stores > Configuration > Catalog > Catalog > Catalog Search
# Search Engine: Elasticsearch 7.x

# Reindex catalog search
php bin/magento indexer:reindex catalogsearch_fulltext

Magento Hosting and Infrastructure

PHP optimization:

; php.ini for Magento
memory_limit = 4G
max_execution_time = 1800
upload_max_filesize = 64M
post_max_size = 64M
opcache.enable = 1
opcache.memory_consumption = 512
opcache.max_accelerated_files = 60000
opcache.validate_timestamps = 0
realpath_cache_size = 10M
realpath_cache_ttl = 7200

Nginx configuration for Magento:

upstream fastcgi_backend {
    server unix:/var/run/php/php8.1-fpm.sock;
}

server {
    listen 80;
    server_name example.com;
    root /var/www/magento/pub;

    index index.php;
    autoindex off;
    charset UTF-8;

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

    # Cache static files
    location ~* \.(jpg|jpeg|gif|png|css|js|ico|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }

    # PHP handling
    location ~ \.php$ {
        fastcgi_pass fastcgi_backend;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

CDN Integration

Magento CDN configuration:

  • Stores > Configuration > General > Web > Base URLs
  • Set secure and unsecure base URLs for media
  • Use CloudFlare, Fastly, or AWS CloudFront
  • Configure proper cache rules

Fastly (recommended for Magento Commerce):

  • Included with Adobe Commerce Cloud
  • Magento-optimized VCL configuration
  • Real-time purging
  • Image optimization
  • WAF protection

Database Optimization

Maintenance commands:

# Optimize tables
mysqlcheck -o magento_database

# Clean log tables
php bin/magento log:clean

# Clean expired sessions
php bin/magento session:cleanup

Performance Testing for Magento

Diagnostic Tools

  1. Google PageSpeed Insights - Core Web Vitals analysis
  2. Chrome DevTools Performance Tab - Detailed waterfall analysis
  3. Lighthouse - Comprehensive performance audit
  4. Magento Profiler - Built-in performance profiling
  5. New Relic - Application performance monitoring
  6. Blackfire.io - PHP profiler for Magento

Enable Magento profiler:

# Add to index.php
\Magento\Framework\Profiler::applyConfig(
    ['drivers' => [['output' => 'html']]],
    BP
);

Key Metrics for Magento

Performance targets:

Platform-Specific Troubleshooting

Slow Category Pages

Causes:

  • Large product catalogs without flat catalog
  • Unoptimized layered navigation
  • Heavy product listing blocks
  • Missing database indexes

Fixes:

  • Enable flat catalog for categories and products
  • Optimize layered navigation queries
  • Implement pagination (24-48 products per page)
  • Use Elasticsearch for filtering
  • Cache product collections
  • Optimize category images

Slow Product Pages

Causes:

  • Many product options and configurable products
  • Heavy product reviews
  • Related/upsell product queries
  • Unoptimized product images

Fixes:

  • Optimize configurable product option loading
  • Lazy load product reviews
  • Cache related product blocks
  • Implement image lazy loading
  • Reduce number of product images loaded initially

Slow Checkout Process

Causes:

  • Complex shipping calculations
  • Multiple payment gateway validations
  • Heavy checkout page blocks
  • Address validation overhead

Fixes:

  • Optimize shipping method calculations
  • Implement checkout page caching where possible
  • Minimize checkout page blocks
  • Use AJAX for dynamic checkout elements
  • Optimize payment gateway integrations
  • Enable guest checkout

Admin Panel Performance

Optimization tips:

  • Enable Admin Panel caching
  • Limit grid row display (50-100 rows)
  • Optimize admin notifications
  • Disable unused admin grids
  • Use admin action logging selectively

Advanced Performance Techniques

Implement Varnish ESI

Edge Side Includes (ESI) for personalized content:

  • Cart blocks via ESI
  • Customer sections via ESI
  • Reduce cache holes
  • Better full-page cache hit rates

Database Read Replicas

For high-traffic stores:

// app/etc/env.php
'db' => [
    'connection' => [
        'default' => [
            'host' => 'master-db',
            'dbname' => 'magento',
            'username' => 'magento',
            'password' => 'password',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'initStatements' => 'SET NAMES utf8;',
            'active' => '1',
        ],
        'indexer' => [
            'host' => 'slave-db',
            'dbname' => 'magento',
            'username' => 'magento',
            'password' => 'password',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'initStatements' => 'SET NAMES utf8;',
            'active' => '1',
        ]
    ]
]

Magento PWA Studio

For modern, high-performance storefronts:

  • React-based frontend
  • GraphQL API
  • Service workers and offline support
  • Superior mobile performance
  • Improved Core Web Vitals

Implement HTTP/2 Server Push

Push critical resources:

location / {
    http2_push /static/frontend/Vendor/theme/en_US/css/styles-m.css;
    http2_push /static/frontend/Vendor/theme/en_US/js/theme.js;
}

Ongoing Maintenance

Regular Performance Tasks

Daily:

  • Monitor server resource usage
  • Check error logs for performance issues

Weekly:

  • Review slow query log
  • Monitor cache hit rates
  • Check indexer status

Monthly:

  • Run full database optimization
  • Audit installed extensions
  • Review and clean log tables
  • Test page load times across site
  • Update Magento and extensions

Magento Updates

  • Keep Magento updated for performance improvements
  • Test updates in staging environment
  • Review release notes for performance enhancements
  • Apply security patches promptly

Update Magento:

# Update via Composer
composer update

# Run upgrade
php bin/magento setup:upgrade

# Compile code
php bin/magento setup:di:compile

# Deploy static content
php bin/magento setup:static-content:deploy

# Flush cache
php bin/magento cache:flush

General Fixes

For universal performance concepts, see the Global Performance Issues Hub.

// SYS.FOOTER