This article describes how to implement MySQL read/write splitting using Thinkphp. For more information, see
This article describes how to implement MySQL read/write splitting using Thinkphp. For more information, see
Compared with other methods to implement MySQL read/write splitting, using Thinkphp framework to implement MySQL read/write splitting is easy to use. The configuration file sample code is as follows:
'Db _ type' => 'mysql', 'db _ DEPLOY_TYPE '=> 1, // enable multi-server 'db _ RW_SEPARATE' => true, // whether the database reads/writes are separated by '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.