MySQL database implements distributed master-slave architecture

Source: Internet
Author: User
Tags redis

Recently learned about the use of MySQL data implementation of the principle of the active structure, in the previous concurrent access to a low scene, generally a high performance of the server as a MySQL data, can meet the business of add and delete to change the scene, but with the increase of network users

In the case of high concurrency, high QPS, a MySQL is difficult to support this scenario, according to the current distributed processing architecture, processing in the use of Redis this efficient cache database, in fact, can also be targeted at the database side of the distributed processing, that is, the original

Same as Redis, using the distributed master-slave architecture, through master and Slave to achieve read and write analysis, data using the principle of master-slave replication, the use of read-write analysis, while reading the Slave machine can be configured in multiple configurations, greatly increased the stability and satisfaction of the background

High-concurrency scenarios;

The following principles are analyzed:

Brief procedure Description of the configuration:

MySQL configuration file "set in Spring"

Configuration of the data source:

Master data Source:

Slave data Source:

The source code can be implemented in a way that is based on custom annotations:

1, use a Select class, used to configure the selection method;

The configuration of the system requires a routing configuration:

Register the data source in spring "match the corresponding data source through the master and slave keywords":

Using annotations to achieve automatic matching via annotations on the Mapper interface, the effect is as follows:

Implementation of custom annotations: Using AspectJ's proxy mode AOP principle:

Match annotations to specific implementations:

Configure registration in Spring:

Configuration Complete!

MySQL database implements distributed master-slave architecture

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.