What is a distributed system 01-- distributed transactions

Beginning of this article will introduce you to the beginning of the relevant knowledge distributed systems. I am concerned about the number of public "side Java Code" 10:24 every day with you to learn more Java-related knowledge.

Affairs

Transaction (TRANSACTION) are a series of operations as a single logical unit of work performed, these operations as a whole system to be submitted together, are either executed or not executed. A transaction is a logical unit of work indivisible transaction must have the following four properties referred to as ACID properties:

Atomicity (Atomicity)

A transaction is a complete operating. Each step operation transaction is indivisible (atoms) - either perform or not to perform
the line.

Consistency (Consistency)

When the transaction is completed, the data must be in a consistent state.

Isolation (Isolation)

All data can be modified concurrent transactions are isolated from each other, indicating that the transaction must be independent, it should not in any way affect or depend on other matters.

Persistent (Durability)

After the transaction is complete, it modifies its database is permanently kept, the transaction log to maintain permanent transaction.

Distributed Transaction

Distributed Transaction: refers to the transaction involves operating multiple databases.

The key is to ensure that all nodes in the data write operation, or else all executed or all not executed. But a machine can not know the results of the other machines in the local affairs in the implementation of local affairs. So I do not know in the end of this transaction should commit or roolback.

常规的解决办法就是引入一个“协调者”的组件来统一调度所有分布式节点的执行。

CAP theory

A distributed system can only meet two of the three Consistency (consistency), Availability (availability), and Partition tolerance (partitions fault tolerance).

CA (abandon P): all the data on one node. Meet consistency, availability;
the AP (give up C): give up the strong consistency, to ensure consistency with the final;
the CP (renounce A): Once the system has met failure, the affected server to wait for some time, unable to provide external during recovery service.

Consistency (Consistency)

From the perspective of the client, multi-process concurrent access to updated data in different strategies of how to get different processes, determines the different consistency:

  1. Strong consistency : For a relational database, updated data can be requested follow-up visits can see;
  2. Weak consistency : subsequent to tolerate some or all not visit;
  3. Eventual consistency : After a period of time required to access the updated data.

CAP中说,不可能同时满足的这个一致性指的是强一致性。

Availability (availability)

Service has been available, and is a normal response time.

大型互联网为了服务可用,舍弃强一致性,保证最终一致性。

Partition Tolerance (partitions fault tolerance)

Distributed systems in the face of a node or network failure, still be able to provide to meet the external consistency and availability of services. That it is, in the case of a network outage, if the system still work.

BASE theory

What is BASE theory

BASE theory consists of three points: Basically the Available (available basic) , Soft State (soft state) , and Eventually consistent (final consistency) .

Base theory is the result of the CAP consistency and availability trade-offs, which comes from large Internet distributed a summary of the practice is based on CAP theorem gradually evolved. The core idea is:既是无法做到强一致性(Strong consistency),但每个应用都可以根据自身的业务特点,采用适当的方式来使系统达到最终一致性(Eventual consistency)。

Basically Available (Basic available)

Assume that the system, there has been unpredictable fault, but still can be used, compared to the normal system in terms of:

  1. Loss response time : 0.5 seconds search engine under normal conditions i.e. the results returned to the user, without substantially available search engines can return a result action in one second;
  2. Loss of features : electricity supplier on a website, under normal circumstances, the user can successfully complete every order, but to a big promotion period, in order to protect the stability of shopping system, some consumers may be directed to a page downgrade .

Soft state (soft state)

Hard state : the atomic properties, the copy of the data required a plurality of nodes are the same.

Soft state : the system allows the data in an intermediate state, and that the state does not affect the overall availability of the system, i.e. the system allows the presence of multiple copies of the data in the delay data to different nodes.

Eventually consistent (eventual consistency)

System to ensure no other new update operations, the data eventually will be able to achieve a consistent state, all client data access to the system will eventually be able to obtain the latest value. Eventual consistency include the following:

  1. Causal consistency (Causal Consistency) : If node A after some data has been updated to inform the Node B, then Node B after the access and modify data are based on the value of the A update. Meanwhile data access, the node A and the node C no causal relationship is not so limited;

  2. Read our own written (the Read your Writes) : This is very simple, after a node A updates the data itself always have access to their latest updated values, but will not see the old value. In fact, it can be considered a causal consistency;

  3. Session consistency (the Session Consistency) : process block access session data consistency system will be set at a session which: system ensures consistency, "read written by our own" in the same valid session, that is , after performing the update operation, the client can always read the latest value of the data item in the same session;

  4. Monotone read consistency (Read Consistency Monotonic) : Monotone read consistency means that if a node reads out a value of a data item from the system, the system for any subsequent data access node should not return to the older value;

  5. Monotone write consistency (Monotonic Write Consistency) : refers to a system to be able to ensure that a write operation from the same node is the execution order.

Guess you like

Origin www.cnblogs.com/weechang/p/12616146.html