The Thinkphp framework supports MySQL read/write splitting.

Source: Internet
Author: User

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:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.