[go: up one dir, main page]

CN112799827A - An Assurance Method for Cross-Service Database Transactions - Google Patents

An Assurance Method for Cross-Service Database Transactions 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
cluster
controller
service
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 OR CALCULATING; 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 OR CALCULATING; 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

本发明公开了一种跨服务数据库事务的保证方法,其具体实现过程为:创建一个分布式事务控制器,来控制整个分布式事务的进行;前端请求通过nginx做负载均衡,再转发到web容器,web容器中单线程执行该请求;将分布式事务控制器做水平分布后形成一个集群对外提供服务,通过心跳检测将宕机的控制器从集群节点中剔除;使用redis做缓存,集群内共用该redis。本发明可以解决分布式事务的问题,实现对业务进行分布式架构的改造,进而大幅度的提升系统的性能,并且实现了分布式事务之后,可以对数据库进行水平分库,可以大幅度的改善运维成本。

Figure 201911115515

The invention discloses a cross-service database transaction assurance method. The specific implementation process is as follows: creating a distributed transaction controller to control the entire distributed transaction; front-end requests are load balanced through nginx, and then forwarded to a web container , a single thread in the web container executes the request; the distributed transaction controller is horizontally distributed to form a cluster to provide services to the outside world, and the downed controller is eliminated from the cluster nodes through heartbeat detection; redis is used as a cache, shared within the cluster the redis. The invention can solve the problem of distributed transactions, realize the transformation of the distributed architecture of the business, thereby greatly improving the performance of the system, and after the distributed transactions are realized, the database can be divided horizontally, which can greatly improve the Operation and maintenance costs.

Figure 201911115515

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 An Assurance Method for Cross-Service Database Transactions Pending CN112799827A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911115515.5A CN112799827A (en) 2019-11-14 2019-11-14 An Assurance Method for Cross-Service Database Transactions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911115515.5A CN112799827A (en) 2019-11-14 2019-11-14 An Assurance Method for Cross-Service Database Transactions

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 An Assurance Method for Cross-Service Database Transactions

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 深圳壹账通智能科技有限公司 Cross-system distributed transaction processing method and system for distributed transaction processing
CN110012098A (en) * 2019-04-04 2019-07-12 浙江工业大学 A web high concurrent access processing 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 深圳壹账通智能科技有限公司 Cross-system distributed transaction processing method and system for distributed transaction processing
CN110012098A (en) * 2019-04-04 2019-07-12 浙江工业大学 A web high concurrent access processing system and method

Similar Documents

Publication Publication Date Title
US10133596B2 (en) System and method for supporting application interoperation in a transactional middleware environment
KR102072726B1 (en) Systems and methods for supporting inline delegation of middle-tier transaction logs to database
CN108304271B (en) A distributed transaction manager and management method under a microservice architecture
US20140157276A1 (en) Distributed transaction routing
CN105843609A (en) An MVC framework based on Spring and MyBatis
CN106776984B (en) A kind of cleaning method of distributed system mining data
TWI687875B (en) Distributed transaction processing method and device
CN111292028B (en) Inventory information processing method and system, computer system and readable storage medium
CN105955801B (en) A kind of distributed optimistic concurrency control method based on RDMA and HTM
CN106503974A (en) Transaction data processing method and device
WO2020000720A1 (en) Server, packet processing method, program, and computer-readable storage medium
CN105653398A (en) Intelligent distribution operation system mirror image method
CN102567399A (en) Method and device for accessing database
WO2020133609A1 (en) Server abnormality processing method and management device
CN107943584A (en) The processing method and processing device of batch transaction request
CN116089126A (en) Method, device and equipment for acquiring data in real time and readable storage medium
CN110765148B (en) A business data processing method and device
WO2024045400A1 (en) Decision flow engine simplification method supporting parallel execution
US20120297005A1 (en) Breaking locks held by two-phase commit transactions while preserving data consistency
CN106033422A (en) A database operation control method, device and system
CN108629016A (en) Support real-time stream calculation towards big data database control system, computer program
CN118193499A (en) Device, method and system for heterogeneous database full migration
US11157690B2 (en) Techniques for asynchronous execution of computationally expensive local spreadsheet tasks
CN112799827A (en) An Assurance Method for Cross-Service Database Transactions
CN105867974A (en) Offline updating method of CS framework application

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210514