CN112799827A - Method for guaranteeing cross-service database transaction - Google Patents
Method for guaranteeing cross-service database transaction Download PDFInfo
- Publication number
- CN112799827A CN112799827A CN201911115515.5A CN201911115515A CN112799827A CN 112799827 A CN112799827 A CN 112799827A CN 201911115515 A CN201911115515 A CN 201911115515A CN 112799827 A CN112799827 A CN 112799827A
- Authority
- CN
- China
- Prior art keywords
- distributed transaction
- distributed
- service
- cluster
- rollback
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 21
- 238000001514 detection method Methods 0.000 claims abstract description 4
- 239000011347 resin Substances 0.000 claims description 3
- 229920005989 resin Polymers 0.000 claims description 3
- 238000012423 maintenance Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 4
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000000638 solvent extraction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/505—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a method for guaranteeing cross-service database transactions, which comprises the following specific implementation processes: creating a distributed transaction controller to control the whole distributed transaction; the front-end request is subjected to load balancing through nginx and then forwarded to the web container, and the request is executed by a single thread in the web container; the distributed transaction controllers are distributed horizontally to form a cluster for providing services to the outside, and the down controllers are removed from cluster nodes through heartbeat detection; and using the redis as a cache, and sharing the redis in the cluster. The invention can solve the problem of distributed transaction, realize the reconstruction of the distributed architecture of the service, further greatly improve the performance of the system, and can horizontally divide the database after realizing the distributed transaction, thereby greatly improving the operation and maintenance cost.
Description
Technical Field
The invention relates to the technical field of distributed transactions, in particular to a method for guaranteeing cross-service database transactions.
Background
In the prior art, the transactional property of the database is ensured through dao native transactions by coupling all logics in the same service. However, the pressure of the flow cannot be shared, the coupling of the services is too high, the whole system has a single point problem, all the services are affected when a certain functional module has a problem, the database cannot be divided, and the data volume of the single database is too large, so that a method for guaranteeing the cross-service database transaction is provided.
Disclosure of Invention
Based on the technical problems in the background art, the invention provides a method for guaranteeing cross-service database transactions.
The invention provides a method for ensuring cross-service database transactions, which comprises the following specific implementation processes:
creating a distributed transaction controller to control the whole distributed transaction;
the front-end request is subjected to load balancing through nginx and then forwarded to the web container, and the request is executed by a single thread in the web container;
the distributed transaction controllers are distributed horizontally to form a cluster for providing services to the outside, and the down controllers are removed from cluster nodes through heartbeat detection;
and using the redis as a cache, and sharing the redis in the cluster.
Preferably, the distributed transaction controller in S1 identifies the performing of the distributed transaction by creating a record of the distributed transaction, and records the operation into the StepList field before performing the operation of the service.
Preferably, when the distributed transaction controller in S1 needs to perform rollback, the record of the current distributed transaction is put into a rollback queue, and when performing rollback, the distributed transaction controller obtains the performed service operation record according to the StepList, and sends the record to the respective service for rollback.
Preferably, the distributed transaction controller in S1 concatenates the entire distributed transaction process with the unique identifier uuid recorded by hdStatus.
Preferably, the web container is one of tomcat or resin.
The beneficial effects of the invention are as follows:
1. by creating the controller of the distributed transaction, the problem of the distributed transaction can be solved, the reconstruction of a distributed architecture of the service is realized, the performance of the system is greatly improved, the horizontal database partitioning can be performed on the database after the distributed transaction is realized, and the operation and maintenance cost can be greatly improved.
2. Only one thread is required to execute each request in the web container from initialization to completion, so that the concurrency problem caused in a multi-thread environment is avoided, and the stateless distribution of the distributed controller is realized to solve the high concurrency problem.
3. And the redis is used as a cache, and the redis is shared in the cluster, so that the problem of data consistency can be solved, and a high-availability architecture is further realized.
Drawings
FIG. 1 is a schematic diagram of a system architecture for single-thread high concurrency of a method for guaranteeing cross-service database transactions according to the present invention;
fig. 2 is a schematic diagram of a system architecture for realizing high availability of a Redis + cluster, which is a method for guaranteeing cross-service database transactions provided by the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
Referring to fig. 1-2, a method for guaranteeing cross-service database transactions creates a central control service named hdstatuussvr to control the whole distributed transaction, and the service is mainly responsible for the following functions:
a. creating a record to identify the proceeding of this distributed transaction is called hdStatus record, and before doing any service operation, this operation must be recorded in the stepList field.
b. When rollback is required, the hdStatus record is placed in a rollback queue. And when the rollback is carried out, acquiring the operation of which services are carried out according to the stepList, and sending the operation to the respective service for rollback.
c. The unique identifiers uuid recorded by the hdStatus are connected in series in the whole distributed transaction process.
In the present invention, the high concurrency and high availability architecture of the distributed transaction controller:
(1) single thread achieves high concurrency: all the requests of the front end are subjected to load balancing through nginx and then forwarded to web containers such as tomcat, resin and the like, only one thread is required to execute each request in the web containers from initialization to termination, so that the concurrency problem caused in a multi-thread environment is avoided, the stateless distribution of the distributed controller is realized, the high concurrency problem is solved, and the system architecture diagram is shown in figure 1.
(2) Redis + clustering enables high availability: the distributed transaction controllers are horizontally distributed to form a cluster for providing services to the outside, so that even if partial controllers are down, functions cannot be influenced, the down controllers are removed from cluster nodes through heartbeat detection, the health condition in the cluster is guaranteed, a redis is used as a cache, the redis is shared in the cluster to solve the problem of data consistency, a high-availability architecture is further realized, and a system architecture diagram is shown in figure 2.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be considered to be within the technical scope of the present invention, and the technical solutions and the inventive concepts thereof according to the present invention should be equivalent or changed within the scope of the present invention.
Claims (5)
1. A method for guaranteeing cross-service database transactions is characterized in that the specific implementation process is as follows:
creating a distributed transaction controller to control the whole distributed transaction;
the front-end request is subjected to load balancing through nginx and then forwarded to the web container, and the request is executed by a single thread in the web container;
the distributed transaction controllers are distributed horizontally to form a cluster for providing services to the outside, and the down controllers are removed from cluster nodes through heartbeat detection;
and using the redis as a cache, and sharing the redis in the cluster.
2. The method of claim 1, wherein the distributed transaction controller in S1 identifies the distributed transaction by creating a record of the distributed transaction, records the operation into the StepList field, and then performs the service operation.
3. The method of claim 2, wherein the distributed transaction controller in S1, when a rollback is required, puts the record of the current distributed transaction into a rollback queue, and when a rollback is required, obtains a record of performed service operations according to the StepList, and sends the record to the respective service for rollback.
4. The method of claim 3, wherein the distributed transaction controller in S1 concatenates the entire distributed transaction process with the unique identifier uuid recorded in hdStatus.
5. A method for guaranteeing cross-service database transactions according to claim 4, wherein said web container is one of tomcat or resin.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911115515.5A CN112799827A (en) | 2019-11-14 | 2019-11-14 | Method for guaranteeing cross-service database transaction |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911115515.5A CN112799827A (en) | 2019-11-14 | 2019-11-14 | Method for guaranteeing cross-service database transaction |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112799827A true CN112799827A (en) | 2021-05-14 |
Family
ID=75803919
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911115515.5A Pending CN112799827A (en) | 2019-11-14 | 2019-11-14 | Method for guaranteeing cross-service database transaction |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112799827A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020174108A1 (en) * | 2001-05-15 | 2002-11-21 | International Business Machines Corporation | Method for managing distributed savepoints across multiple DBMS's within a distributed transaction |
CN103647834A (en) * | 2013-12-16 | 2014-03-19 | 上海证券交易所 | System and method used for processing multi-phase distributed task scheduling |
US20150046511A1 (en) * | 2013-08-06 | 2015-02-12 | Wal-Mart Stores, Inc. | System and method for storing and processing web service requests |
US20180191811A1 (en) * | 2016-12-31 | 2018-07-05 | UBTECH Robotics Corp. | Distributed server systems and data processing methods |
CN108737548A (en) * | 2018-05-24 | 2018-11-02 | 南京邮电大学 | Distributed WEB micro services container aggregated structure system and its implementation |
CN109885382A (en) * | 2019-01-16 | 2019-06-14 | 深圳壹账通智能科技有限公司 | The system of cross-system distributed transaction processing method and distributing real time system |
CN110012098A (en) * | 2019-04-04 | 2019-07-12 | 浙江工业大学 | A kind of web high concurrent access process system and method |
-
2019
- 2019-11-14 CN CN201911115515.5A patent/CN112799827A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020174108A1 (en) * | 2001-05-15 | 2002-11-21 | International Business Machines Corporation | Method for managing distributed savepoints across multiple DBMS's within a distributed transaction |
US20150046511A1 (en) * | 2013-08-06 | 2015-02-12 | Wal-Mart Stores, Inc. | System and method for storing and processing web service requests |
CN103647834A (en) * | 2013-12-16 | 2014-03-19 | 上海证券交易所 | System and method used for processing multi-phase distributed task scheduling |
US20180191811A1 (en) * | 2016-12-31 | 2018-07-05 | UBTECH Robotics Corp. | Distributed server systems and data processing methods |
CN108737548A (en) * | 2018-05-24 | 2018-11-02 | 南京邮电大学 | Distributed WEB micro services container aggregated structure system and its implementation |
CN109885382A (en) * | 2019-01-16 | 2019-06-14 | 深圳壹账通智能科技有限公司 | The system of cross-system distributed transaction processing method and distributing real time system |
CN110012098A (en) * | 2019-04-04 | 2019-07-12 | 浙江工业大学 | A kind of web high concurrent access process system and method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10289443B2 (en) | System and method for sharing global transaction identifier (GTRID) in a transactional middleware environment | |
CN108304271B (en) | Distributed transaction manager and management method under micro-service architecture | |
KR102072726B1 (en) | Systems and methods for supporting inline delegation of middle-tier transaction logs to database | |
CN107979635A (en) | System, method and storage medium based on micro services | |
CN106776984B (en) | A kind of cleaning method of distributed system mining data | |
US9086911B2 (en) | Multiprocessing transaction recovery manager | |
WO2019047441A1 (en) | Communication optimization method and system | |
CN104572415A (en) | Event log recording method applicable to distributed system | |
CN107153527A (en) | A kind of parallel radar data processing method based on message queue | |
CN105808342A (en) | Method used for allocating client requests and judgment apparatus and system | |
CN110928746B (en) | Configurable business processing system, method, device and storage medium | |
CN109189575A (en) | A kind of Explore of Unified Management Ideas and device of more OpenStack clusters | |
CN107463663B (en) | Lightweight multi-data source access method | |
CN112799827A (en) | Method for guaranteeing cross-service database transaction | |
CN107153679B (en) | Extraction statistical method and system for semi-structured big data | |
US11163601B2 (en) | Dynamically determine the transaction coordinator in multitier hybrid transaction processing middleware systems | |
CN113051331A (en) | Connection pool conversion method, device, equipment and storage medium of database | |
US20180067859A1 (en) | Selective allocation of cpu cache slices to database objects | |
CN111752949B (en) | Service processing method and device | |
US9984096B2 (en) | System and method for reducing communications overhead in a distributed transactions environment by modifying implementation of the transaction start function | |
CN113760671A (en) | Online task diagnosis method and device and electronic equipment | |
CN110428314A (en) | For summarizing asynchronous invoking method, device and the electronic equipment of verification subsystem | |
CN110109936B (en) | Method for avoiding database lock waiting and transaction merging and submitting | |
CN112350837A (en) | Cloud platform-based power application cluster management method and device | |
CN112700304B (en) | Order interaction management system based on multiple platforms |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |