Example of using Thinkphp to implement MySQL read/write splitting

Source: Internet
Author: User
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.

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.