CN116820791A - Parallel computing method and system based on Feign asynchronous call - Google Patents

Parallel computing method and system based on Feign asynchronous call Download PDF

Info

Publication number
CN116820791A
CN116820791A CN202310930157.3A CN202310930157A CN116820791A CN 116820791 A CN116820791 A CN 116820791A CN 202310930157 A CN202310930157 A CN 202310930157A CN 116820791 A CN116820791 A CN 116820791A
Authority
CN
China
Prior art keywords
parallel
feign
interface
parallel computing
creating
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
CN202310930157.3A
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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN202310930157.3A priority Critical patent/CN116820791A/en
Publication of CN116820791A publication Critical patent/CN116820791A/en
Pending legal-status Critical Current

Links

Abstract

The application discloses a parallel computing method and a system based on Feign asynchronous call, wherein the method comprises the following steps: creating a service acceptance external interface; creating a business step processing unit interface; creating an @ FeignClient interface; and asynchronously calling the Feign method to realize the parallel calculation of the business step processing unit and receiving the parallel processing result. Compared with the traditional parallel computing framework, the application can reduce development and maintenance cost; enhancing code readability; and the usability and expansibility of the system are improved.

Description

Parallel computing method and system based on Feign asynchronous call
Technical Field
The application relates to the technical field of computers, in particular to a parallel computing method and system based on Feign asynchronous call.
Background
Traditional parallel computing implementations typically include the following steps: creating a parallel task processing class which inherits from the recurseveltask class; a computer () method in the task processing class is rewritten; creating an implementation method for each parallel execution unit in the computer () method; creating a task object for each parallel execution unit in the computer () method; arranging a parallel processing flow (invokeAll, join) in the computer () method; creating parallel task processing class objects (class objects of step 1) in a main service main flow; creating a ForkJoinPool object in a main service main flow to execute parallel computing tasks; parallel computing results are received and processed using parallel task processing class objects. Therefore, the traditional parallel computing implementation generally adopts Fork/Join to start parallel computing, and the implementation generally needs to add a large amount of parallel computing related codes on the basis of the original service implementation, so that the readability of the code of the originally clear service logic implementation is poor, and the development and maintenance cost of the system is greatly increased, so that an optimized and improved parallel computing method and system are needed.
Disclosure of Invention
The application discloses a parallel computing method based on Feign asynchronous call, which comprises the following steps:
creating a service acceptance external interface;
creating a business step processing unit interface;
creating an @ FeignClient interface;
the asynchronous call Feign method realizes the parallel calculation of the business step processing unit and receives the parallel processing result.
And the service acceptance external interface realizes a service function by the parallel step processing unit processing function.
The annotation information of the @ FeignClient interface comprises an entry address of a business step processing unit.
Further, the asynchronous call Feign method includes:
importing relevant dependencies;
writing the @ FeignClient interface;
and adding @ EnableFeignClients annotation in the program environment starting class, and starting Feign remote call.
Further, the parallel computing service step processing unit starts parallel computing by adopting a completyieFuture.
Further, the parallel processing result of the receiving parallel computing service step processing unit adopts a completyif uture.
On the other hand, the application adopts another technical scheme that: there is provided a Feign asynchronous call-based parallel computing system, the system comprising: RESTful module: exposing the processing function of the parallel business step processing unit as an external interface; feign module: creating an @ FeignClient interface, asynchronously calling a Feign method to start parallel computation for service step processing in service processing, and receiving a parallel processing result.
Further, the system also comprises a business step processing parallel execution unit, wherein the parallel execution unit starts parallel computation by adopting a completeFuture.supplyasync () method for acquiring parallel computation threads and starts parallel computation, and the unit adopts a completeFuture.join () method for receiving parallel processing results.
Further, the application also includes a server, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the method when executing the computer program;
still further, the present application also includes a computer readable storage medium storing a computer program and applied to a server, the computer program implementing the above method when executed by a processor.
Compared with the prior art, the application has at least the following advantages and positive effects:
1. the development and maintenance cost is reduced;
2. enhancing code readability;
3. and the usability and expansibility of the system are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. Like elements or portions are generally identified by like reference numerals throughout the several figures. In the drawings, elements or portions thereof are not necessarily drawn to scale.
FIG. 1 is a flow chart of a process provided by an embodiment that does not employ parallel computing.
FIG. 2 is a flow chart of a process employing conventional parallel computing, according to an embodiment.
FIG. 3 is a flow chart of a process for parallel computing using Feign asynchronous calls, as provided by an embodiment.
Description of the embodiments
Embodiments of the technical scheme of the present application will be described in detail below with reference to the accompanying drawings. The following examples are only for more clearly illustrating the technical aspects of the present application, and thus are merely examples, and are not intended to limit the scope of the present application. It is noted that unless otherwise indicated, technical or scientific terms used herein should be given the ordinary meaning as understood by one of ordinary skill in the art to which this application belongs.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
As used in this specification and the appended claims, the term "if" may be interpreted in context as "when … …" or "upon" or "in response to a determination" or "in response to detection. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Examples
Assuming that a certain business process comprises business steps 1-5, 5 business step processes in total, each business step process needs 0.2 seconds to be executed, wherein business steps 1, 2 and 3 can be parallel, and business steps 4 and 5 can be parallel but the execution result of step 2 is needed to be depended on.
In this embodiment, the non-parallel conventional service processing method is adopted in fig. 1, so that service logic is clear, but the whole service processing needs 1.0 second to complete, which takes the longest time, and may not meet the requirements in a scene of high concurrency and low delay.
In this embodiment, fig. 2 adopts a traditional parallel computing framework to perform service processing, and the whole service processing requires 0.4 seconds, so that service response timeliness is greatly improved; however, a large number of parallel computing implementation codes are added in the method, the service processing logic implementation is required to be migrated to the newly created parallel task processing class, and the specific content and implementation logic of service execution cannot be seen in the service processing main flow, so that the readability of the originally clear service logic implementation codes is poor, and the development and maintenance cost of the system is greatly increased.
In this embodiment, fig. 3 adopts a Feign asynchronous call parallel computing method to perform service processing, and the whole service processing needs 0.4 seconds to complete, so that service response timeliness is greatly improved; the implementation method comprises the following steps: starting a parallel business step by adopting a supplyAsync () method of a completyieldeFuse class to carry out parallel calculation, synchronizing a processing and executing result of the parallel business step by adopting a join () method of the completyieldeFuse class, and realizing distributed high availability by calling a Feign interface by adopting the execution content of the parallel business step; the implementation method has the advantages of simple code, clear logic and convenient expansion, and the execution steps ensure the high availability of the system through the Feign interface call.

Claims (11)

1. The parallel computing method based on the Feign asynchronous call comprises a business main program and a parallel step processing unit processing function, and is characterized by comprising the following steps:
creating a service acceptance external interface;
creating a business step processing unit interface;
creating an @ FeignClient interface;
the asynchronous call Feign method realizes the parallel calculation of the business step processing unit and receives the parallel processing result.
2. The method of claim 1, wherein the service acceptance external interface implements a service function by the parallel step processing unit processing function.
3. The method of claim 1, wherein the annotation information of the @ FeignClient interface comprises an entry address of a business step processing unit.
4. The method of claim 1, wherein the asynchronously invoking the Feign method comprises:
importing relevant dependencies;
writing the @ FeignClient interface;
and adding @ EnableFeignClients annotation in the program environment starting class, and starting Feign remote call.
5. The method of claim 1, wherein the parallel computing step unit in the pair of business processes turns on parallel computing using a completeFuture.
6. The method of claim 5, wherein the call completeFuture. Supplyasync () method is used to fetch parallel computing threads and turn on parallel computing.
7. The method of claim 1, wherein the receiving of the parallel computing step processing results in the business process employs a completionf.
8. A Feign asynchronous call-based parallel computing system, comprising:
RESTful module: exposing the parallel execution unit processing functions as external interfaces;
feign module: creating an @ FeignClient interface, asynchronously calling a Feign method to realize parallel calculation of service steps in service processing, and receiving a parallel processing result.
9. The system of claim 8, further comprising a parallel execution unit that turns on parallel computation using a completeFuture.supplyasync () method and receives a parallel computation processing result using a completeFuture.join () method.
10. A server comprising a memory, a processor and a computer program stored in the server and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 9 when executing the computer program.
11. A computer readable storage medium storing a computer program and applied to a server, wherein the computer program when executed by a processor implements the method of any one of claims 1 to 9.
CN202310930157.3A 2023-07-27 2023-07-27 Parallel computing method and system based on Feign asynchronous call Pending CN116820791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310930157.3A CN116820791A (en) 2023-07-27 2023-07-27 Parallel computing method and system based on Feign asynchronous call

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310930157.3A CN116820791A (en) 2023-07-27 2023-07-27 Parallel computing method and system based on Feign asynchronous call

Publications (1)

Publication Number Publication Date
CN116820791A true CN116820791A (en) 2023-09-29

Family

ID=88112848

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310930157.3A Pending CN116820791A (en) 2023-07-27 2023-07-27 Parallel computing method and system based on Feign asynchronous call

Country Status (1)

Country Link
CN (1) CN116820791A (en)

Similar Documents

Publication Publication Date Title
CN110865888B (en) Resource loading method and device, server and storage medium
US9336001B2 (en) Dynamic instrumentation
CN110806923A (en) Parallel processing method and device for block chain tasks, electronic equipment and medium
US20090328005A1 (en) Debugger call stack caching
EP2839369B2 (en) Information processing device and method for protecting data in a call stack
US8769233B2 (en) Adjusting the amount of memory allocated to a call stack
CN110297955B (en) Information query method, device, equipment and medium
CN113835854A (en) Task processing method and device
CN111966508A (en) Message batch sending method and device, computer equipment and storage medium
CN112256421A (en) Communication processing method, communication processing device, storage medium and electronic equipment
CN116820791A (en) Parallel computing method and system based on Feign asynchronous call
CN111429140B (en) Method and device for realizing atomicity of multi-level intelligent contract stack
CN114647411A (en) Programming interface loading method and device, electronic equipment and storage medium
US8359602B2 (en) Method and system for task switching with inline execution
CN113407325A (en) Video rendering method and device, computer equipment and storage medium
US20210191867A1 (en) Hardware Accelerator Automatic Detection of Software Process Migration
CN113032118A (en) Asynchronous operation processing method for computer application program and corresponding system
CN111416863A (en) Diversified download management method, terminal and medium based on client
CN111124627A (en) Method, device, terminal and storage medium for determining application program caller
US20240094992A1 (en) Non-disruptive servicing components of a user mode process
CN110765098B (en) Flow operation prediction system and method
CN113742096B (en) Method and system for realizing event queue
CN111522600B (en) Heterogeneous computing framework construction method and system on DSP
US20240078141A1 (en) Method and system for event topic checkpointing
CN114816433A (en) Encoding method, system, device and medium in project based on asynchronous programming

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication