Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

Set MAGE_INDEXER_THREADS_COUNT in Adobe Commerce Cloud

If you’re running an Adobe Commerce Cloud (formerly known as Magento) store, you know how important it is to keep your store running smoothly.

Set MAGE_INDEXER_THREADS_COUNT in Adobe Commerce Cloud
Written by
JKJigar Karangiya
Published
Reading time
3 min read

Jigar Karangiya · · 3 min read

If you’re running an Adobe Commerce Cloud (formerly known as Magento) store, you know how important it is to keep your store running smoothly. One of the key processes that keeps your store up-to-date is indexing. Indexing ensures that your product data, prices, and other information are current and accurate. However, as your store grows, indexing can become slower, especially if you have a large catalog or frequent updates.

The good news is that Adobe Commerce Cloud provides a way to speed up indexing (opens in new tab) by using a feature called MAGE_INDEXER_THREADS_COUNT. In this blog, we’ll explain what this feature is, why it’s useful, and how you can set it up in your Adobe Commerce Cloud environment.

In adobe commerce, you can either add an environment variable to the env.php file or use the environment variable MAGE_INDEXER_THREADS_COUNT when running the reindex command in parallel mode. The number of threads used for the reindex procedure is determined by this variable.

What is MAGE_INDEXER_THREADS_COUNT?

MAGE_INDEXER_THREADS_COUNT is an environment variable that allows you to control how many threads (or processes) are used during indexing. By default, Adobe Commerce runs indexing tasks one at a time, which can be slow for large stores. By increasing the thread count, you can split the indexing workload across multiple threads, making the process faster and more efficient.

For example, if you set MAGE_INDEXER_THREADS_COUNT to 4, Adobe Commerce will use 4 threads to process indexing tasks simultaneously. This can significantly reduce the time it takes to complete indexing.

Why Should You Use MAGE_INDEXER_THREADS_COUNT?

Here are some benefits of using this feature:

  • Better Resource Utilization : If your server has multiple CPU cores, increasing the thread count allows you to take full advantage of your hardware.
  • Faster Indexing : By using multiple threads, indexing tasks are completed much quicker, especially for large catalogs.
  • Improved Store Performance : Faster indexing means your store’s data is updated sooner, ensuring customers see the most accurate information.

How to Set MAGE_INDEXER_THREADS_COUNT in Adobe Commerce Cloud

1. Edit the .magento.env.yaml File

Locate the .magento.env.yaml file in your project’s root directory (or create it if it doesn’t exist).

Add the MAGE_INDEXER_THREADS_COUNT variable under the env section in the stage > deploy phase.

yaml
stage:
  deploy:
    env:
      variables:
        MAGE_INDEXER_THREADS_COUNT: 4

Replace 4 with your desired thread count (e.g., based on your Cloud infrastructure’s CPU cores).

2. Commit and Push Changes

  • Commit the updated .magento.env.yaml file to your Git repository.
  • Push the changes to trigger a redeployment of your Adobe Commerce Cloud environment.

Example.magento.env.yaml

yaml
stage:
  deploy:
    env:
      variables:
        MAGE_INDEXER_THREADS_COUNT: 4
        # Other variables (optional)
        CRON_CONSUMERS_RUNNER: true
        CONFIG__DEFAULT__WEB__SECURE__USE_IN_FRONTEND: 1

3. Validate after deployment using ece-tools

RunTerminal
php ./vendor/bin/ece-tools cloud:config:validate

Bonus Trick

You can run command manually via below parameter

ini
MAGE_INDEXER_THREADS_COUNT=3 php -f bin/magento indexer:reindex catalogsearch_fulltext

Best Practices for Using MAGE_INDEXER_THREADS_COUNT

  1. Match Thread Count to CPU Cores : Set the thread count to match the number of CPU cores available on your server. For example, if your server has 4 CPU cores, set MAGE_INDEXER_THREADS_COUNT to 4.
  2. Monitor Performance : After increasing the thread count, monitor your server’s performance to ensure it’s not overloading the CPU or memory.
  3. Test in Staging First : If you’re unsure about the optimal thread count, test different values in your staging environment before applying them to production.

Example Use Case

Imagine you run an online store with 50,000 products. Every time you update prices or inventory, the indexing process takes over an hour to complete. By setting MAGE_INDEXER_THREADS_COUNT to 4, you can reduce the indexing time to just 15-20 minutes, ensuring your store’s data is updated quickly and efficiently.

Conclusion

Using MAGE_INDEXER_THREADS_COUNT is a simple yet powerful way to speed up indexing in Adobe Commerce Cloud. By optimizing the number of threads used during indexing, you can improve your store’s performance and provide a better experience for your customers.

If you haven’t already, try adding this setting to your .magento.env.yaml file and see the difference it makes. And remember, always test changes in a staging environment before applying them to your live store.

Happy indexing! 🚀


You may also like,

Adobe Commerce Security: CSP, Escaping, Form Keys, Sanitization, reCAPTCHA, Input Validation

How to Create New Commands in Magento 2 CLI

Fastly : How to set basic authentication for a specific page in Magento 2

Keep reading
All posts

01 · 5 min · Shares Adobe Commerce on Cloud, DevOps

Fastly VCL for Adobe Commerce

If you run Adobe Commerce on Cloud, Fastly is already in the path for staging and production. Most of the time you touch cache settings in Admin and never look at VCL.

5 min

02 · 11 min · Shares Adobe Commerce on Cloud, DevOps

Syncing Adobe Commerce catalog to Optimizer with the ACO Connector

If you already read my Adobe Commerce Optimizer overview, you know the pitch: keep Adobe Commerce as your system of record for cart, checkout, and orders, and let Commerce Optimizer handle discovery, search, recommendations, and the headless storefront layer.

11 min

03 · 14 min · Shares Adobe Commerce on Cloud, DevOps

Adobe Commerce Cloud performance optimization for Real

Most Magento 2 performance posts read the same. Enable cache, install Redis, run reindex, the end. Real stores on Adobe Commerce on cloud infrastructure break in messier ways.

14 min

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe