PHPackages                             furan/magento-read-write-split - 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. [Database &amp; ORM](/categories/database)
4. /
5. furan/magento-read-write-split

ActiveMagento2-module[Database &amp; ORM](/categories/database)

furan/magento-read-write-split
==============================

Magento 2 module to split read &amp; write operations

v1.0.0(6mo ago)912MITPHPPHP ^8.0

Since Oct 30Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/furan917/Magento2-ReadWriteSplit)[ Packagist](https://packagist.org/packages/furan/magento-read-write-split)[ RSS](/packages/furan-magento-read-write-split/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Magento 2 Read/Write Database Split Module
==========================================

[](#magento-2-readwrite-database-split-module)

A Magento 2 module that implements automatic read/write database splitting. Read queries are distributed across multiple read replicas using round-robin selection, while write operations always go to the master database. CLI operations (indexing, cron, console commands) always use the master to avoid temporary table conflicts. We ensure a 'writer first' approach and include a writer fallback for defensive posturing. It is built to support multiple readers, but 1 will work just as well.

Configuration
-------------

[](#configuration)

Add reader connection configurations to `app/etc/env.php`:

```
'db' => [
    'connection' => [
        'default' => [
            'host' => 'master-db-host',
            'dbname' => 'magento',
            'username' => 'dbuser',
            'password' => 'dbpass',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'initStatements' => 'SET NAMES utf8;',
            'active' => '1',
            'driver_options' => [
                1014 => false
            ]
        ],
        'indexer' => [
            'host' => 'master-db-host',
            'dbname' => 'magento',
            'username' => 'dbuser',
            'password' => 'dbpass',
            'model' => 'mysql4',
            'engine' => 'innodb',
            'initStatements' => 'SET NAMES utf8;',
            'active' => '1'
        ]
    ],
    'reader_connections' => [
        'default' => [
            // Note this is an array, even if only using 1 you must keep this structure
            [
                'host' => 'reader-1-host',
                'dbname' => 'magento',
                'username' => 'dbuser',
                'password' => 'dbpass',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ],
            [
                'host' => 'reader-2-host',
                'dbname' => 'magento',
                'username' => 'dbuser',
                'password' => 'dbpass',
                'model' => 'mysql4',
                'engine' => 'innodb',
                'initStatements' => 'SET NAMES utf8;',
                'active' => '1',
                'driver_options' => [
                    1014 => false
                ]
            ]
        ]
    ]
],
```

How It Works
------------

[](#how-it-works)

- SELECT, SHOW, DESCRIBE, EXPLAIN queries are routed to reader connections
- INSERT, UPDATE, DELETE, DDL, and transaction queries go to master
- Queries within transactions always use master for consistency
- CLI operations (bin/magento commands) always use master
- Failed reader connections automatically fall back to master
- Round-robin load balancing across active readers

Disabling Readers
-----------------

[](#disabling-readers)

Set `'active' => '0'` for any reader connection to temporarily disable it without removing the configuration.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Magento 2.4+
- MySQL master-slave replication configured
- Read replicas must be in sync with master

Notes
-----

[](#notes)

The indexer connection is never split and always uses the master database to avoid issues with temporary tables during reindexing operations.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance66

Regular maintenance activity

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2bc9c9b137efd6484a9d949c5263a830d19741d00f334aab3e858c7cf6f1cc8?d=identicon)[furan917](/maintainers/furan917)

---

Top Contributors

[![furan917](https://avatars.githubusercontent.com/u/15950274?v=4)](https://github.com/furan917 "furan917 (6 commits)")

---

Tags

databaseperformancesplitmagento2read-writereplica

### Embed Badge

![Health badge](/badges/furan-magento-read-write-split/health.svg)

```
[![Health](https://phpackages.com/badges/furan-magento-read-write-split/health.svg)](https://phpackages.com/packages/furan-magento-read-write-split)
```

###  Alternatives

[bvanhoekelen/performance

PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.

521774.3k4](/packages/bvanhoekelen-performance)[sarfraznawaz2005/meter

laravel package to find performance bottlenecks in your laravel application.

2498.1k](/packages/sarfraznawaz2005-meter)[satur.io/duckdb

DuckDB API for PHP

7856.3k5](/packages/saturio-duckdb)[msafadi/laravel-eloquent-join-with

Laravel Eloquent Join With Relationships

1646.0k](/packages/msafadi-laravel-eloquent-join-with)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[olliejones/index-wp-mysql-for-speed

Speed up your WordPress site by adding high-performance keys (database indexes) to your MySQL database tables.

1481.8k](/packages/olliejones-index-wp-mysql-for-speed)

PHPackages © 2026

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