Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MYSQL MONGODB REDIS synchronization principle and High availability comparison

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL

1. Asynchronous replication:

2. Semi-synchronous replication: when synchronization times out, it automatically changes back to asynchronous replication.

MongoDB

A replica set of MongoDB is a collection of mongod processes that provide redundancy and high availability. The smallest replica set contains (1 primary, 1 secondary, and 1 arbiter), and most deployments contain 3 nodes (1 primary, 2 secondary). A replica set can support up to 12 nodes, and a master-slave architecture is required for more than that.

Primary: receives all write operations from clients. There can be only one primary per replica set, and in order to support data replication, all operations of the primary to change the data are recorded in the oplog.

Secondary: maintain data consistency with primary (asynchronous with latency) by copying primary's oplog and replaying oplog. When the master is not available, the replica set selects one of the secondary as the primary. By default, all read operations will also point to primary, but you can configure read operations to point to secondary (data strict consistency cannot be guaranteed due to latency in copying data). You can configure priority to make null values become the priority of primary, priority=0 means that you cannot become primary, and you can also configure hidden replica members.

Arbiter:arbiter does not store data, it is only used to elect primary. When the cluster has an even number of nodes, add an artiber to get the secondary with the most votes as the primary. Arbiter does not require special hardware.

Replica Set Elcetions: during the election process, the replica set does not take over the write operation because there is no primary, and all members are read-only. If most of the members of the replica set are not available, the replica set will not select primary.

Heartbeats: replica set members send a heartbeats (pings) to other members every 2 seconds. If a heartbeat does not receive a response for 10 seconds, the sender of the heartbeat will mark the receiver of the heartbeat as unreachable.

Replica set features: asynchronous, automatic failover

You can set up a function similar to MySQL semi-synchronization, which can specify how many nodes will return after completing the write synchronization, and there is a timeout.

A typical replica set structure

Redis

Comparison between MySQL and MongoDB

There is semi-synchronous replication in MySQL and semi-synchronous replication in MongoDB.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report