Distributed models of NoSQL Databases
Distributed Model Single Server of NoSQL Database
Distributed architecture is easy to deploy and easy to maintain when a server is fully competent;
Shard features
Each part of the data is stored on different servers of the cluster;
For example, by letter: key values starting with a-g are stored on the first server, and keys starting with h-n are stored on the second server...
Issues to consider
How to store data allows users to retrieve data from a server
If you often need to interact with multiple nodes to obtain the required data, the partition policy may be inappropriate, or the split is not an ideal solution in this scenario;
Distribution of data nodes: Relationship between geographical locations and Access Users
Data nodes are distributed all over the world, allowing users in Beijing to access only Beijing nodes to obtain the required data;
Maintain Load Balancing
Advantages
Improves both read and write Performance
Because data is distributed to multiple nodes for storage, the pressure on data writing is also scattered;
Horizontally scalable write capability
Disadvantages
Reduces database error recovery capabilities
After partitioning, node faults in the cluster will cause some data loss;
Solution: each part of data is not only stored on one node, but also stored in redundancy to increase data security (it is a commonly used method by combining with master-slave replication)
Master-slave replication features
The master node stores authoritative data and is responsible for data update operations;
The master node copies the updated data to the slave node;
Advantages
Improves Data Reading Performance
The slave node is only responsible for querying, increasing the number of slave nodes to improve data reading performance
Enhanced fault recovery capabilities for read Operations"
The master node is damaged and can still process read requests;
After upgrading from a node to a master node, You can process the update request;
Single storage solution for instant backup
Even if distributed deployment is not required, master-slave replication can be used as a single-host server backup Deployment Solution;
Disadvantages
Data inconsistency (not updated in time)
After the master node is updated, the data synchronized to each slave node cannot be guaranteed in a timely manner, which may result in Inconsistent Data queried on each node (only with eventual consistency)
It is not helpful for improving the write operation performance
All update operations are processed by the master node. For services with frequent updates, the master-slave replication model has little advantage;
The master node is the bottleneck and weakness of the system.
Peer replication features
All nodes have the same status and can receive query and write requests;
Each node will copy its own updated data to another node;
Advantages
- Handle faulty nodes with ease without worrying about Data Request loss
- Add nodes to easily improve query and Write Performance
Disadvantages
- Data inconsistency
Conflicts may occur between the write and read operations;
Combined Use
The multipart and master-slave replication solutions are used in combination;
The role of sharding is data distributed storage; the role of master-slave replication is to provide backup for each shard node to increase data security;
Note: the deployment of the Sina Redis cluster uses this solution. For details about the use of Sina redis, see the blog before the big CC:
Application of Redis on Sina Weibo
Mind Map
Reference
NoSQL Essence
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.