Magento 2 CE Split Database to Master and Slave
- Compatible with Magento Open Source
2.3.x
&2.4.x
This module provides the ability to route query from Frontend to specific MySql instance (write to master and select to slave). The module currently provides the following advantage:
- Increasing performance of Frontend Store
- Prevent MySql server from deadlock (SQLSTATE[40001]: Serialization failure: 1213 Deadlock)
You need to change your enviroment config file - env.php
.
- To quick disable split database and route all query to master:
bin/magento db:mode:set default
- To quick enable split database and route all query to master:
bin/magento db:mode:set split
If you not config, default connection will be used.
- Magento Open Source version
2.3.x
or2.4.x
Please install this module via Composer. This module is hosted on Packagist.
composer config repositories.nosense '{"type": "composer","url": "https://repo.nosense.lol"}'
composer require cdfrm/magento2-splitdb
bin/magento module:enable CodeFarm_SplitDb
bin/magento setup:upgrade
You can add log to check at: \CodeFarm\SplitDb\Adapter\Pdo\Mysql::query
use for all frontend and admin. All query after Write Query will be route to Write instance. (This will prevent latancy of Master-Slave architechture (Some performance traded here :D))