[Reprint] About Distributed

https://www.cnblogs.com/wupeixuan/p/9302496.html

 

The first chapter is primarily concerned with distributed architecture, mainly includes the following:

  1. Centralized features
  2. Distributed Features
  3. All kinds of problems in distributed environments
  4. ACID
  5. Distributed Transaction
  6. CAP and BASE theory

1 | 1 centralized and distributed features


Centralized features: the deployment of simple structure (based on outstanding because the underlying performance of the mainframe, without regard to the deployment of multiple service nodes, also do not consider the problem of distributed coordination among multiple nodes)

Distributed features:

  • Distributive
  • Reciprocity
  • Concurrency
  • The lack of global clock
  • Failure always happens

1 | 2 all kinds of problems in distributed environments


All kinds of problems in distributed environments:

  • Abnormal communication: mainly because of the unreliability of the network itself
  • Network partition: when an abnormality occurs in the network, leading to network delay between a node portion increasing, eventually leading to some of the nodes can communicate, and the other portion not node.
  • Tri-state (success, failure and timeout)
  • Node failure: server nodes distributed system downtime or "dead" phenomenon

1 | 3 the ACID distributed transactions


Transaction is accessing a program update operation execution logic unit consisting of a series of data in the system, especially the transaction database transaction in a narrow sense.

There are four transaction properties are atomic (Atomicity), consistency (Consistency), isolation (Isolation) and persistent (Durability Rev), referred to as ACID properties of transactions.

  • Atomicity (Atomicity): the sequence of operations must be an atomic unit, only one of the two state occurs (all successfully performed, does not perform all).
  • Consistency (Consistency): can not destroy the database data integrity and consistency before and after the execution of a transaction, the database must be in a consistent state.
  • Isolation (Isolation): isolated from each other, a transaction can not be performed other transactions interference.
  • Persistent (Durability): also known as permanent, once the transaction commits, then modify the changes will be saved to the database forever. Even if the system crashes, the implementation of the outcome of the transaction can not be lost. By database backup and recovery to ensure sustainability.

There are four isolation level transaction is not authorized to read, authorized to read, read and re-serialized.

  • Unauthorized reading (READ UNCOMMITTED): also known as read uncommitted, allow dirty read.
  • Authorized to read (READ COMMITTED): also known as read committed allows unrepeatable reads.
  • Repeatable read (REPEATABLE READ): disabled and non-repeatable reading dirty reads, but phantom data may occur (refer to like transaction operations, two periods before and after performing two read the same data item in take, inconsistent results may occur).
  • Serialization (SERIALIXABLE): requires that all transactions executed serially.

Comparison of four isolation levels

Isolation Levels Dirty read Repeatable read Magic Reading
Read uncommitted presence Can not presence
Authorized to read does not exist Can not presence
Repeatable read does not exist can presence
Serialization does not exist can does not exist

The higher the transaction isolation level, the more we can ensure the integrity and consistency of the data, but the impact on concurrent performance is also greater. Give priority consideration to the isolation level of the database is authorized to read, to avoid dirty read concurrency while ensuring good performance will result in non-repeatable reads, and phantom reads the second class lost update concurrency issues etc., in the case of such problems may arise , we should take the initiative to adopt pessimistic locking and optimistic locking transaction control.

Distributed Transaction means the transaction participants, transactional servers, server and transaction manager resource are located on different nodes of a distributed system. It may also be defined as a nested transaction, and also with the transaction ACID properties.

1 | 4 CAP and BASE theory


CAP theory: a distributed system can not meet the consistency, availability, partition and fault tolerance.

  • Consistency: Data is able to maintain a consistent characteristic among multiple copies.
  • Availability: the system provides the service must be the same in a usable state, always returns results for each operation request user within a limited time.
  • Zoning fault tolerance: a distributed system in the face of any network partition fails, we still need to be able to provide external assurance to meet the consistency and availability of services, unless the entire network environment has failed.

Seen from the CAP Theorem, a distributed system can not meet the consistency, availability, fault tolerance, and partition these three requirements. For a distributed system, partition, fault tolerance is a basic need.

BASE theory: Is Basically Available (basic available), three short phrases Soft state (soft state) and Eventually consistent (eventual consistency). The core idea is that 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.

  • Basic available: a distributed system when a failure occurs unpredictable, allowing availability loss portion.
  • Weak Status: also known as soft state, allowing the system to synchronize data between the data present in the replica delay different nodes.
  • Eventual consistency: All copies of the data system, after synchronization over time, and ultimately to achieve a consistent state.

Eventual consistency following five variants:

  1. Causal consistency
  2. Read our own written
  3. Session consistency
  4. Monotonous read consistency
  5. Monotonous write consistency

Generally speaking BASE theory is large availability for scalable, distributed systems, strong consistency model ACID completely different, but the expense to get the availability of strong consistency and allows data to be inconsistent over time, but eventually reached a consistent state. Actual distributed scenarios, ACID properties will combine theory and BASE.

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11850742.html