Database transaction design and implementation under microservice architecture

Author: Zen and the Art of Computer Programming

1 Introduction

With the rise of new technologies such as the Internet, mobile Internet, and cloud computing, more and more people are beginning to transform from standalone applications to service-oriented architecture. Faced with the huge challenges brought by this architectural model, microservice architecture proposes a new architectural paradigm. Under the microservice architecture, the finer the services are split, the more complex the data processing in each service will be, requiring more database transaction mechanisms to ensure data consistency, integrity, and availability. This article will introduce how to design and implement database transactions under a microservice architecture.

2.Basic concepts and terminology

2.1. Database transactions

Database transaction (Transaction) is an indivisible unit of work. Its processing unit is a SQL statement or a sequence of program operations. It is controlled by a transaction manager to ensure that all data changes during database execution are successful. (Commit), or all fail (Rollback). Transactions have four attributes ACID, which represent Atomicity, Consistency, Isolation, and Durability. Generally speaking, the application scenarios of database transactions include the following:

  1. The beginning and end of the transaction.
  2. Data read and write operations.
  3. Concurrent access to the same data set.
  4. Rollback. When an error occurs in a transaction or the user requests to roll back to the previous correct state, the data modifications made by the transaction must be canceled through rollback.
  5. Commit. Submit indicates that the transaction has completed successfully and requires updated data to be saved to the database.

2.2. Distributed transactions

Distributed Transaction

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132899724