PHP 7.3 reaches end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in April 2022. We strongly recommend planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.

Magento_ResourceConnections

Magento\ResourceConnections module adds a mechanism to segregate database connections between master and slave database servers based on the request type.

For each master database connection (except the indexer connection) that are configured in db/connection section of app/etc/env.php you can add one slave connection that can be configured in db/slave_connection. Configuration format is the same as db/connection. Slave connection name must be the same as associated master connection name. To enable slave connections for specific resources create a slave connection configuration by adding slave_connection node as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
return array (
    //...
    'db' =>
        array (
            'connection' =>
                array (
                    'default' =>
                        array (
                            'host' => 'default-master-host',
                            'dbname' => 'magento',
                            'username' => 'magento',
                            'password' => 'magento',
                            'active' => '1',
                        ),
                ),
            'slave_connection' =>
                array (
                    'default' =>
                        array (
                            'host' => 'default-slave-host',
                            'dbname' => 'magento',
                            'username' => 'read_only',
                            'password' => 'password',
                            'active' => '1',
                ),
        ),
        'table_prefix' => '',
    ),
    //.......

To add slave connection for resources other than ‘default’ repeat the step and add to db/slave_connection new element with same name and slave configuration for specified resource. Config structure retains backward compatibility if module is turned off.

WARNING: ‘indexer’ connection is not designed to have slave configuration.