Distributed Database CAP principle + BASE

1: CAP theoretical core

CAP core theory is: a distributed system can not simultaneously satisfy consistency, availability, fault tolerance, and partition these three requirements, can only meet two good while.
Therefore, in accordance with the principles of the CAP into a NoSQL database to meet the CA principle, to meet the principles of CP and AP meet the principles of three categories:

  • CA: single-point cluster, meet consistency, availability of the system, usually less powerful on scalability.
  • CP: meet consistency, will tolerate the partition of the system, usually performance is not particularly high .
  • AP: meet availability, partition tolerance of the system, usually require some consistency may be low .

Here Insert Picture Description
CAP theory means that in a distributed storage system, can only achieve the above two points. And because the current network hardware there will be delays and packet loss problems, so partition tolerance that we must need to achieve. So we can only consistency and availability trade-off between, no NoSQL systems can simultaneously guarantee three points.

  • C: strong consistency
  • A: High Availability
  • P: Distributed tolerance
  • CA: Traditional Oracle Database
  • AP: Most sites architecture choices
  • CP :Redis、Mongodb
  • Note: The distributed architecture of the time must make a choice.

2: consistency and availability of choice

For web2.0 site, many key features of relational databases is often useless.

  • Database transactional consistency requirements:
    Many web real-time system does not require strict database transaction requires read consistency is very low, on some occasions to write consistency requirement is not high. It allows eventual consistency.
  • Write and read real-time real-time demand of database:
    relational databases, query immediately after inserting a piece of data, be sure to read out this data, but for many web applications, does not require such a high real-time performance , then send a message to say , after a few seconds or even ten seconds, my subscribers only see this dynamic is perfectly acceptable. Complex SQL queries, especially multi-table queries related needs
  • Any large amount of data web systems are very taboo multiple large table associated with the query, and analyze complex data type of report query, especially the SNS type of site, from the perspective of demand and product design, to avoid this situation produce. More often only a single primary key table queries, and simple single-table query paging conditions, SQL functions are greatly weakened.

3: BASE Introduction

BASE is to the availability of a relational database to solve the problem caused by the strong consistency due to lower solutions proposed.

BASE actually three terms hereinafter abbreviated:

  • Basic available (Basically Available)

  • Soft state (Soft state)

  • The final agreement (Eventually consistent)

  • BASE The idea is to allow the system to relax to the consistency of the data requirements for a certain time in exchange for improved scalability and overall system performance. Why do they say, the reason is that large systems are often due to geographical distribution and very high performance requirements, impossible to use distributed transactions to complete these indicators, in order to obtain these indicators, we have to adopt another way to accomplish here BASE way is to solve this problem

Published 167 original articles · won praise 119 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_44891295/article/details/104087574