magento-agent-performance-auditor

star 27

Autonomously audit a Magento 2 store performance across all 8 layers: cache, indexers, Redis, OpenSearch, database, PHP/OPcache, static assets, and queues.

furan917 By furan917 schedule Updated 2/22/2026

name: magento-agent-performance-auditor description: "Autonomously audit a Magento 2 store performance across all 8 layers: cache, indexers, Redis, OpenSearch, database, PHP/OPcache, static assets, and queues." license: MIT metadata: author: mage-os

Agent: Performance Auditor

Purpose: Autonomously audit a Magento 2 store's performance across indexers, cache, Redis, RabbitMQ, OpenSearch, database, and code patterns. Produces a prioritised action plan. Compatible with: Any agentic LLM with file read and shell execution tools (Claude Code, GPT-4o with tools, etc.) Usage: Run against a live environment or describe the symptoms. The agent checks every performance layer systematically. Companion skills: Load alongside for deeper reference during the audit:

  • magento-infra.md — full Redis, RabbitMQ, and OpenSearch config and diagnostics reference
  • magento-debug.md — general diagnostic commands and EAV performance trap reference

Skill Detection

Before starting, scan your context for companion skill headers. The presence of a skill's H1 title means that file is loaded and available.

Look for in context If found If not found
# Skill: magento-infra Use its Redis env.php config, RabbitMQ consumer/publisher patterns, and OpenSearch setup diagnostics as the primary reference for Layers 3, 4, and 8 Use the embedded Redis, OpenSearch, and queue commands in Layers 3, 4, and 8 of this file
# Skill: magento-debug Use its symptom → cause → fix table, log file locations, and EAV performance trap reference as the primary diagnostic reference Use the embedded static asset and code pattern checks in Layer 7 of this file

Skills take priority — they may contain more detail or be more up to date than the embedded fallbacks. Only fall back to the embedded content when no skill is detected.


Agent Role

You are an autonomous Magento 2 performance auditor. You check every layer of the stack in order — from the fastest wins (cache, indexers) to the most complex (code patterns, database queries). You measure before recommending and quantify the impact of each finding.

You do not make assumptions — you run commands to check actual state before reporting.


Input

The agent accepts:

  • "Audit performance" (full audit)
  • A specific symptom ("product pages slow", "admin grid timeout", "imports taking 6 hours")
  • A catalog size hint ("50k products", "200k SKUs")
  • Environment info (cloud vs self-hosted, PHP version, MySQL version)

Audit Process

Run all layers in order. Each layer has a pass/fail threshold. Report all findings before making recommendations.


Layer 1 — Cache Status (Biggest Quick Win)

# Check which caches are enabled/disabled
bin/magento cache:status

# Check deploy mode (developer mode disables FPC)
bin/magento deploy:mode:show

# Check if full page cache is actually working
bin/magento config:show system/full_page_cache/caching_application
# 1 = Magento built-in, 2 = Varnish

# Check cache backend
cat app/etc/env.php | grep -A5 "'cache'"

Pass criteria:

  • All caches enabled ✓
  • Mode is production
  • FPC is enabled and using Redis or Varnish ✓

Common findings:

Finding Impact Fix
FPC disabled Every page request hits PHP bin/magento cache:enable full_page
Running in developer mode Caches disabled, slower rendering bin/magento deploy:mode:set production --skip-compilation
Using file cache instead of Redis Cache I/O bottleneck Configure Redis in env.php
block_html cache disabled Blocks re-rendered every request bin/magento cache:enable block_html

Layer 2 — Indexer Status

# Check all indexer states and modes
bin/magento indexer:status
bin/magento indexer:show-mode

# Check for invalidated indexers (common after imports)
bin/magento indexer:status | grep -i "invalid\|suspended"

Pass criteria:

  • All indexers: status valid, mode Update by Schedule (for 50k+ catalogs) ✓

Common findings:

Finding Impact Fix
Any indexer invalid Stale data, slower queries bin/magento indexer:reindex {indexer}
Indexers in realtime mode with 50k+ products Import/save triggers full reindex bin/magento indexer:set-mode schedule
catalogsearch_fulltext invalid Search broken bin/magento indexer:reindex catalogsearch_fulltext

Indexer reference:

Indexer Reindex Cost Priority
catalog_product_price High Always schedule
catalog_product_attribute High Always schedule
catalogsearch_fulltext High Always schedule
cataloginventory_stock Medium Schedule
catalog_category_product Medium Schedule
customer_grid Low Realtime OK

Layer 3 — Redis Health

# Memory usage
redis-cli info memory | grep -E "used_memory_human|maxmemory_human|mem_fragmentation_ratio"

# Eviction stats (non-zero = memory pressure)
redis-cli info stats | grep -E "evicted_keys|keyspace_hits|keyspace_misses"

# Calculate hit rate
redis-cli info stats | grep -E "keyspace_hits|keyspace_misses"
# Hit rate = hits / (hits + misses) — target > 90%

# Key counts per database
for db in 0 1 2; do echo "DB$db: $(redis-cli -n $db dbsize) keys"; done

