II: Distributed System transactions

Source: Internet
Author: User

One: Business
---> is a program execution logical unit consisting of a series of operations that access and update the data in the system. Ensure that the data is correct in the business logic.
The four characteristics of---> Business: atomicity, consistency, isolation, persistence. The acid characteristics of a transaction.
Atomic Nature
Either all successfully executed, or all failed.
Consistency
Transactional consistency, data is logical. Can only be changed from one consistency state to another consistency state. No intermediate state data is allowed.
Isolation of
The isolation of a transaction is defined in a concurrency environment. Concurrent transactions are isolated from each other. Execution of one transaction cannot be disturbed by other transactions. That is, the operations within one transaction and the data used are isolated from other concurrent transactions, and the transactions performed concurrently cannot interfere with each other.
Durability
Once a transaction completes successfully, the updates it makes to the database must be persisted. Even if a system crash and a machine outage fail, as long as the database can be restarted, it must be able to restore it to the state at the end of the transaction's success




II: Distributed Transactions
---> Distributed transactions are participants in transactions, servers that support transactions, resource servers, and transaction managers located on different nodes of a distributed system, respectively. Typically, a distributed transaction involves operations on multiple data sources or business systems.
---> A distributed transaction can be thought of as being composed of multiple distributed operation sequences. This series of distributed sequences of operations can often be referred to as child transactions. As a result, distributed transactions can also be defined as a nested transaction, with an acid-based transactional nature. However, because the execution of each sub-transaction is distributed in the distributed transaction, it is very complicated to implement a distributed transaction processing system which can guarantee the acid characteristic.
---> Typical case: Cross-line transfer. A bank transfer to Bank B. A bank to bank B through the message to send money to operate successfully, a bank to reduce money business failure. But Bank B is more successful than money. b The Bank account money was immediately taken away. A bank transaction rollback. But the money has been taken away. There is a problem with this distributed transaction.


Three: Cap and base theory
---> Centralized transaction and local transaction processing system, acid model to ensure the strict consistency of data.
---> For distributed transactions, a simple implementation of the acid characteristics can be a conflict between system availability and strict consistency.
---> Usability for consumers is not allowed us to bargain on the system properties
---> Consistency is the consumer's need for the application system.
---> How to build a distributed system that balances availability and consistency has become a challenge for countless engineers. There is a classical theory of distributed systems such as caps and base.



Three: Cap theorem




---> Distributed system consistency.
(1) In a distributed environment, consistency refers to the ability of data to remain consistent across multiple replicas. Under the requirement of consistency, when a system performs the update operation in the consistent state of the data, it should ensure that the data of the system is still in a consistent state.
(2) for a system that distributes copies of data across different distributed nodes. If the data for the first node is updated and succeeds, but does not make the data on the second node be updated accordingly, then the data for the second node is fetched with old data or dirty data. This is the case of typical distributed data inconsistencies. If the data for one node is updated and all other nodes are updated accordingly, then such a system is considered strong consistency.

---> Distributed system availability
(1) Availability means that the services provided by the system must always be available, and that for each operation request of the user, the result can be returned within a limited time. Here we focus on "limited time" and "return results"
(2) "Within a limited time" means, for a user's operation request, the system must be able to return the corresponding processing results within a reasonable length of time. If this time frame is exceeded, then the system is considered unavailable.
(3) The "return result" is another very important indicator of usability, which requires the system to return a normal response after the processing of the user's request has been completed. Normal response results can often clearly reflect the outcome of the processing of a request, that is, success or failure, rather than a return result that confuses the user.

---> Distributed system partitioning fault tolerance
(1) Partitioning fault tolerance constrains the need for a distributed system to have the following characteristics: In the event of any network partition failure, distributed systems still need to be able to provide services that meet consistency and availability, unless the entire network environment has failed.
(2) The network partition refers to the distributed system, the different nodes are distributed in different sub-networks (computer room or off-site network, etc.), because of some special reasons, the network is not connected between these sub-network conditions. But the internal network of each sub-network is normal. This results in the network environment of the whole system being cut into several isolated areas. It is important to note that the join and exit of each node that makes up a distributed system can be considered a special network partition.



