Impact of MySQL multihost client connections(master-slave)
Background: When there is MySQL replication, with slaves replicating the master asynchronously, the application can be configured to connect to both master and slave. The MySQL Replication Driver can be used to load balance between different slaves, or choose slave over master for specific queries. The following spring datasource will do the work, To send queries to slaves, we need to set the JDBC Connection to readOnly. This can be achieved by setting the readyOnly attribute of @Transactional to be True. Actually, it depends on the configured TransactionManager, it works for DataSourceTransactionManager, but may not work for other transaction managers. If it's not working, you can get the current connection in the application code using DataSourceUtils.getConnection(DataSource) and set readOnly using Connection.setReadOnly(True). We used this way type of connections to scale out our reads and to increase the utilisation of rather idle slaves. Im...