I understand the distributed system CAP theorem

There are always some people who are invisible to control the software world, just like the CAP theorem. The first time I heard this word is actually in the interview, it is really sweating, and I try to understand this theorem several times. The English original understanding is not released. Painful thinking, decided to study, and explain with a more popular speech.

noun

CAP Theorem, also known as the Brusler, which points out that for a distributed computing system, it is impossible to meet the following three points: consistentness: All clients query or update to the same latest data availability (Availability : Regardless of whether it is successful, ensure that the response section fault tolerance is received in each request: When the system is split into multiple zones, the system is still available.

principle

Distributed system: Apple deployment interacts through the network between multiple compute nodes and NODE. Partitioning: Unreliability of the network, the isolation between NODE is inevitable. When the network is not arriving, the system is inevitable because the network is separated into a plurality of contactless areas, so the partition of the distributed system is inevitable.

Priority to meet CA

MYSQL branches based on primary key implementation: Database is divided into n instances, each instance M table, primary key% N remainder, an instance of index primary key% M humeum is a table’s index each data exists in one instance of one instance In the table, consistency is satisfied. When the network causes the network causes the partition, the client accesses the data of the Unicom area, the availability and partition fault tolerance are guaranteed; however, the client access data is not connected to the connected partition, the system returns the database access error, meets usability, not satisfied Partition fault. So this access satisfies CA, but to inherrable any partition

Priority to meet CP

Use the master from the MYSQL cluster to do read and write separation, write master, read slave; to ensure data consistency, after the master update, Slave must be successfully replicated until the update is successfully returned. Therefore meet the requirements of data consistency (C). System partition leads, some slave cannot interact, data cannot be copied from Master to slave, resulting in writing unavailable, but reading does not affect. So satisfying C (consistency) P (partition fault tolerance is available), not satisfying A (write function is not available)

Priority to satisfy the AP

Still using the master from the Mysql cluster, read and write separate, write Master, read slave; to ensure availability, data master update is successful, it is considered to be successful, and when some Slave is not required, it can still guarantee the availability of read and write And partition faults. However, there is an inconsistent situation, some clients are located in the same partition with the SLAVE that cannot be documented with MASTER, which may result in reading historical data. So satisfy A (availability) P (partition fault tolerance read writing is available), do not satisfy C (read non-replication of Slave historical data)

Base thinking

More and more large data volumes, high merging systems are preferred to meet APs, guarantee availability, allowing temporary intermediate states, and data ultimate assurance. That is, for BASE thinking: BA: BASICLY AVAILABLE basically available S: Soft State soft status can have a period of time data in an intermediate state, the data is inconsistent. E: EVENTUALLY CONSISTENT ultimately, the final data is consistent.