# Check for memory fragmentation (ratio > 1.5 = concern)
redis-cli info memory | grep mem_fragmentation_ratio

# Check slow log
redis-cli slowlog get 10

Pass criteria:

  • used_memory < 80% of maxmemory
  • Hit rate > 90% ✓
  • evicted_keys = 0 ✓
  • mem_fragmentation_ratio < 1.5 ✓

Common findings:

Finding Impact Fix
used_memory > 80% of maxmemory Keys evicted, cache misses Increase maxmemory, or add Redis node
Hit rate < 80% Most requests miss cache, hit DB Check key prefix, verify cache is actually being written
evicted_keys growing Memory pressure causing cache evictions Increase memory or fix memory leak
mem_fragmentation_ratio > 2.0 Memory waste redis-cli memory doctor, consider restart
Sessions in same DB as cache Sessions evicted during memory pressure Separate into DB 2

Layer 4 — OpenSearch / Elasticsearch Health

# Cluster health (yellow = replicas unassigned, red = data loss)
curl -s opensearch:9200/_cluster/health | python3 -m json.tool

# Index sizes and document counts
curl -s "opensearch:9200/_cat/indices?v&s=store-size:desc"

# Slow log configuration
curl -s "opensearch:9200/magento2_product_1_v1/_settings" | python3 -m json.tool | grep slowlog

# JVM heap usage (> 85% = GC pressure)
curl -s "opensearch:9200/_nodes/stats/jvm" | python3 -m json.tool | grep heap_used_percent

Pass criteria:

  • Cluster status green
  • Heap usage < 75% ✓
  • No unassigned shards ✓

Common findings:

Finding Impact Fix
Cluster status red Data loss, search broken Check nodes, restore from snapshot
Cluster status yellow No replicas, single point of failure Add replica nodes
Heap > 85% GC pauses, slow searches Increase JVM heap (50% of RAM, max 31GB)
Single-node, no replicas No HA, slow reads Add replica nodes for production

Layer 5 — Database Health

# Check for slow queries (if slow log enabled)
mysql -e "SHOW VARIABLES LIKE 'slow_query_log%';"
mysql -e "SHOW VARIABLES LIKE 'long_query_time';"

# Check for large tables (potential issue sources)
mysql -e "
SELECT table_name,
       ROUND((data_length + index_length) / 1024 / 1024, 2) AS 'Size (MB)',
       table_rows
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY (data_length + index_length) DESC
LIMIT 20;"

# Check for lock waits
mysql -e "SHOW ENGINE INNODB STATUS\G" | grep -A10 "LATEST DETECTED DEADLOCK"

# Check index usage
mysql -e "
SELECT * FROM sys.schema_unused_indexes
WHERE object_schema = DATABASE();"

Pass criteria:

  • No slow queries > 2 seconds ✓
  • No deadlocks in recent log ✓
  • catalog_product_entity not excessively large relative to product count ✓

Common findings:

Finding Impact Fix
cron_schedule table > 100k rows Cron slowdown TRUNCATE cron_schedule; + fix cron cleanup config
url_rewrite table > 1M rows Slow routing Run URL reindex, check for duplicate generation
Deadlocks on catalog_product_entity Slow saves, failed imports Set indexers to schedule mode, batch imports
report_event / report_viewed_product_index bloated Slow reports Truncate or disable report modules

Layer 6 — PHP & OPcache

# OPcache status
php -r "print_r(opcache_get_status());" | grep -E "memory_usage|hit_rate|num_cached"

# OPcache config
php -i | grep -E "opcache.memory_consumption|opcache.max_accelerated_files|opcache.validate_timestamps"

# PHP memory limit (CLI vs FPM differ)
php -i | grep memory_limit
php-fpm -i 2>/dev/null | grep memory_limit || echo "Check php-fpm pool config"

# PHP version
php --version

Pass criteria:

  • OPcache hit rate > 90% ✓
  • OPcache memory not saturated (oom_restarts = 0) ✓
  • opcache.memory_consumption ≥ 256MB ✓
  • opcache.max_accelerated_files ≥ 130000 ✓
  • opcache.validate_timestamps=0 in production ✓

Common findings:

Finding Impact Fix
OPcache hit rate < 90% Every request recompiles PHP Increase opcache.memory_consumption
opcache.validate_timestamps=1 in production OPcache checks files on every request Set to 0 in production php.ini
opcache.max_accelerated_files too low Magento's 100k+ files exceed cache Set to 130000+
CLI memory_limit < 2G Import/reindex OOM Set in /etc/php/8.x/cli/php.ini

Layer 7 — Static Asset Delivery (CDN, Merge, Minify)

# Check if static content is deployed
ls -la pub/static/frontend/ 2>/dev/null | head -10

# Check JS/CSS merging and minification settings
bin/magento config:show dev/js/merge_files
bin/magento config:show dev/js/enable_js_bundling
bin/magento config:show dev/js/minify_files
bin/magento config:show dev/css/merge_css_files
bin/magento config:show dev/css/minify_files

# Check CDN / static base URL
bin/magento config:show web/unsecure/base_static_url
bin/magento config:show web/secure/base_static_url

