16 ACID, CAP, BASE and distributed transactions

problem

Introduce ACID, CAP, BASE and distributed transactions

answer

* Affairs, refers to the sequence of operations bunch, either executed completely or not an execution; there is an error, the result in front of all the statements have been executed must be revoked in the implementation process, common in the database, but also the business logic ensure data consistency when used. Services are generally stand-alone system to ensure that the database itself.

  • Four characteristics (the ACID) transaction
    atomicity (Atomicity)
    transaction is an indivisible unit, the transaction either all SQL operations such as occur or not occur.
    Consistency (Consistency)
    before and after the transaction occurs and occurs, the integrity of the data must be consistent.
    Isolation (Isolation)
    data between when concurrent access database, a transaction being executed is finished before, corresponding to the other session is not visible, the plurality of concurrent transactions are isolated.
    Persistent (Durability)
    Once a transaction is committed, the data in the database is a permanent change it. If something goes wrong, the transaction is also allowed to withdraw, can only be compensated by other mechanisms.

  • Early in the design of distributed systems will generally focus on three characteristics, Consistency (consistency), Availability (availability), Partition tolerance (partitions fault tolerance), but any effort will be in vain attempt to satisfy the three properties only which meet two.
    The so-called consistency (C): Back up all data in a distributed system, have the same value at the same time, that is a matter which is the latest data access node
    so-called availability (A): part of a node failure in a distributed system after the entire system whether it can read and write requests in response to the client. (For high availability data update)
    called fault tolerance partition (P): means the system can tolerate a failure of communication between the network nodes, to some extent, the network communication failure is inevitable, the system design must be based on this matter It will take place to consider.

  • BASE CAP theory is an extension of the theory, the core idea is that even if unable to do so strong consistency, but also the application should use the appropriate way to achieve eventual consistency.
    Refers to the basic BASE available (Basically Available), soft state (Soft State), the final consistency (Eventual Consistency).
    Basic Available: Distributed Systems at the time of failure, allowing the loss of part availability, ie ensure that the core is available.
    Soft state: the system allows the presence of an intermediate state, the intermediate state without affecting the overall system availability. A distributed storage in general there will be at least three copies of the data, allows synchronization between different nodes copies of the delay is a manifestation of the soft state.
    Eventual consistency: All copies of data in the system after a certain time, and ultimately to achieve a consistent state. Instead weak consistency and strong consistency, the final consistency is a special case of weak consistency.

  • Distributed transaction, most of the system design is to convert eventual consistency and strong consistency, usually through a message queue notice, TCC transaction compensation and maximum effort to notify the completion of eventual consistency.

Published 358 original articles · won praise 0 · Views 2749

Guess you like

Origin blog.csdn.net/langli204910/article/details/105226551