Distributed system transaction consistency solution

strong agreement

When the update operation is complete, any access by multiple subsequent processes or threads will return the latest updated value. This is the most user-friendly, that is, what the user wrote last time is guaranteed to be read next time. According to CAP theory, this implementation requires sacrificing availability.

weak consistency

The system does not guarantee that subsequent processes or thread accesses will return the latest updated value. After the data is successfully written, the system does not promise to read the newly written value immediately, nor does it promise to read the latest value.

eventual consistency

A specific form of weak consistency. The system guarantees that the system will eventually return the value of the last update operation without subsequent updates . Under the premise that no failure occurs, the time of the inconsistency window is mainly affected by the communication delay, the system load and the number of replicas. DNS is a typical eventual consistency system.

 

In engineering practice, in order to ensure the availability of the system, most Internet systems convert strong consistency requirements into eventual consistency requirements, and implement idempotency guarantees through the system to ensure the eventual consistency of data.

TCC is the 2PC (2 Phase Commit, two-phase commit) of the application layer, if you think of the application as a resource manager. In detail, what TCC needs to do for each operation are as follows:

1. Try: try to execute the business.

  • Complete all business checks (consistency)
  • Reserve necessary business resources (quasi-isolation)

2. Confirm: Confirm the execution of the business.

  • really execute the business
  • Do not do any business checks
  • Only use the business resources reserved in the Try phase

3. Cancel: cancel the execution of the business

  • Release the service resources reserved in the Try phase

Distributed field CAP theory,
Consistency (consistency), consistent data update, all data changes are synchronous
Availability (availability), good response performance
Partition tolerance (partition tolerance) Reliability

theorem: any distributed system can only simultaneously Satisfying two points, it is impossible to take care of all three.
Advice: architects should not waste energy on how to design the perfect distributed system that satisfies all three, but should make trade-offs.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325065701&siteId=291194637