CN114237833A - High-performance real-time consistent micro-service execution method and system - Google Patents
High-performance real-time consistent micro-service execution method and system Download PDFInfo
- Publication number
- CN114237833A CN114237833A CN202111541665.XA CN202111541665A CN114237833A CN 114237833 A CN114237833 A CN 114237833A CN 202111541665 A CN202111541665 A CN 202111541665A CN 114237833 A CN114237833 A CN 114237833A
- Authority
- CN
- China
- Prior art keywords
- micro
- service
- calling
- service calling
- verification file
- 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
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/466—Transaction processing
-
- 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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
-
- 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/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Retry When Errors Occur (AREA)
Abstract
The invention relates to a high-performance real-time consistent micro-service execution method and system, which comprises the steps of generating a verification file corresponding to a micro-service calling request to set micro-service calling quantity, determining a service calling state according to the value of the micro-service calling quantity, and combining execution strategies of two-stage submission and three-stage submission to ensure the real-time consistency of data of a distributed transaction scene.
Description
Technical Field
The invention relates to the technical field of distributed transaction processing, in particular to a high-performance real-time consistent micro-service execution method and system.
Background
The mainstream solutions for distributed transactions at present include two-stage commit, three-stage commit, compensatory transactions, and ways to achieve final consistency.
Each solution of distributed transaction has its own application scenario, for example, three-stage commit is suitable for a scenario with high data security requirements, and can ensure data to be consistent in real time, but has low performance and is not supported by a mature framework. The compensatory transaction scheme is similar to manual rollback, can also ensure real-time consistency, but is logistically cumbersome. The final consistency has better performance, but the real-time consistency of the data cannot be ensured.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention provides a high-performance real-time consistent micro-service execution method and system, which combine the execution strategies of two-stage submission and three-stage submission to ensure the real-time consistency of data of a distributed transaction scene, have simpler logic and higher reliability, and are suitable for distributed frame projects such as dubbo and springclosed.
In order to achieve the above purpose, the technical scheme adopted by the invention comprises the following steps:
a high-performance real-time consistent micro-service execution method is characterized by comprising the following steps:
s1, acquiring a micro-service calling request;
s2, generating a verification file corresponding to the micro-service calling request, wherein the verification file comprises the micro-service calling quantity required by the corresponding micro-service calling request;
s3, calling the micro-service according to the micro-service calling request, and polling and inquiring the micro-service calling number;
s4, when the micro-service calling number is empty, feeding back that the micro-service calling fails;
and S5, when the micro-service calling number is not 0 or null, feeding back that the micro-service is successfully called, and subtracting 1 from the micro-service calling number in the verification file.
Further, the verification file also includes an expiration time corresponding to the micro-service invocation request.
Further, the step S3 further includes:
and when the time for calling the micro service exceeds the expiration time, stopping calling and feeding back the failure of calling the micro service.
Further, the method further comprises:
and when the micro service is unsuccessfully called by feedback, rolling back the current service and deleting the corresponding verification file.
Further, the method further comprises:
and S6, when the micro-service calling number is 0, feeding back that all the services are successfully called.
Further, the step S3 further includes:
the distributed lock is used when polling the number of microservice calls.
The invention also relates to a high-performance real-time consistent micro-service execution system, which is characterized by comprising the following components:
the interaction module is used for acquiring the micro-service calling request and feeding back a calling result;
the verification file management module is used for generating a verification file corresponding to the micro-service calling request;
and the query module is used for polling and querying and adjusting the micro-service calling quantity.
The invention also relates to a computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the above-mentioned method.
The invention also relates to an electronic device, characterized in that it comprises a processor and a memory;
the memory is used for storing the verification file;
the processor is used for executing the method by calling the verification file.
The invention also relates to a computer program product comprising a computer program and/or instructions, characterized in that the computer program and/or instructions, when executed by a processor, implement the steps of the above-mentioned method.
The invention has the beneficial effects that:
the high-performance real-time consistent micro-service execution method and system provided by the invention are combined with the execution strategies of two-stage submission and three-stage submission, so that the real-time consistency of data of a distributed transaction scene is ensured, the logic is simpler, the reliability is higher, and the method and system are suitable for distributed frame projects such as dubbo and springclosed.
Drawings
Fig. 1 is a flow chart of a high-performance real-time consistent micro-service execution method according to the present invention.
FIG. 2 is a schematic diagram of a high-performance real-time consistent microservice execution system according to the present invention.
Detailed Description
For a clearer understanding of the contents of the present invention, reference will be made to the accompanying drawings and examples.
The first aspect of the present invention relates to a method for executing high-performance real-time consistent microservice, which has the step flow shown in fig. 1, and comprises the following steps:
and S1, acquiring the micro-service calling request. When the micro-service consumer applies for calling other multiple micro-services, the micro-service consumer does not call the other multiple micro-services in a http or rpc mode provided by the distributed framework.
And S2, generating a verification file corresponding to the micro-service calling request, wherein the verification file comprises the micro-service calling quantity and the expiration time required by the corresponding micro-service calling request. Preferably, a unique verification file is generated by means of snowflake code sending, the generated unique verification file is used as the calling number of the micro-services to be called and stored in the redis, the expiration time of the verification file is set, and the value of the verification file is put into a message to call each service in a specified manner.
And S3, calling the micro-service according to the micro-service calling request, and inquiring the calling quantity of the micro-service by using the distributed lock polling. Preferably, when the time for calling the micro-service exceeds the expiration time, the calling is stopped, the micro-service calling failure is fed back, the current service is rolled back, and the corresponding verification file is deleted. Preferably, the polling query also needs a redis distributed lock, so as to avoid data inconsistency caused by different count values queried by a plurality of services.
And S4, when the micro-service calling number is empty, the corresponding calling of the verification file is overtime or the verification file is deleted by other services, the micro-service calling is failed in a feedback mode, the current service is rolled back, and the corresponding verification file is deleted.
And S5, when the micro-service calling number is not 0 or null, feeding back that the micro-service is successfully called, and subtracting 1 from the micro-service calling number in the verification file, preferably, ensuring single execution through a redis distributed lock, and avoiding simultaneous data change.
And S6, when the micro-service call number is 0, feeding back that all the services are successfully called and submitting the transaction, and simultaneously deleting the related distributed locks.
Preferably, the adopted redis distributed lock can introduce java daemon threads, and the safety of the distributed lock is guaranteed. On the other hand, when the method is actually executed, the submission and rollback of transactions can be controlled by using a dynamic proxy of jdk, a custom annotation and a spring transaction, so that the calling end can sense when the service makes an error. Meanwhile, as the distributed transaction lock of the redis is not absolutely reliable, the overtime time can be increased through the cycle of the daemon thread to increase the safety, or the distributed lock provided by zookeeper can be adopted.
Another aspect of the present invention also relates to a high-performance real-time consistent microservice execution system, whose structure is shown in fig. 2, including:
the interaction module is used for acquiring the micro-service calling request and feeding back a calling result;
the verification file management module is used for generating a verification file corresponding to the micro-service calling request;
and the query module is used for polling and querying and adjusting the micro-service calling quantity.
By using this system, the above-described arithmetic processing method can be executed and a corresponding technical effect can be achieved.
Embodiments of the present invention also provide a computer-readable storage medium capable of implementing all the steps of the method in the above embodiments, the computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements all the steps of the method in the above embodiments.
Embodiments of the present invention further provide an electronic device for executing the method, as an implementation apparatus of the method, the electronic device at least has a processor and a memory, and particularly, the memory stores data required for executing the method and related computer programs, such as an authentication file, and the like, and the processor calls the data and the programs in the memory to execute all steps of implementing the method, and obtains corresponding technical effects.
Preferably, the electronic device may comprise a bus architecture, which may include any number of interconnected buses and bridges linking together various circuits including one or more processors and memory. The bus may also link various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the receiver and transmitter. The receiver and transmitter may be the same element, i.e., a transceiver, providing a means for communicating with various other systems over a transmission medium. The processor is responsible for managing the bus and general processing, while the memory may be used for storing data used by the processor in performing operations.
Additionally, the electronic device may further include a communication module, an input unit, an audio processor, a display, a power source, and the like. The processor (or controller, operational controls) employed may include a microprocessor or other processor device and/or logic device that receives input and controls the operation of various components of the electronic device; the memory may be one or more of a buffer, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices, and may store the above-mentioned related data information, and may also store a program for executing the related information, and the processor may execute the program stored in the memory to realize information storage or processing, etc.; the input unit is used for providing input to the processor, and can be a key or a touch input device; the power supply is used for supplying power to the electronic equipment; the display is used for displaying display objects such as images and characters, and may be an LCD display, for example. The communication module is a transmitter/receiver that transmits and receives signals via an antenna. The communication module (transmitter/receiver) is coupled to the processor to provide an input signal and receive an output signal, which may be the same as in the case of a conventional mobile communication terminal. Based on different communication technologies, a plurality of communication modules, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, may be disposed in the same electronic device. The communication module (transmitter/receiver) is also coupled to a speaker and a microphone via an audio processor to provide audio output via the speaker and receive audio input from the microphone to implement the usual telecommunication functions. The audio processor may include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor is also coupled to the central processor, so that recording on the local machine can be realized through the microphone, and sound stored on the local machine can be played through the loudspeaker.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a system for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction system which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
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 changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. A high-performance real-time consistent micro-service execution method is characterized by comprising the following steps:
s1, acquiring a micro-service calling request;
s2, generating a verification file corresponding to the micro-service calling request, wherein the verification file comprises the micro-service calling quantity required by the corresponding micro-service calling request;
s3, calling the micro-service according to the micro-service calling request, and polling and inquiring the micro-service calling number;
s4, when the micro-service calling number is empty, feeding back that the micro-service calling fails;
and S5, when the micro-service calling number is not 0 or null, feeding back that the micro-service is successfully called, and subtracting 1 from the micro-service calling number in the verification file.
2. The method of claim 1, wherein the validation file further comprises an expiration time for a corresponding microservice invocation request.
3. The method of claim 2, wherein the step S3 further comprises:
and when the time for calling the micro service exceeds the expiration time, stopping calling and feeding back the failure of calling the micro service.
4. The method of claim 3, wherein the method further comprises:
and when the micro service is unsuccessfully called by feedback, rolling back the current service and deleting the corresponding verification file.
5. The method of claim 4, wherein the method further comprises:
and S6, when the micro-service calling number is 0, feeding back that all the services are successfully called.
6. The method of claim 5, wherein the step S3 further comprises:
the distributed lock is used when polling the number of microservice calls.
7. A high performance, real-time consistent microservice execution system, comprising:
the interaction module is used for acquiring the micro-service calling request and feeding back a calling result;
the verification file management module is used for generating a verification file corresponding to the micro-service calling request;
and the query module is used for polling and querying and adjusting the micro-service calling quantity.
8. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the method of any one of claims 1 to 6.
9. An electronic device comprising a processor and a memory;
the memory is used for storing the verification file;
the processor, configured to execute the method of any one of claims 1 to 6 by calling a verification file.
10. A computer program product comprising a computer program and/or instructions, characterized in that the computer program and/or instructions, when executed by a processor, implement the steps of the method of any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111541665.XA CN114237833A (en) | 2021-12-16 | 2021-12-16 | High-performance real-time consistent micro-service execution method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111541665.XA CN114237833A (en) | 2021-12-16 | 2021-12-16 | High-performance real-time consistent micro-service execution method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114237833A true CN114237833A (en) | 2022-03-25 |
Family
ID=80756994
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111541665.XA Pending CN114237833A (en) | 2021-12-16 | 2021-12-16 | High-performance real-time consistent micro-service execution method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114237833A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117331675A (en) * | 2023-11-27 | 2024-01-02 | 云筑信息科技(成都)有限公司 | Graceful start-stop method in micro service |
-
2021
- 2021-12-16 CN CN202111541665.XA patent/CN114237833A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117331675A (en) * | 2023-11-27 | 2024-01-02 | 云筑信息科技(成都)有限公司 | Graceful start-stop method in micro service |
CN117331675B (en) * | 2023-11-27 | 2024-03-26 | 云筑信息科技(成都)有限公司 | Graceful start-stop method in micro service |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020259354A1 (en) | Queue adjustment method, apparatus and device, and computer-readable storage medium | |
CN112615753B (en) | Link abnormity tracking method, first node, second node and link | |
WO2021248477A1 (en) | Central control system for multimedia exhibition hall, and control method and apparatus for same | |
CN111897738B (en) | Automatic testing method and device based on atomic service | |
CN111352719B (en) | Transaction bookkeeping service data processing method, device and system | |
CN114237833A (en) | High-performance real-time consistent micro-service execution method and system | |
US8719622B2 (en) | Recording and preventing crash in an appliance | |
CN105095727A (en) | Device administrator permission application method, server and system | |
CN111930624B (en) | Test link message data processing method and device | |
CN114285657B (en) | Firewall security policy change verification method and device | |
CN115562898A (en) | Distributed payment system exception handling method and device | |
CN114595081A (en) | Response type RPC calling method and system based on cache storage | |
CN113158259A (en) | Block chain integrity verification method and device | |
CN113434423A (en) | Interface test method and device | |
CN112734360A (en) | End-to-end business process management method, device, equipment and storage medium | |
CN113190338A (en) | Method, device and system for processing service data | |
CN115021938B (en) | Secure digital certificate application method and apparatus | |
CN111679930B (en) | Single-point rollback method and system for CICS online transaction | |
CN116932222A (en) | Low-coupling parallel financial data processing method and system | |
CN115510158A (en) | Method and system for synchronizing data of bank industry | |
CN117807037A (en) | Batch number supply method and device based on database client | |
CN111885148B (en) | Session synchronization method and device | |
CN116560751A (en) | Dynamic menu loading method and system based on user | |
CN117459375A (en) | Log level dynamic adjustment method and system under distributed cluster | |
CN117291608A (en) | Transaction request verification method and system based on hierarchical asynchronous execution |
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 |