Magento 2 Multi Source Inventory performance

Multi Source Inventory a new Magento store feature with the bad performance

Inventory Management modules provide all inventory features and options for Single and Multi Source merchants to manage product quantities and stock for sales channels. These features are available in 2.3.x Magento Open Source, Magento Commerce, and Magento Commerce Cloud.

Multi Source merchants have one website or a multisite implementation and manage on-hand inventory and fulfilling orders through multiple locations. This is called multi-sourcing.

For example, you have a multisite implementation with websites for United States, Germany, France, and Brazil. Your business includes a number of warehouses and stores in these countries and drop shipper services that manage all inventory stock and fulfill orders. These locations and websites become sources and stocks in Magento. You may create a stock for the Americas and another for Europe, assigning websites and sources based on locales and locations. Customers shopping each website only have access to salable inventories from the assigned sources.

Good advertisement but bad performance a lot of merchants struggling with these features even if they don’t have multi-source inventory. Basically Magento team forgot to add Indexers to the table. They are using View it doesn’t have indexes.

Basically, in general, it is a bad idea to manage inventory in Magento. If you really need it better to write microservice to manage stocks without using Magento's slow PHP Monolithic backend.

Article with a detailed Magento performance issue description and troubleshooting:

merchant has 80K SKUs….

Even This Small Query without JOINS:

SELECT inventory_stock_1.quantity, inventory_stock_1.is_salable FROM inventory_stock_1 WHERE (sku = ‘007’)

takes 0.6490 seconds. Because it doesn’t have an index on the SKU column…

For the test, we have used Magento 2 Sass Platform — Magneto with default Luma theme and sample data (3000 SKUs) and Apache Benchmark performance tooling.

The ApacheBench tool (ab) can load test servers by sending an arbitrary number of concurrent requests. Although ab was designed for testing Apache installations, it can be used to benchmark any Magento server.

Magento 2.3.5 Performance with MSI enabled

Image for post
Image for post

Result: 1239ms

Magento 2.3.5 Performance after MSI disabled

Image for post
Image for post

Result: 786ms

Magento Performance Charts

Image for post
Image for post
Magento 2 performance with MSI and without
Image for post
Image for post
Magento 2 TTFB performance

Disabling redundant MSI

The following line in the composer.json meta-package installs Inventory Management:

magento/inventory-composer-metapackage = 1.1.3

The Inventory Management installation process adds all modules to the <Magento_installation_directory>/app/etc/config.php file. A “1” value indicates the corresponding module is enabled. The following list of modules are added:

'Magento_Inventory' => 1,
'Magento_InventoryAdminUi' => 1,
'Magento_InventoryAdvancedCheckout' => 1,
'Magento_InventoryApi' => 1,
'Magento_InventoryBundleProduct' => 1,
'Magento_InventoryBundleProductAdminUi' => 1,
'Magento_InventoryCatalog' => 1,
'Magento_InventorySales' => 1,
'Magento_InventoryCatalogAdminUi' => 1,
'Magento_InventoryCatalogApi' => 1,
'Magento_InventoryCatalogSearch' => 1,
'Magento_InventoryConfigurableProduct' => 1,
'Magento_InventoryConfigurableProductAdminUi' => 1,
'Magento_InventoryConfigurableProductIndexer' => 1,
'Magento_InventoryConfiguration' => 1,
'Magento_InventoryConfigurationApi' => 1,
'Magento_InventoryDistanceBasedSourceSelection' => 1,
'Magento_InventoryDistanceBasedSourceSelectionAdminUi' => 1,
'Magento_InventoryDistanceBasedSourceSelectionApi' => 1,
'Magento_InventoryElasticsearch' => 1,
'Magento_InventoryExportStockApi' => 1,
'Magento_InventoryIndexer' => 1,
'Magento_InventorySalesApi' => 1,
'Magento_InventoryGroupedProduct' => 1,
'Magento_InventoryGroupedProductAdminUi' => 1,
'Magento_InventoryGroupedProductIndexer' => 1,
'Magento_InventoryImportExport' => 1,
'Magento_InventoryCache' => 1,
'Magento_InventoryLowQuantityNotification' => 1,
'Magento_InventoryLowQuantityNotificationApi' => 1,
'Magento_InventoryMultiDimensionalIndexerApi' => 1,
'Magento_InventoryProductAlert' => 1,
'Magento_InventoryRequisitionList' => 1,
'Magento_InventoryReservations' => 1,
'Magento_InventoryReservationCli' => 1,
'Magento_InventoryReservationsApi' => 1,
'Magento_InventoryExportStock' => 1,
'Magento_InventorySalesAdminUi' => 1,
'Magento_InventorySalesFrontendUi' => 1,
'Magento_InventorySetupFixtureGenerator' => 1,
'Magento_InventoryShipping' => 1,
'Magento_InventorySourceDeductionApi' => 1,
'Magento_InventorySourceSelection' => 1,
'Magento_InventorySourceSelectionApi' => 1,
'Magento_InventoryLowQuantityNotificationAdminUi' => 1,
'Magento_InventoryShippingAdminUi' => 1,
'Magento_InventoryGraphQl' => 1,

This command will list and disable all the MSI modules.

php bin/magento module:status | grep Magento_Inventory | grep -v List | grep -v None | grep -v -e '^$' | xargs php bin/magento module:disable
php bin/magento s:upgrade --keep-generated
php bin/magento i:reindex

And now you are having better performance. 780ms page rendering is still slow, however, not 6000ms as Helly Hansen Magento implementation has ;)

Written by

Magento/APP Cloud Architect. Melting metal server infrastructure into cloud solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store