Best practice to configure the MySQL slave connection

For Adobe Commerce sites deployed on cloud infrastructure Pro architecture, Adobe recommends enabling the MYSQL slave connection for the database by default.

Adobe Commerce can read multiple databases asynchronously. When you enable the MYSQL slave connection, Adobe Commerce uses a read-only connection to the database to receive read-only traffic on a non-master node. This improves performance through load balancing, because only one node needs to handle read-write traffic.

Affected versions

Adobe Commerce on cloud infrastructure, Pro architecture

Configure MySQL slave connection

The configuration for the MYSQL slave connection is set by the MYSQL_SLAVE_CONNECTION deploy variable in the Adobe Commerce on cloud infrastructure environment configuration file, .magento.env.yaml. Set this variable to true to enable the connection.

To enable the MySQL slave connection:

  1. Edit your .magento.env.yaml file and verify that MYSQL_USE_SLAVE_CONNECTION is enabled.

    stage:
       deploy:
       MYSQL_USE_SLAVE_CONNECTION: true
    
  2. Commit any changes, and then push them to the environment branch to deploy the update.

    After the deployment completes successfully, the MySQL slave connection is enabled on your cloud infrastructure.

Additional information

![NOTE]

We are aware that this article may still contain industry-standard software terms that some may find racist, sexist, or oppressive and which may make the reader feel hurt, traumatized, or unwelcome. Adobe is working to remove these terms from our code, documentation, and user experiences.

On this page