With the increasing number of high-level concurrent access and massive data processing scenarios on large websites, it is increasingly important to achieve high-availability, scalability, scalability, and security goals.

In order to solve such a series of problems, the architecture of large websites is also constantly evolving. To improve the high-availability architecture of large websites, it is necessary to mention distributed. In the article "Consistency Discussion of Distributed Systems", the consistency problem in distributed systems is mainly introduced. This article will briefly describe how to effectively address distributed consistency issues, including what is distributed, two-phase commit, and three-phase commit.

Distributed consistency review

In a distributed system, in order to ensure high availability of data, we usually keep multiple copies of the data, which are placed on different physical machines. In order to provide users with the correct semantics such as adding, deleting, and changing, we need to ensure that the copies placed on different physical machines are consistent.

In order to solve this distributed consistency problem, many typical protocols and algorithms have been summarized in the process of anti-repetition and trade-off of performance and data consistency. Among the more famous ones are the Two Phase Commitment Protocol, the Two Phase Commitment Protocol and the Paxos algorithm.

Distributed transaction

A distributed transaction is a transaction that involves manipulating multiple databases. In fact, the concept of the same library transaction is extended to the transaction of multiple libraries. The goal is to ensure data consistency in distributed systems. The key to distributed transaction processing is that there must be a way to know all the actions that the transaction does anywhere, and the decision to commit or roll back the transaction must produce a uniform result (all commits or all rollbacks).

In a distributed system, each node is physically independent of each other and communicates and coordinates through the network. Due to the existence of a transaction mechanism, it is guaranteed that the data operations on each individual node can satisfy the ACID. However, the execution of transactions in other nodes cannot be accurately known between nodes that are independent of each other. So in theory, the two machines theoretically cannot reach a consistent state. If you want to keep the data in multiple machines distributed in a consistent manner, then you must ensure that the data write operations on all nodes, or not all are executed. However, a machine cannot know the execution result of a local transaction in another machine while executing a local transaction. So he does not know whether this transaction should be committed or roolback. Therefore, the conventional solution is to introduce a "coordinator" component to uniformly schedule the execution of all distributed nodes.

XA specification

The X/Open organization (now Open Group) defines a distributed transaction processing model. The X/Open DTP model (1994) includes an application (AP), a transaction manager (TM), a resource manager (RM), and a communication resource manager (CRM). In general, a common transaction manager (TM) is a transaction middleware, a common resource manager (RM) is a database, and a common communication resource manager (CRM) is a message middleware. Usually a transaction within a database, such as operations on multiple tables, is treated as a local transaction. The transaction object of the database is a local transaction, and the object of a distributed transaction is a global transaction. The so-called global transaction refers to a distributed transaction processing environment, multiple databases may need to work together to complete a job, this work is a global transaction, for example, a transaction may update several different databases. Operations on the database occur throughout the system but must all be committed or rolled back. At this point, the commit of a database to its own internal operations depends not only on the success of its own operation, but also on the success of other databases related to the global transaction. If any operation of any database fails, then all the participating transactions are involved. All operations done by the database must be rolled back. In general, a database cannot know what other databases are doing. Therefore, in a DTP environment, transaction middleware is required to notify and coordinate the commit or rollback of related databases. A database only maps its own operations (recoverable) to global transactions.

XA is the interface specification (ie interface function) between the transaction middleware defined by X/Open DTP and the database. The transaction middleware uses it to notify the start, end, and commit, rollback, etc. of the database transaction. The XA interface functions are provided by the database vendor.

The second-order commit protocol and the third-order commit protocol are derived from this idea. It can be said that the two-phase commit is actually the key to realize the XA distributed transaction (exactly: the two-phase commit mainly guarantees the atomicity of the distributed transaction: that is, all nodes are either all or none)

2PC

Two-phase Commit refers to an algorithm designed in the computer network and database domain to make all nodes under the distributed system architecture consistent in transaction commit. Usually, a two-phase commit is also referred to as a protocol. In a distributed system, each node can know the success or failure of its operations, but cannot know the success or failure of other nodes. When a transaction spans multiple nodes, in order to maintain the ACID characteristics of the transaction, it is necessary to introduce a component as a coordinator to uniformly control the operation results of all nodes (called participants) and finally indicate whether these nodes want to make the operation result true. Submission (such as writing updated data to disk, etc.). Therefore, the algorithm idea of ​​the two-stage submission can be summarized as follows: the participant informs the coordinator of the success or failure of the operation, and then the coordinator determines whether each participant should submit the operation or suspend the operation according to the feedback information of all the participants.

The so-called two phases are: the first phase: the preparation phase (voting phase) and the second phase: the submission phase (execution phase).

Preparation Phase

TPU Screen Protector


Hd Screen Protector,High-Definition Screen Protector,Hd Clear Screen Protector,Transparent Screen Film

Shenzhen TUOLI Electronic Technology Co., Ltd. , https://www.hydrogelprotector.com