Excerpt from "Principle and Practice of Distributed Consistency from PAXOS to ZOOKEEPER" (1)

Distributed characteristics
1) Distributed: Distributed randomly in space, and the distribution of machines is also changing at any time
2) Peer-to-peer: There is no master-slave distinction, and there is no host that controls the entire system. Copy is the most common concept of distributed systems;
    copy concept :
        The first is the existence of nodes, which is used to store the same data in different nodes. When the storage data of one node is
              lost , it can read data from other copies to solve the problem of distributed data loss;
        the second is the service copy, which is for Multiple nodes provide the same service
3) Concurrency: For the concurrency problem, it refers to the concurrent operation of the distributed system to share resources, and the solution to the problem of coordinating and publishing distributed operations solved by the distributed system
4) Lack of a global clock: because the distributed system is in space There are multiple processes randomly distributed on the Internet, and they all communicate and interact through communication, so
sometimes it is difficult to define two time sequences, because the system lacks a global clock sequence control
5) Fault handling plan: distributed Exception handling

ACID transaction
1. Atomicity: refers to an atomic operation sequence unit, all successful or not all executed; refers to a sequence of operations either all executed successfully, or rolled back
2. Consistency: transaction execution cannot destroy the integrity of the database and consistency, for example, the two accounts transfer money to each other here, the two operations must have data consistency, maintain one-in-one-out
synchronization
3. Isolation: In a concurrent environment, concurrent transactions are isolated from each other, and the execution of one transaction cannot be executed by other transactions. Interference, each transaction has its own complete data space between different transactions, and four transaction isolation levels are defined in sql:
1) Unauthorized read: also called read uncommitted, for example, A and B transactions run at the same time, A transaction pair The variable j does an auto-increment operation, and the j seen by the B transaction is the middle of different times
   Values, such as 1, 2, 3, 4, etc.
2) Authorized reading: also known as read committed, the difference is that transaction B can only read the value of the j variable that was finally submitted by transaction A
3) Repeatable reading : Only the data read by the transaction for the first time remains unchanged. For example, the j read by the transaction B for the first time is 1, then the transaction in B is always 1.
4) Serialization: refers to only one transaction One execution, cannot be executed concurrently, the strictest execution method
4. Persistence: If the transaction is committed, then the data consistency is maintained. Even if it is down or fails, it must be able to recover to the transaction

commit
. The challenge is to take into account both availability and consistency. Consistency refers to satisfying distributed ACID, and availability is maintaining 24 availability
. 1. CAP theory: This theory tells us that a distributed system cannot satisfy consistency, availability, and partition fault tolerance at the same time; At most two of them are satisfied at the same time
: 1) Consistency: it means that the update execution obtained by multiple copies of data is consistent, and it should be consistent for each node.
2) Availability: only return normal results within a certain time period, and the time period refers to The time period required for different systems, for example, the expected value of
a is 20 seconds, and it is 0.5 seconds for the search engine, so they are different; the normal result is the result set returned by normal business operations
3) Network fault tolerance: refers to When the network fails, it can still provide consistency and availability to the outside world, unless all failures occur.
   Because it is a distributed system, network fault tolerance must be a basic requirement. Different nodes of a distributed system are distributed on different sub-networks. If the
   network fault tolerance is abandoned, it means Going back to a centralized solution, so architects need to balance consistency and availability

2.BASE Theory
   It is a further extension of the cap theory. Since the availability and consistency that cannot be done are perfectly balanced, the final consistency solution can be achieved from three aspects:
   1. Basic availability is to allow the loss of partial availability to achieve: response time loss and function Loss;
   2. Weak state: there is a delay that allows replica data to be synchronized between different nodes
   3. Final consistency: it can ensure that in the event of a failure, the data reaches a consistent state depending on network delay, system load, and data replication scheme is

   eventually consistent There are five main ways of performance
   : 1. Causal consistency: When process B uses A's data, it must be obtained after A updates the data and commits the transaction
   . 2. Read what it has written: It means that when the process operates the data, it does not Read the old data that is lower than your own version
   3. Session consistency: the latest data that can be read in a session for system access
   4. Monotonic read consistency: refers to the data read by a process from a system , and subsequent reads will not be later than this value.
   5. Monotonic write consistency: a system needs to ensure that the write operations of the same process are executed sequentially

   Summary: BASE theory is aimed at large-scale high-availability scalable distributed systems, he emphasized Gain availability by sacrificing consistency and allow
   data inconsistency for a period of time, but the end result is consistency
 

Guess you like

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