NoSQL

1. A single server

When a server is fully capable of work, there is no need to consider distribution, so deployment is simple and maintenance is much more convenient;

2. Fragmentation

2.1. Features

Each part of the data is stored in different servers of the cluster; for 
example, it is divided by letters: the key values ​​starting with ag are stored on the first server, and those starting with hn are stored on the second server...

2.2. Issues that need to be considered

  1. How to store data so that users basically only need to get data from one server. 
    If you often need to interact with multiple nodes to get the required data, the sharding strategy may not be suitable, or the sharding is not an ideal solution in this scenario ;

  2. Distribution of data nodes: The relationship between geographical location and visiting users 
    Data nodes are distributed all over the world, so that users in Beijing only need to visit the nodes in Beijing to get the required data;

  3. maintain load balance

2.3. Advantages

  1. Improve read and write performance at the same time. 
    Since sharding distributes data to multiple nodes for storage, the pressure is also dispersed when writing;

  2. Scale-out write capability

2.4. Disadvantages

  1. Reduce the error resilience of the database 
  2. After sharding, the failure of nodes in the cluster will cause some data loss; 
  3. Solution: Each shard data is not only stored on one node, but redundantly stored to increase data security (through the combination of master-slave replication mentioned later, it is a common method)

3. Master-slave replication

3.1. Features

The master node stores authoritative data and is responsible for data update operations; 
the master node copies the updated data to the slave nodes;

3.2, advantages

  1. Helps to improve data read performance. 
    The slave node is only responsible for querying, and adding slave nodes improves data read performance.

  2. Enhance the "failure recovery capability of read operations" 
    The master node is damaged, but it can still process read requests; 
    after the slave node is upgraded to the master node, it can process update requests;

  3. The "one-to-one" instant backup single-storage solution 
    does not require distributed deployment, and master-slave replication can also be used as a single-server backup deployment solution;

3.3. Disadvantages

  1. 数据的不一致性(未及时更新) 
    主节点更新后,同步到各个从结点的数据不能保证及时,可能导致各个结点上查询的数据不一致(只具有最终一致性)

  2. 对提升写入操作性能帮助不大 
    所有的更新操作都通过主结点处理,对于更新频繁的业务,使用主从复制模型优势不大;

  3. 主节点是系统的瓶颈和弱点

4、对等复制

4.1、特点

  1. 所有节点地位相同,都可接收查询和写入请求; 
  2. 各节点将自己的更新的数据复制到其他节点;

4.2、优点

  1. 从容处理出错节点,不必担心数据请求的丢失

  2. 增加节点,轻易提升查询和写入性能

4.3、缺点

  1. 数据不一致性 
    写入和读取都有可能发生冲突;

5、结合使用

分片和主从复制中的一拖一方案结合使用; 

分片的作用在于数据的分布式存储;主从复制的作用在于为各个分片结点提供备份,增加数据安全;


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324824731&siteId=291194637