Summary of CAP theory for---> Distributed systems
(1) As we can see from the cap theorem, a whitewash system cannot meet the three requirements of consistency, availability, and partition fault tolerance at the same time. On the other side, it is important to be clear that partition fault tolerance is a basic requirement for a distributed system. Why this said, in fact, is very simple, because it is a distributed system, then the formation of distributed systems must be deployed to different nodes, otherwise it does not matter whether the distributed system, it will inevitably appear in the sub-network. For the distributed system, the network problem is a certain abnormal situation. Therefore, partition fault tolerance becomes a problem that a distributed system must face and solve. Therefore, system architects often need to focus on how to strike a balance between C (consistency) and a (usability) in terms of business characteristics.








Four: Base theory
---->base is shorthand for the basically Available (Basic), Soft State (soft) and eventually consistent (final consistency) three phrases.
---->base is the result of a tradeoff between consistency and availability in the CAP, which comes from a summary of distributed practices in large-scale Internet systems. is based on the cap theorem evolved gradually. The core idea is that even if there is no strong consistency (strong consistency), each application can achieve eventual consistency (eventual consistency) in accordance with its own business characteristics and in the appropriate way.
Three elements of---->base
Basic available
"1" is basically used to mean that distributed systems allow loss of department availability in the event of unpredictable failures--but note that this is by no means equivalent to the system being unavailable. The following two are typical examples of "basic availability".
"2" Response time loss: Under normal circumstances, an online search engine needs to return to the user within 0.5 seconds of the corresponding query results, but due to failure (such as the system part of the computer room power outage or fault), the corresponding time of the query results increased to 1-2 seconds.
"3" function loss: Under normal circumstances, in an e-commerce site to do shopping, consumers can almost complete each order, but in some festivals to promote shopping peak, due to the surge in consumer shopping behavior, in order to protect the stability of the shopping system, some consumers may be led to a downgrade page.

Weak state
"1" weak state, also known as the soft state, and the hard state, is to allow the system of data in the middle State, and that the existence of the intermediate State does not affect the overall availability of the system, that is, allow the system to synchronize data between the different nodes of the process of data synchronization exists delay.

Final consistency
The final consistency of 1 emphasizes that all copies of the data in the system can eventually reach a consistent state after a period of synchronization. Therefore, the essence of final consistency is the need for the system to ensure that the final data can be consistent, without the need for real-time guarantee the strong consistency of system data.
The final consistency of 2 is a special weak consistency: The system guarantees that the data will eventually reach a consistent state in the absence of any other new update operations, so that all client data access to the system is able to obtain the most recent value. At the same time, in the absence of failure, the data reached a consistent state delay, depending on the network delay, system load and data replication scheme design and other factors.



Five: Five variants of final consistency in the three elements of base theory
Causal consistency
---> Causal consistency means that if process a notifies process B after the data has been updated, then the access to that data after process B should be able to obtain the most recent value after the update of process A, that is, the situation where the loss of the update cannot occur. At the same time, there is no such restriction on the data access of process C, which has no causal relationship to process a.

Read what has been written
---> Read has been written that when process a updates a data, it will always have access to the latest updated values, without seeing the old values. That is, for a single data-acquisition, the data it reads must be no more than the old value it was last written to. Therefore, reading has been written can also be seen as a special causal consistency.

Session consistency
---> Painting consistency the process of accessing system data is framed in a single session, ensuring that "read-write" consistency is achieved in the same effective session, meaning that after the update operation, the client is able to always read the latest value of the data item in the same session.


Monotonic Read Consistency
---> monotonic read consistency means that if a process reads a value from a data item from the system, then any subsequent data access to the process should not return an older value.


Monotonic Write consistency
---> Monotone write consistency means that a system needs to be able to ensure that write operations from the same process are executed sequentially.

II: Distributed System transactions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.