PHPackages                             trunglv/magento2-concurrent\_indexer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. trunglv/magento2-concurrent\_indexer

ActiveMagento2-module

trunglv/magento2-concurrent\_indexer
====================================

Magento2 concurrent indexer with spatie/fork

09PHP

Since Aug 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/trunglv/magento2_concurrent_indexer)[ Packagist](https://packagist.org/packages/trunglv/magento2-concurrent_indexer)[ RSS](/packages/trunglv-magento2-concurrent-indexer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Magento Concurrent/Multithreading Indexer
=========================================

[](#magento-concurrentmultithreading-indexer)

Purposes:
---------

[](#purposes)

Magento 2 already supports multithreading for some indexer processes, but not all of them—specifically, the Product Flat Indexer. The purpose of this module is to:

#### 1. Enable the Product Flat Indexer to run concurrently.

[](#1-enable-the-product-flat-indexer-to-run-concurrently)

#### 2. Replace the default multithreading functionality in Magento Core with the spatie/fork module. Although I haven't benchmarked it yet, I have a feeling that spatie/fork is faster and seems to be more modern and professional in terms of coding.

[](#2-replace-the-default-multithreading-functionality-in-magento-core-with-the-spatiefork-module-although-i-havent-benchmarked-it-yet-i-have-a-feeling-that-spatiefork-is-faster-and-seems-to-be-more-modern-and-professional-in-terms-of-coding)

Installation
------------

[](#installation)

```
composer require trunglv/magento2-concurrent_indexer

```

Config
------

[](#config)

In etc/env.php, we should define MAGE\_INDEXER\_THREADS\_COUNT (Magento2 Core) and a new one, BETA\_CONCURRENT\_INDEXER\_THREADS\_ENABLE.

### !!!!If you want to use "spatie/fork" , you should enable BETA\_CONCURRENT\_INDEXER\_THREADS\_ENABLE

[](#if-you-want-to-use-spatiefork--you-should-enable-beta_concurrent_indexer_threads_enable)

```
...
'MAGE_INDEXER_THREADS_COUNT' => 3,
'BETA_CONCURRENT_INDEXER_THREADS_ENABLE' => 1

```

How is multithreading in the Indexer implemented by Magento 2 Core?
-------------------------------------------------------------------

[](#how-is-multithreading-in-the-indexer-implemented-by-magento-2-core)

##### CLASS \\Magento\\Catalog\\Model\\Indexer\\Category\\Product\\Action

[](#class-magentocatalogmodelindexercategoryproductaction)

```
/**
     * Run reindexation
     *
     * @return void
     */
    protected function reindex(): void
    {
        $userFunctions = [];

        foreach ($this->storeManager->getStores() as $store) {
            if ($this->getPathFromCategoryId($store->getRootCategoryId())) {
                $userFunctions[$store->getId()] = function () use ($store) {
                    $this->reindexStore($store);
                };
            }
        }

        $this->processManager->execute($userFunctions);
    }

```

##### CLASS \\Magento\\Indexer\\Model\\ProcessManager

[](#class-magentoindexermodelprocessmanager)

```
/**
     * Execute user functions
     *
     * @param \Traversable $userFunctions
     */
    public function execute($userFunctions)
    {
        if ($this->threadsCount > 1 && $this->isCanBeParalleled() && !$this->isSetupMode() && PHP_SAPI == 'cli') {
            $this->multiThreadsExecute($userFunctions);
        } else {
            $this->simpleThreadExecute($userFunctions);
        }
    }

```

How is multithreading in the Indexer implemented by my module?
--------------------------------------------------------------

[](#how-is-multithreading-in-the-indexer-implemented-by-my-module)

##### CLASS \\Betagento\\ConcurrentIndexer\\Plugin\\Indexer\\AroundProcessManager

[](#class-betagentoconcurrentindexerpluginindexeraroundprocessmanager)

```
if ($this->config->isEnabled() && $this->config->getThreadCount() > 1 && $this->config->isCanBeParalleled() && !$this->config->isSetupMode() && PHP_SAPI == 'cli') {

    \Spatie\Fork\Fork::new()->concurrent($this->config->getThreadCount())->run(...$userFunctions);
            return;
}

```

@trunglv Skype :  - email :

```
vendor/bin/phpstan analyse app/code/Betagento/ConcurrentIndexer/ --level 9
 5/5 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors

```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/15e9d0c7c6322100e7f10b8efb4ed2a28193b52d7ba32d96033635838c7c09f0?d=identicon)[trunglv](/maintainers/trunglv)

---

Top Contributors

[![trunglv](https://avatars.githubusercontent.com/u/820411?v=4)](https://github.com/trunglv "trunglv (26 commits)")

### Embed Badge

![Health badge](/badges/trunglv-magento2-concurrent-indexer/health.svg)

```
[![Health](https://phpackages.com/badges/trunglv-magento2-concurrent-indexer/health.svg)](https://phpackages.com/packages/trunglv-magento2-concurrent-indexer)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
