CN112799827A - Method for guaranteeing cross-service database transaction - Google Patents

Method for guaranteeing cross-service database transaction Download PDF

Info

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
Application number
CN201911115515.5A
Other languages
Chinese (zh)
Inventor
吕源星
邓崇良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Faisco Internet Technology Co ltd
Original Assignee
Guangzhou Faisco Internet Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou Faisco Internet Technology Co ltd filed Critical Guangzhou Faisco Internet Technology Co ltd
Priority to CN201911115515.5A priority Critical patent/CN112799827A/en
Publication of CN112799827A publication Critical patent/CN112799827A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation 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/505Allocation 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques 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

Method for guaranteeing cross-service database transaction
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.
CN201911115515.5A 2019-11-14 2019-11-14 Method for guaranteeing cross-service database transaction Pending CN112799827A (en)

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)

* Cited by examiner, † Cited by third party
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

Patent Citations (7)

* Cited by examiner, † Cited by third party
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
CN108304271B (en) Distributed transaction manager and management method under micro-service architecture
CN106776984B (en) A kind of cleaning method of distributed system mining data
US9086911B2 (en) Multiprocessing transaction recovery manager
CN108334557B (en) Aggregated data analysis method and device, storage medium and electronic equipment
WO2013138770A1 (en) Systems and methods for supporting inline delegation of middle-tier transaction logs to database
WO2019047441A1 (en) Communication optimization method and system
CN105592164B (en) A kind of distributed system and method for data processing
CN109062982B (en) Financial data interaction method and device, computer equipment and storage medium
WO2023082681A1 (en) Data processing method and apparatus based on batch-stream integration, computer device, and medium
CN110704442A (en) Real-time acquisition method and device for big data
CN112799827A (en) Method for guaranteeing cross-service database transaction
CN109189575A (en) A kind of Explore of Unified Management Ideas and device of more OpenStack clusters
US11163601B2 (en) Dynamically determine the transaction coordinator in multitier hybrid transaction processing middleware systems
CN110928746B (en) Configurable business processing system, method, device and storage medium
CN109150599A (en) A kind of O&M monitoring system based on cloud framework
CN107463663B (en) Lightweight multi-data source access method
US20150120660A1 (en) Using message-passing with procedural code in a database kernel
US20160294723A1 (en) System and method for reducing communications overhead in a distributed transactions environment by modifying implementation of the transaction start function
US9842052B2 (en) Selective allocation of CPU cache slices to database objects
CN112350837B (en) Cloud platform-based power application cluster management method and device
CN109635040B (en) Real-time data migration method and device and storage medium
CN113051331A (en) Connection pool conversion method, device, equipment and storage medium of database
CN110428314A (en) For summarizing asynchronous invoking method, device and the electronic equipment of verification subsystem
CN110765148A (en) Service data processing method and device
CN110109936B (en) Method for avoiding database lock waiting and transaction merging and submitting

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