Eventual consistency BASE theory of distributed transactions

First, the transaction

  All operations in the transaction to provide a mechanism for an activity according to an indivisible into the execution unit, a transaction consisting of all the operations only in the case where in order to submit all normal operations can be performed, as long as either operation fails, will lead to a rollback of the entire transaction. Simply put, the transaction provides an "either do nothing, or do a full (All or Nothing)" mechanism.

Second, distributed transactions

  Distributed Transaction participants of the transaction, transactional servers, server and transaction manager resource are located on different nodes of different distributed systems. Simply put, is a major operation by the composition of different small operation, these small operations distributed across different servers, and belong to different applications, distributed transactions need to ensure that these small operations either all succeed, or all fail.

Third, the application scenarios

  Bank transfer, the station ticket online shopping.

Fourth, the consistency of distributed transactions

1, strong consistency

  This level of consistency is the most user intuitive, it requires a system of what is written, will read out what is a good user experience, but it will often large impact on system performance.

2, weak consistency

  This level of consistency restraint system after writing success, does not promise immediate value can read the writing, but also how long commitment shortly after the data can reach consensus, but to ensure a certain level of time (such as second level as much as possible after), the data can be consistent state.

3, eventual consistency

  The final consistency is the special case of a weakly consistent, the system will guarantee within a certain time, to reach a consistent state of the data. The reason here will eventually consistent singled out because it is a very weak consistency model of consistency respected, but also on industry data consistency large distributed systems more respected model.

Five, BASE theory

  BASE theory is the ultimate consistency and effective solutions to achieve a distributed transaction.

  BASE is Basically Available (basic available), abbreviated three phrases Soft state (soft state) and Eventually consistent (eventual consistency). BASE theory is the result of the CAP consistency and availability trade-offs, which comes from the summary of the large-scale distributed systems Internet practice is based on CAP theorem gradually evolved. BASE is the core idea of the theory: even if unable to do so strong consistency, but each application according to their operational characteristics, in an appropriate manner to enable the system to achieve eventual consistency .

BASE theory of three elements:

1, the basic available

  The basic means of distributed systems available in times of unpredictable failures, allowing lose some usability ---- Note that this is not equivalent to the system unusable. such as:

(1) loss of response time. Under normal circumstances, an online search engine needs to be returned to the corresponding user query results within 0.5 seconds, but due to a failure, the response time of the query result is increased by 1 to 2 seconds.

(2) loss of system functionality: Under normal circumstances, the time for shopping at an e-commerce website, consumers can successfully complete almost every order, but in some holiday shopping season big promotion, because of consumers' surge in shopping behavior, in order to protect the stability of shopping system, some consumers may be directed to a page downgrade.

2, soft state

  Refers to a soft state allows data system there is an intermediate state, and that there is the intermediate state will not affect the overall availability of the system, i.e. the system allows data synchronization process delay between the presence of a copy of the data to different nodes.

3, eventual consistency

  Eventual consistency emphasized that all copies of the data, after synchronization over time, eventually able to achieve a consistent state. Therefore, the nature of eventual consistency is the need to ensure that the final system to achieve data consistency, without the need for real-time systems guarantee strong consistency of the data.

  Overall, BASE theory-oriented large-scale high-availability scalable, distributed systems, and the traditional ACID properties of things are the opposite, it is completely different from the model ACID strong consistency, but obtained by sacrifice strong consistency availability and allow a period of time the data is inconsistent, but eventually reaches a consistent state . But, in an actual distributed scenario, different business units and components are different requirements for data consistency, so in a particular distributed system architecture design process, ACID BASE theoretical characteristics and will often together.

Method to realize:

Guess you like

Origin www.cnblogs.com/guanghe/p/11707401.html