惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
PCI Perspectives
PCI Perspectives
H
Help Net Security
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
S
Secure Thoughts
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
大猫的无限游戏
大猫的无限游戏
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Tor Project blog
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
博客园 - 【当耐特】
G
Google Developers Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
I
Intezer
S
Schneier on Security
S
Securelist
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
Project Zero
Project Zero
Google Online Security Blog
Google Online Security Blog
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
Last Week in AI
Last Week in AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
A
Arctic Wolf
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Magento 2 MSI Performance Optimization: Taming Multi-Source Inventory
Magevanta · 2026-05-16 · via DEV Community

Multi-Source Inventory (MSI) arrived in Magento 2.3 as a major architectural overhaul of stock management. For merchants running multiple warehouses, it's genuinely powerful. For the other 80% — single-warehouse stores that just want fast page loads and quick checkout — it's often an unexpected performance drag that's hard to diagnose and even harder to fix.

This guide walks through exactly what MSI does under the hood, where the bottlenecks hide, and what you can do about them today.

What MSI Actually Does (and Why It's Slow)

Before MSI, Magento's inventory system was a flat, denormalized structure. Stock was stored in cataloginventory_stock_item, and a simple JOIN during product listing was all that was needed to determine salability.

MSI replaced this with a normalized, extensible model:

  • inventory_source — physical locations
  • inventory_source_item — stock per SKU per source
  • inventory_stock — named stock pools
  • inventory_stock_sales_channel — maps stocks to websites/stores
  • inventory_reservation — deferred (eventual consistency) deductions during checkout

The genius of this design is its flexibility. The performance cost is that every salability check now requires resolving a chain of tables — source → stock → reservation — often via PHP-layer aggregation, not a single SQL query.

The IsSalableConditionInterface plugin chain and the GetProductSalableQty service are called on virtually every product load in catalog listing, cart, checkout, and order placement. In a store with thousands of SKUs and a busy queue, this adds up fast.

Diagnosing MSI Overhead

Before optimizing blindly, measure. These are the usual suspects:

1. Slow Category Pages

Enable the Magento profiler (MAGE_PROFILER=html php bin/magento ...) or use New Relic / Blackfire and look for repeated calls to:

Magento\InventorySalesAdminUi\Model\...
Magento\InventoryCatalog\Plugin\...
Magento\InventoryIndexer\...

Enter fullscreen mode Exit fullscreen mode

If you see these appearing hundreds of times per page request, MSI is your bottleneck.

2. Slow Checkout / Add-to-Cart

The reservation mechanism writes to inventory_reservation on every cart add and order placement. On high-traffic stores, this table grows rapidly and the compensating cron (inventory_cleanup_reservations) may lag behind.

Check table size:

SELECT COUNT(*) FROM inventory_reservation;
SELECT COUNT(*) FROM inventory_stock_1; -- adjust stock ID

Enter fullscreen mode Exit fullscreen mode

Tables with millions of rows indicate the cleanup cron is not keeping up.

3. Reindex Times

MSI adds several new indexers:

bin/magento indexer:status | grep inventory

Enter fullscreen mode Exit fullscreen mode

inventory_stock reindex can be very slow on large catalogs — especially if it runs in "Update on Save" mode during peak hours.

Optimization Strategy 1: Switch to Single-Source Mode Correctly

If you're a single-warehouse merchant, MSI is solving problems you don't have. However, you cannot simply disable the MSI modules — they are deeply integrated into Magento's sales flow since 2.3.

What you can do is configure MSI to behave like the old single-stock system:

  1. Use the Default Source and Default Stock only. Never create additional sources or stocks.
  2. Set all products to the Default Source. If you imported products incorrectly, run:
bin/magento inventory:source-items:export-stock-to-default-source

Enter fullscreen mode Exit fullscreen mode

  1. Unassign unused sources. In Admin → Stores → Sources, disable all non-default sources so Magento skips multi-source resolution logic.

  2. Ensure inventory_stock_sales_channel maps only the Default Stock to your website. Mismatches here cause fallback resolution paths that are significantly slower.

With a clean single-source setup, MSI's internal resolvers hit fast code paths that are barely slower than the old system.

Optimization Strategy 2: Indexer Tuning

Switch to "Update by Schedule"

Real-time (Update on Save) inventory reindex is a common culprit for frontend slowdowns during product edits or imports.

bin/magento indexer:set-mode schedule inventory_stock

Enter fullscreen mode Exit fullscreen mode

This moves reindexing to cron, keeping the frontend responsive.

Run Inventory Indexers on Cron Properly

Magento's default cron group for MSI indexers is index. Verify it's running:

bin/magento cron:status

Enter fullscreen mode Exit fullscreen mode

For high-volume stores, consider running the inventory indexers on a dedicated cron group with a tighter schedule during off-peak hours.

Partial Reindex After Imports

When you import products in bulk, avoid a full inventory_stock reindex if possible. Use Magento's partial reindex:

bin/magento indexer:reindex inventory_stock

Enter fullscreen mode Exit fullscreen mode

For very large catalogs, use --no-interaction with a time limit and offset if you've implemented chunked reindex via a custom CLI command.

Optimization Strategy 3: Reservation Table Maintenance

The inventory_reservation table uses an append-only model. Magento only cleans it via compensating cron jobs (inventory.reservations.cleanup and inventory.reservations.updateSalabilityStatus).

If these lag, the table balloons and reservation resolution becomes slow.

Check and Force Cleanup

bin/magento inventory:reservations:cleanup

Enter fullscreen mode Exit fullscreen mode

For stores processing thousands of orders per day, schedule this to run every 15 minutes instead of the default hourly.

In crontab.xml of a custom module:

<job name="inventory_cleanup_reservations_frequent" instance="Magento\InventoryIndexer\Cron\ReindexAfterReservationsPlaced" method="execute">
    <schedule>*/15 * * * *</schedule>
</job>

Enter fullscreen mode Exit fullscreen mode

Also run the compensating reservation update more frequently if you see salability showing stale (e.g., item still shows in stock 10 minutes after the last unit sold):

bin/magento inventory:salability:reindex

Enter fullscreen mode Exit fullscreen mode

Archive Old Reservations

For stores that have been running MSI for years without cleanup, a one-time purge of fully compensated reservations is safe:

-- Safe: removes reservations where the net quantity per SKU/stock is zero
-- Run this only after verifying with a SELECT first
DELETE r1 FROM inventory_reservation r1
INNER JOIN (
    SELECT sku, stock_id
    FROM inventory_reservation
    GROUP BY sku, stock_id
    HAVING SUM(quantity) = 0
) r2 ON r1.sku = r2.sku AND r1.stock_id = r2.stock_id;

Enter fullscreen mode Exit fullscreen mode

⚠️ Always run on a staging environment first and take a backup. This is a data mutation.

Optimization Strategy 4: Salability Check Caching

MSI's GetProductSalableQty and IsSalable services are called per-product. On a category page with 48 products, that's 48 individual salability resolutions — each potentially involving multiple DB queries.

Magento 2.4.4+ introduced a built-in result cache for salability checks. Ensure it's enabled by checking your DI configuration:

grep -r "IsSalableConditionInterface" vendor/magento/module-inventory-sales/etc/

Enter fullscreen mode Exit fullscreen mode

If you're on an older version, you can implement a simple proxy cache using Magento's cache framework:

// In a plugin for GetProductSalableQtyInterface
public function aroundExecute(
    GetProductSalableQtyInterface $subject,
    callable $proceed,
    string $sku,
    int $stockId
): float {
    $cacheKey = 'msi_salable_qty_' . $sku . '_' . $stockId;
    if ($cached = $this->cache->load($cacheKey)) {
        return (float) $cached;
    }
    $result = $proceed($sku, $stockId);
    $this->cache->save((string) $result, $cacheKey, [], 30); // 30s TTL
    return $result;
}

Enter fullscreen mode Exit fullscreen mode

Use with care on high-velocity SKUs — a 30-second stale quantity is usually acceptable for catalog display but not for final checkout reservation.

Optimization Strategy 5: Disable MSI for Non-Salable Product Types

Configurable products trigger MSI salability checks for every child product to determine if the parent is in stock. For configurables with dozens of variants, this cascades badly.

Magento provides the InventoryConfigurableProduct module specifically to aggregate child stock for configurable parents. Ensure this module is enabled:

bin/magento module:status Magento_InventoryConfigurableProduct

Enter fullscreen mode Exit fullscreen mode

If it's disabled (sometimes happens after partial module disablement attempts), re-enable it:

bin/magento module:enable Magento_InventoryConfigurableProduct
bin/magento setup:upgrade

Enter fullscreen mode Exit fullscreen mode

Monitoring MSI in Production

Set up these dashboards to catch MSI degradation before users notice:

New Relic / Datadog custom metrics:

  • inventory_reservation row count (alert > 500k)
  • Time spent in Magento\InventorySales\Model\IsProductSalableForRequestedQtyCondition
  • Cron job duration for inventory_cleanup_reservations

MySQL slow query log: Filter for queries against inventory_reservation, inventory_source_item, and inventory_stock_* that exceed 100ms.

Magento logs: Watch var/log/system.log for Could not resolve salability or reservation consistency warnings.

When Nothing Else Works: Third-Party MSI Alternatives

For stores with extreme inventory complexity (tens of thousands of SKUs, multiple warehouses, real-time 3PL sync), native MSI may genuinely not scale to your needs. Some merchants have had success with:

  • Linnworks or SkuVault with a Magento connector that bypasses MSI entirely and writes directly to the legacy cataloginventory_stock_item table
  • Custom Magento_InventoryCatalog preference that replaces the salability check with a direct single-table lookup for single-source setups

The latter approach (essentially shunting around MSI's resolution chain while keeping the module structure intact for compatibility) is the most maintainable path if you need single-source speed with MSI's API compatibility.

Summary

MSI is not inherently slow — it's complex, and complexity has a cost. The optimization playbook:

Problem Fix
Slow category pages Single-source cleanup + salability caching
Slow checkout / cart Reservation table maintenance + frequent cleanup cron
Slow reindex Switch to schedule mode + partial reindex on imports
Stale stock display Run inventory:salability:reindex more frequently
General MSI overhead Ensure InventoryConfigurableProduct is enabled

Start with the reservation table — it's the most common and most impactful quick win. Then profile to find your specific bottleneck before diving into deeper changes.

Got a specific MSI issue that isn't covered here? Drop a comment or reach out — real-world MSI war stories are always educational.