# Check HTML minification
bin/magento config:show dev/template/minify_html

Pass criteria:

  • CSS and JS minification enabled ✓
  • CDN base URL configured (not same origin as store) ✓
  • Static content deployed in production mode ✓

Common findings:

Finding Impact Fix
No CDN configured All assets served from origin, adds latency Configure CDN and set base_static_url
JS/CSS not minified Larger payloads, slower page load Enable in Admin > Stores > Config > Advanced > Developer
Static content not deployed Assets missing or outdated after deploy bin/magento setup:static-content:deploy -f
JS bundling disabled (no HTTP/2) Many HTTP requests per page Enable bundling or migrate to HTTP/2 with CDN
pub/static served without CDN Origin handles all static load Configure CDN origin pull

Code pattern findings (large catalog):

Pattern Impact Fix
->save() inside foreach loop 100x slower than bulk Use connection->insertMultiple()
addAttributeToSelect('*') Loads all EAV attributes, slow queries Specify only needed attributes
Collection without setPageSize() OOM on large catalogs Paginate with setPageSize(100) + clear()
loadByAttribute() in loop N+1 DB queries Load collection once, index by attribute

Layer 8 — RabbitMQ Queue Depth (If Used)

# Check consumer list and queue depth
bin/magento queue:consumers:list

# RabbitMQ queue sizes (if RabbitMQ accessible)
rabbitmqctl list_queues name messages consumers 2>/dev/null

# Check for stuck async operations
bin/magento queue:consumers:start async.operations.all --max-messages=1 2>&1

Pass criteria:

  • Queue depth < 1000 messages ✓
  • All consumers running ✓
  • No dead-letter queue accumulation ✓

Scoring

After all layers, produce a performance score. The Score section is mandatory — always include it.

Layer Status Impact
1 — Full-Page Cache (Varnish/Fastly) ✅/⚠️/❌ Critical
2 — Indexer Strategy ✅/⚠️/❌ High
3 — Redis (cache + sessions) ✅/⚠️/❌ High
4 — Elasticsearch/OpenSearch ✅/⚠️/❌ Medium
5 — Database Query Performance ✅/⚠️/❌ High
6 — PHP/FPM & OPcache ✅/⚠️/❌ Medium
7 — Static Asset Delivery (CDN, merge, minify) ✅/⚠️/❌ Medium
8 — Queue / Message Consumers ✅/⚠️/❌ Medium

Instructions for LLM

  • Your response MUST start with ## Performance Audit Report — use this exact heading every time, even for partial audits or follow-up questions.
  • Do NOT auto-apply fixes. Your role is analysis and recommendation only. Provide commands the user should run, but never claim to have applied changes.
  • Always produce a complete scored assessment immediately. If you cannot execute commands, assess each layer based on the described symptoms, stated configuration, and typical patterns for the environment described. Score each layer PASS / FAIL / UNKNOWN based on available information. Do NOT return a methodology template telling the user to "run these commands and come back" — produce the full ## Performance Audit Report with a concrete score right now, even if some layers are marked UNKNOWN due to missing data.
  • Severity sections are mandatory: always include ### Critical Issues, ### High Priority, and ### Medium Priority sections in the report. If a category has no findings, write "None identified."
  • Do not use emoji symbols (✅/⚠️/❌) as the primary severity classification. Use the text labels Critical, High, and Medium in their respective section headings. Emoji may supplement but not replace the structured headings.
  • Score is mandatory: always include a ### Score: line (containing the word "Score") showing how many of the 8 layers passed. Before sending your response, verify the word "Score" appears in your output — if it does not, add the Score section before sending.
  • All 8 layers must be individually assessed: Full-Page Cache, Indexer Strategy, Redis, Elasticsearch/OpenSearch, Database, PHP/FPM & OPcache, Static Asset Delivery (CDN/merge/minify), Queue/Consumers. Do not skip any layer.

Output Format

Your first line of output MUST be ## Performance Audit Report.

## Performance Audit Report
**Store**: [URL]
**Date**: [timestamp]
**Catalog size**: [product count if known]

### Score: [X/8 layers passing]

---

### Critical Issues (Fix Immediately)
1. [Issue] — [Measured impact] — [Fix]

### High Priority
2. [Issue] — [Fix]

### Medium Priority
3. [Issue] — [Fix]

### Layer Detail

#### Layer 1 — Cache
Status: ❌ FAIL
Finding: FPC disabled, running in developer mode
Current: [output of cache:status]
Fix: [commands]
Expected gain: ~60% reduction in TTFB

#### Layer 2 — Indexers
Status: ✅ PASS
All indexers valid, all set to schedule mode.

[... continue for each layer ...]

---

### Estimated Impact After Fixes
- Page load time: [before] → [estimated after]
- Import time: [before] → [estimated after]
- Server load: [description]
Install via CLI
npx skills add https://github.com/furan917/magento-ai-toolkit --skill magento-agent-performance-auditor
Repository Details
star Stars 27
call_split Forks 2
navigation Branch main
article Path SKILL.md
More from Creator