The Thinkphp framework supports MySQL read/write splitting.
In the past, I tried to use Mysql Proxy and Ameba to solve the read/write splitting of MySQL, but the results are not very satisfactory. Now many websites and projects have been migrated to the Thinkphp framework, I feel that its MySQL read/write splitting function is well supported. The main code is as follows:
'Db _ type' => 'mysql ',
'Db _ DEPLOY_TYPE '=> 1, // supports multiple servers
'Db _ RW_SEPARATE '=> true, // database read/write splitting
'Db _ host' => '2017. 168.11.101, 192.168.11.102 ',
'Db _ name' => 'test ',
'Db _ user' => 'admin ',
'Db _ pwd' => 'admin101 ',
'Db _ prefix' => 'fav _',
Note:
1. execute and query are used for read operations when the original SQL statement is used for write operations.
2. MySQL DATA master-slave synchronization depends on the MySQL mechanism. Therefore, the latency of MySQL master-slave synchronization needs to be optimized at this time. A long delay not only affects the business, it also affects user experience.
MySQL5.6 master-slave Replication (read/write splitting) configuration full version
Build a MySQL proxy server for read/write splitting + Master/Slave Synchronization
MySQL-5.6 + MySQL-Proxy build master-slave replication and read/write Separation
MySQL database read/write splitting
This article permanently updates the link address: