Control method, device, equipment and storage medium based on algorithm service platform
By introducing decoupling interaction between the message queue layer and the algorithm engine layer in the algorithm service platform, the active task acquisition and result synchronization of the algorithm engine is realized, solving the problems of frequent configuration changes and load imbalance in the existing technology, and improving data Processing efficiency.
Patent Information
- Application Number
- CN202210040552.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-01-14
AI Technical Summary
The existing algorithm service platform changes frequently during horizontal expansion/decrease capacity, and the load balancing strategy causes request processing to take a long time, low efficiency, and unbalanced load.
The decoupling interaction between the message queue layer and the algorithm engine layer is adopted. The algorithm engine actively monitors and acquires tasks, and uses the message queue layer to perform task allocation and result synchronization to avoid frequent configuration changes and load balancing problems.
It improves data processing efficiency, simplifies system management, and solves the problems of long and low-efficiency processing requests caused by traditional load balancing strategies.
Smart Images

Figure CN114490122B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and digital medical technology, and in particular to a control method, device, equipment and storage medium based on an algorithm service platform. Background Art
[0002] The algorithm service platform generally consists of two parts: the web service platform layer and the algorithm engine layer. The web service platform integrates various algorithm services (for example, OCR document recognition, face recognition, vehicle damage assessment, etc.) and provides an http interface for users to call. Each algorithm service has a different http interface address. Users can get results of different algorithm capabilities by calling different http interfaces.
[0003] The existing web service platform is highly coupled with each algorithm service. The algorithm service itself is also an http / rpc service. The web service platform calls the backend algorithm service through http / rpc combined with load balancing (usually using nginx). If a certain algorithm capability of this algorithm service system needs to be horizontally expanded / reduced, it is necessary to configure load balancing to include the newly expanded engine. It is cumbersome and not very flexible. Frequent expansion / reduction leads to frequent configuration changes, which is not easy to manage and roll back. In addition, the load balancing strategy is not practical. Common load balancing includes polling, minimum connection, etc. If some request algorithms take longer than expected, it is easy to cause an imbalance in the load of each engine. Summary of the invention
[0004] The present invention provides a control method, device, equipment and storage medium based on an algorithm service platform, which can decouple message queues, improve data processing efficiency, and solve the problems of long processing time and low efficiency of request processing caused by traditional load balancing strategies.
[0005] In order to solve the above technical problems, a technical solution adopted by the present invention is: to provide a control method based on an algorithm service platform, comprising:
[0006] Constructing an algorithm service platform, the algorithm service platform comprising a Web service layer, a message queue layer and an algorithm engine layer, the message queue layer comprising a plurality of message lists, the algorithm engine layer comprising a plurality of algorithm engines, and establishing a connection between each of the algorithm engines and the message lists of the same algorithm type;
[0007] Control the algorithm engine layer to actively send a request to obtain a task to the message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list;
[0008] If the algorithm task exists in the message list, control the message queue layer to send the algorithm task to the algorithm engine layer;
[0009] If the algorithm task does not exist in the message list, the algorithm engine layer is controlled to continuously monitor the message list until the algorithm task is acquired.
[0010] According to an embodiment of the present invention, the control algorithm engine layer actively sends a request to obtain a task to the message list of the same algorithm type and monitors in real time whether there is an algorithm task in the message list, and further includes:
[0011] Control the algorithm engine layer to monitor in real time the status of each algorithm engine executing the previous algorithm task;
[0012] When the algorithm engine layer detects that the algorithm engine has completed executing the previous algorithm task, the algorithm engine layer is controlled to actively send a request to obtain the task to the message queue layer;
[0013] After receiving the task acquisition request, the message queue layer controls the message queue layer to acquire the algorithm type from the task acquisition request, determines a message list with the same algorithm type as a target message list, and detects whether there is a new algorithm task in the target message list.
[0014] According to one embodiment of the present invention, if the message list does not contain the algorithm task, the method further includes:
[0015] Control the message queue layer to detect whether a new algorithm task is added to the message list within a preset time threshold;
[0016] If a new algorithm task is added to the message list within the preset time threshold, the message queue layer is controlled to give the new algorithm task to the algorithm engine layer.
[0017] According to an embodiment of the present invention, after controlling the message queue layer to detect whether a new algorithm task is added to the message list within a preset time threshold, the method further includes:
[0018] If no new algorithm task is added to the message list within the preset time threshold, the message list of the message queue layer is controlled to send a preset message to the algorithm engine layer.
[0019] According to an embodiment of the present invention, if a new algorithm task is added to the message list within the preset time threshold, before controlling the message queue layer to give the new algorithm task to the algorithm engine layer, the method includes:
[0020] After the message queue layer receives the algorithm task request sent by the Web service layer, it controls the message queue layer to create a corresponding key-value pair according to the algorithm task request, and adds the algorithm task carried in the algorithm task request to the message list with the same algorithm type. The algorithm task request carries the algorithm task and algorithm type.
[0021] According to an embodiment of the present invention, the controlling the message queue layer to send the algorithm task to the algorithm engine layer, or the controlling the algorithm engine layer to continuously monitor the message list until the algorithm task is obtained, further includes:
[0022] After the algorithm engine layer receives the algorithm task, it controls the algorithm engine layer to execute the algorithm task and generate a calculation result, and sends the calculation result to the message queue layer.
[0023] According to an embodiment of the present invention, after the algorithm engine layer receives the algorithm task, it controls the algorithm engine layer to execute the algorithm task and generate a calculation result, and sends the calculation result to the message queue layer, and further includes:
[0024] After receiving the calculation result, the message queue layer controls the message queue layer to update the key-value pair according to the calculation result and synchronizes the updated key-value pair to the Web service layer.
[0025] In order to solve the above technical problems, another technical solution adopted by the present invention is: to provide a control device based on an algorithm service platform, comprising:
[0026] A construction module is used to construct an algorithm service platform, wherein the algorithm service platform includes a Web service layer, a message queue layer, and an algorithm engine layer, wherein the message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines, and establishes a connection between each of the algorithm engines and the message lists of the same algorithm type;
[0027] A processing module, used to control the algorithm engine layer to actively send a request to obtain a task to the message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list;
[0028] A first judgment module, configured to control the message queue layer to send the algorithm task to the algorithm engine layer if the algorithm task exists in the message list;
[0029] The second judgment module is used to control the algorithm engine layer to continuously monitor the message list until the algorithm task is obtained if the algorithm task does not exist in the message list.
[0030] In order to solve the above technical problems, another technical solution adopted by the present invention is: to provide a computer device, including: a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the control method based on the algorithm service platform when executing the computer program.
[0031] In order to solve the above technical problems, another technical solution adopted by the present invention is: providing a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above control method based on the algorithm service platform is implemented.
[0032] The beneficial effects of the present invention are as follows: through the interaction between the message queue layer and the algorithm engine layer, each algorithm engine is decoupled, and there is no need to frequently change the system configuration when modifying the algorithm engine layer, which facilitates system management; the algorithm engine is converted from the traditional passive reception of algorithm tasks to active monitoring and acquisition of algorithm tasks, which improves data processing efficiency and solves the problem of long processing request time and low efficiency caused by traditional load balancing strategies. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a flow chart of a control method based on an algorithm service platform according to a first embodiment of the present invention;
[0034] Figure 2 It is a structural diagram of the algorithm service platform in an embodiment of the present invention;
[0035] Figure 3 is a flow chart of a control method based on an algorithm service platform according to a second embodiment of the present invention;
[0036] Figure 4 is a flow chart of a control method based on an algorithm service platform according to a third embodiment of the present invention;
[0037] Figure 5 is a schematic diagram of the structure of a control device of an algorithm service platform according to an embodiment of the present invention;
[0038] Figure 6 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention;
[0039] Figure 7 It is a schematic diagram of the structure of a computer storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The terms "first", "second" and "third" in the present invention are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" can explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. All directional indications (such as up, down, left, right, front, back...) in the embodiments of the present invention are only used to explain the relative position relationship, movement, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication also changes accordingly. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0042] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0043] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0044] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0045] Figure 1 is a flow chart of a control method based on an algorithm service platform according to a first embodiment of the present invention. It should be noted that if there are substantially the same results, the method of the present invention is not limited to Figure 1 The process sequence shown is limited. Figure 1 As shown, the method comprises the steps of:
[0046] Step S101: construct an algorithm service platform, which includes a Web service layer, a message queue layer and an algorithm engine layer. The message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines. Establish a connection between each algorithm engine and a message list of the same algorithm type.
[0047] In step S101, Figure 2 As shown, the algorithm service platform 100 includes a Web service layer 10, a message queue layer 20 connected to the Web service layer 10 via a network, and an algorithm engine layer 30 connected to the message queue layer 20 via a network.
[0048] Among them, the Web service layer 10 is used to receive and forward the algorithm task request sent by the client, and the algorithm task request carries the algorithm task; the message queue layer 20 is used to receive the algorithm task request sent by the Web service layer 10 and create the corresponding key-value pair, and receive the task acquisition request sent by the algorithm engine layer 30 and send the algorithm task to the algorithm engine layer 30 according to the task acquisition request, and the key-value pair is used to store the calculation result of the algorithm task executed by the algorithm engine layer 30; the algorithm engine layer 30 is used to send the task acquisition request to the message queue layer 20 to obtain the algorithm task, execute the algorithm task after obtaining the algorithm task, generate the calculation result and feed the calculation result back to the message queue layer 20.
[0049] In an achievable implementation, the algorithm task request carries the algorithm type, and the message queue layer 20 includes a plurality of message lists for storing the algorithm tasks. The message lists correspond to the algorithm types one by one. After receiving the algorithm task request, the message queue layer 20 adds the algorithm task to the message list with the same algorithm type according to the algorithm type. For example, the algorithm types include OCR document recognition, face recognition, vehicle damage assessment, etc., and the message list includes OCR document recognition message list, face recognition message list, and vehicle damage assessment message list. When the algorithm type carried by the algorithm task request is face recognition, the algorithm task request is added to the face recognition message list.
[0050] In an achievable implementation, the algorithm engine layer 30 includes multiple algorithm engines with different algorithm types, and each algorithm engine is connected to a message list of the same algorithm type. For example, the algorithm engine layer 30 includes an OCR document recognition algorithm engine, a face recognition algorithm engine, a vehicle damage assessment algorithm engine, etc., wherein the OCR document recognition algorithm engine is connected to the OCR document recognition message list, the face recognition algorithm engine is connected to the face recognition message list, and the vehicle damage assessment algorithm engine is connected to the vehicle damage assessment message list. Each algorithm engine will actively send a request to obtain a task to the corresponding message list, and actively monitor whether there is an algorithm task in the corresponding message list. When there is an algorithm task in the message list, the algorithm task is obtained.
[0051] In one embodiment, the algorithm service platform can be expanded / reduced horizontally according to actual needs. In application scenarios that require expansion, it is only necessary to establish a connection between the newly added algorithm engine and the message queue layer 20, that is, to connect the newly added algorithm engine to the corresponding message list in the message queue layer 20; in application scenarios that require reduction, it is only necessary to disconnect the algorithm engine from the message queue layer 20, that is, to disconnect the algorithm engine from the corresponding message list. In the expansion / reduction scenario, it refers to increasing / decreasing the number of algorithm engines with existing algorithm capabilities. This method does not require changing the configuration of the message queue layer 20 and is easy to manage the algorithm service platform.
[0052] In this embodiment, the message queue layer 20 processes the acquisition task request in a serial execution manner, that is, first come first served, and after processing the current acquisition task request, the next acquisition task request is processed to avoid the problem of resource preemption. After receiving the acquisition task request, the message list will automatically detect whether there is an algorithm task in the message list. If so, the algorithm task is sent to the corresponding algorithm engine in response to the acquisition task request; if not, it will wait for a new algorithm task to be added to the message list within the preset time threshold range, and then send the algorithm task to the corresponding algorithm engine; or return to null after exceeding the preset time threshold, and then continue to detect whether there is an algorithm task in the target message list until the algorithm task is acquired.
[0053] For example, the message queue layer 20 can adopt solutions such as redis, kafka, rocketMQ, etc., and redis is used as the message queue layer 20 for explanation. The algorithm engine actively sends a task acquisition request to redis, and redis processes the task acquisition request serially. In one embodiment, when the algorithm engine sends a redis blpop command to redis, the command can obtain an algorithm task from the message list specified by redis. If there is no algorithm task in the message list, it will block and wait until it times out or the algorithm task can be obtained. In another embodiment, when the algorithm engine sends a redis lpop command to redis, the command is the same as the redis blpop command, but if there is no algorithm task in the message list, it returns empty, and then continues to detect whether there is an algorithm task in the message list until the algorithm task is obtained.
[0054] After obtaining the algorithm task, the algorithm engine executes the algorithm task, generates the calculation result and feeds the calculation result back to the message queue layer 20. The message queue layer 20 updates the key-value pair according to the calculation result. The Web service layer 10 monitors the key-value pair in real time. When the key-value pair changes, the key-value pair is obtained to respond to the algorithm task request. Furthermore, if the Web service layer 10 fails to obtain the calculation result after exceeding the preset time threshold, the message of algorithm processing failure is fed back to the client.
[0055] The algorithm service platform 100 of the embodiment of the present invention decouples the various algorithm engines in the algorithm engine layer 30 through the setting of the message queue layer 20. There is no need to frequently change the system configuration when modifying the algorithm engine layer 30, which facilitates system management; the algorithm engine is converted from the traditional passive reception of algorithm tasks to active monitoring and acquisition of algorithm tasks, which improves data processing efficiency and solves the problem of long processing request time and low efficiency caused by traditional load balancing strategies.
[0056] Step S102: Control the algorithm engine layer to actively send a request to obtain a task to a message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list.
[0057] In step S102, the algorithm engine actively sends a request to obtain a task, and actively monitors whether there is an algorithm task in the message list. In this embodiment, the algorithm engine is converted from the traditional passive reception of algorithm tasks to active monitoring and acquisition of algorithm tasks, which improves the data processing efficiency and solves the problem of long processing time and low efficiency caused by the traditional load balancing strategy. In one embodiment, each algorithm engine adopts the method of active monitoring and preemptive acquisition of tasks, that is, each algorithm engine can continue to monitor the corresponding message list to obtain algorithm tasks after processing the current algorithm task. Whoever is free can obtain it, avoiding the problem of load imbalance. Specifically, the algorithm engine layer monitors the status of each algorithm engine executing the previous algorithm task in real time; when the algorithm engine layer detects that the algorithm engine has completed the execution of the previous algorithm task, the algorithm engine layer is controlled to actively send a request to obtain a task to the message queue layer; after the message queue layer receives the request to obtain a task, the message queue layer is controlled to obtain the algorithm type from the request to obtain a task, and the message list with the same algorithm type is determined as the target message list and detects whether there is a new algorithm task in the target message list. The message list of this embodiment is set in a one-to-one correspondence with the algorithm type. The algorithm engine actively sends a task acquisition request to the message queue layer. The task acquisition request carries the name of the message list, which can be understood as determining the message list of the same algorithm type as the task acquisition request as the target message list, and the target message list is connected to the algorithm engine; for example, the task acquisition request sent by the face recognition algorithm engine, the corresponding target message list is the face recognition message list.
[0058] The algorithm engine of this embodiment uses active monitoring to obtain algorithm tasks from the message list. Each algorithm engine can continue to monitor the corresponding message list to obtain algorithm tasks only after executing the current algorithm task. That is, whoever is free can obtain it, avoiding the problem of load imbalance. Compared with the solution of using a load balancer to manage multiple algorithm engines, this embodiment does not need to issue algorithm tasks according to the load capacity of the algorithm engine. The algorithm engine changes from passively receiving algorithm tasks to actively monitoring their respective message lists and actively obtaining algorithm tasks, thus realizing the decoupling of message queues.
[0059] Step S103: If the message list contains an algorithm task, the message queue layer is controlled to send the algorithm task to the algorithm engine layer.
[0060] Step S104: If the algorithm task does not exist in the message list, the algorithm engine layer is controlled to continuously monitor the message list until the algorithm task is obtained.
[0061] In step S104, if there is no algorithm task in the message list, the algorithm engine cannot obtain a new algorithm task and is always in an idle state, and will continue to monitor the corresponding message list.
[0062] The control method based on the algorithm service platform of the first embodiment of the present invention decouples each algorithm engine through the interaction between the message queue layer and the algorithm engine layer. There is no need to frequently change the system configuration when modifying the algorithm engine layer, which facilitates system management; the algorithm engine is converted from the traditional passive reception of algorithm tasks to active monitoring and acquisition of algorithm tasks, which improves data processing efficiency and solves the problem of long processing request time and low efficiency caused by traditional load balancing strategies.
[0063] Figure 3 is a flow chart of a control method based on an algorithm service platform according to a second embodiment of the present invention. It should be noted that if there are substantially the same results, the method of the present invention is not limited to Figure 3 The process sequence shown is limited. Figure 3 As shown, the method comprises the steps of:
[0064] Step S301: Build an algorithm service platform, which includes a Web service layer, a message queue layer and an algorithm engine layer. The message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines. Establish a connection between each algorithm engine and a message list of the same algorithm type.
[0065] In this embodiment, Figure 3 Step S301 and Figure 1 The process is similar to step S101 in , and for the sake of brevity, it will not be repeated here.
[0066] Step S302: Control the algorithm engine layer to actively send a task acquisition request to a message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list.
[0067] In this embodiment, Figure 3 Step S302 and Figure 1 The process is similar to step S102 in , and will not be described again for the sake of brevity.
[0068] Step S303: If the algorithm task exists in the message list, the message queue layer is controlled to send the algorithm task to the algorithm engine layer.
[0069] In this embodiment, Figure 3 Step S303 and Figure 1 The process is similar to step S103 in , and will not be described again for the sake of brevity.
[0070] Step S304: If there is no algorithm task in the message list, the message queue layer is controlled to detect whether there is a new algorithm task added to the message list within a preset time threshold.
[0071] If there is no algorithm task in the message list, wait for a new algorithm task to be added to the target message list within the preset time threshold. In this embodiment, if a new algorithm task is added to the message list within the preset time threshold, step S305 is executed; if no new algorithm task is added to the message list within the preset time threshold, step S306 is executed.
[0072] Step S305: If a new algorithm task is added to the message list within the preset time threshold, the message queue layer is controlled to give the new algorithm task to the algorithm engine layer.
[0073] Step S306: If no new algorithm task is added to the message list within the preset time threshold, the message list is controlled to send a preset message to the algorithm engine layer.
[0074] This embodiment returns "null" after exceeding the preset time threshold, and continues to detect whether there is an algorithm task in the target message list until an algorithm task is detected.
[0075] The control method based on the algorithm service platform of the second embodiment of the present invention is based on the first embodiment. By monitoring the target message list in real time to see if there is an algorithm task when the algorithm engine is idle, the new algorithm task can be immediately acquired as soon as a new algorithm task is added. This can transform the algorithm engine from the traditional passive reception of algorithm tasks to active monitoring and acquisition of algorithm tasks, thereby improving data processing efficiency and solving the problem of long processing request time and low efficiency caused by traditional load balancing strategies.
[0076] Figure 4 is a flow chart of a control method based on an algorithm service platform according to a third embodiment of the present invention. It should be noted that if there are substantially the same results, the method of the present invention is not limited to Figure 4 The process sequence shown is limited. Figure 4 As shown, the method comprises the steps of:
[0077] Step S401: Build an algorithm service platform, which includes a Web service layer, a message queue layer and an algorithm engine layer. The message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines. Establish a connection between each algorithm engine and a message list of the same algorithm type.
[0078] In this embodiment, Figure 4 Step S401 and Figure 3 The process is similar to step S301 in , and for the sake of brevity, it will not be repeated here.
[0079] Step S402: Control the algorithm engine layer to actively send a request to obtain a task to a message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list.
[0080] In this embodiment, Figure 4 Step S402 and Figure 3 The process is similar to step S302 in , and will not be described again for the sake of brevity.
[0081] Step S403: If the algorithm task exists in the message list, the message queue layer is controlled to send the algorithm task to the algorithm engine layer.
[0082] In this embodiment, steps S408 and S409 are executed after step S403.
[0083] Step S404: If there is no algorithm task in the message list, the message queue layer is controlled to detect whether there is a new algorithm task added to the message list within a preset time threshold.
[0084] In this embodiment, Figure 4 Step S404 and Figure 3 The process is similar to step S304 in , and will not be described again for the sake of brevity.
[0085] Step S405: After receiving the algorithm task request sent by the Web service layer, the message queue layer controls the message queue layer to create a corresponding key-value pair according to the algorithm task request, and adds the algorithm task carried in the algorithm task request to the message list with the same algorithm type.
[0086] The Web service layer of this embodiment receives and forwards the algorithm task request sent by the client, which carries the algorithm task and algorithm type. The information queue layer receives the algorithm task request sent by the Web service layer and creates a corresponding key-value pair, which is used to store the calculation results of the algorithm task executed by the algorithm engine layer.
[0087] Step S406: If a new algorithm task is added to the message list within the preset time threshold, the message queue layer is controlled to give the new algorithm task to the algorithm engine layer.
[0088] In this embodiment, after step S406, steps S408 and S409 are executed.
[0089] Step S407: If no new algorithm task is added to the message list within the preset time threshold, the message list is controlled to send a preset message to the algorithm engine layer.
[0090] In this embodiment, Figure 4 Step S407 and Figure 3 The process is similar to step S306 in , and will not be described again for the sake of brevity.
[0091] Step S408: After the algorithm engine layer receives the algorithm task, it controls the algorithm engine layer to execute the algorithm task and generate calculation results, and sends the calculation results to the message queue layer.
[0092] Step S409: After receiving the calculation result, the message queue layer controls the message queue layer to update the key-value pair according to the calculation result and synchronizes the updated key-value pair to the Web service layer.
[0093] The message queue layer updates the key-value pairs according to the calculation results, and the Web service layer monitors the key-value pairs in real time. When the key-value pairs change, the key-value pairs are obtained to respond to the algorithm task request.
[0094] The control method based on the algorithm service platform of the third embodiment of the present invention decouples each algorithm engine through the interaction between the message queue layer and the algorithm engine layer on the basis of the second embodiment, and at the same time feeds back the results of the algorithm engine layer executing the algorithm task through key-value pairs, thereby simplifying the data structure and effectively improving data processing efficiency.
[0095] Figure 5 Schematic diagram of the structure of the control device based on the algorithm service platform in the embodiment of the present invention. Figure 5 As shown, the device 50 includes a construction module 51 , a processing module 52 , a first judgment module 53 and a second judgment module 54 .
[0096] The construction module 51 is used to construct an algorithm service platform, which includes a Web service layer, a message queue layer and an algorithm engine layer. The message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines, and establishes a connection between each algorithm engine and a message list of the same algorithm type;
[0097] The processing module 52 is used to control the algorithm engine layer to actively send a request to obtain a task to a message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list;
[0098] The first judgment module 53 is used to control the message queue layer to send the algorithm task to the algorithm engine layer if the message list has an algorithm task;
[0099] The second judgment module 54 is used to control the algorithm engine layer to continuously monitor the message list until the algorithm task is obtained if the algorithm task does not exist in the message list.
[0100] See also Figure 6 , Figure 6 FIG. 1 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Figure 6 As shown, the computer device 60 includes a processor 61 and a memory 62 coupled to the processor 61 .
[0101] The memory 62 stores program instructions for implementing the control method based on the algorithm service platform described in any of the above embodiments.
[0102] The processor 61 is used to execute program instructions stored in the memory 62 to control the algorithm service platform.
[0103] The processor 61 may also be referred to as a CPU (Central Processing Unit). The processor 61 may be an integrated circuit chip having the ability to process signals. The processor 61 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0104] See also Figure 7 , Figure 7 Schematic diagram of the structure of the computer storage medium of the embodiment of the present invention. The computer storage medium of the embodiment of the present invention stores a program file 71 capable of implementing all the above methods, wherein the program file 71 can be stored in the above computer storage medium in the form of a software product, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned computer storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or terminal devices such as a computer, a server, a mobile phone, and a tablet.
[0105] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0106] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0107] The above are only implementation modes of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A control method based on an algorithm service platform, characterized in that: include: Constructing an algorithm service platform, the algorithm service platform comprising a Web service layer, a message queue layer and an algorithm engine layer, the message queue layer comprising a plurality of message lists, the algorithm engine layer comprising a plurality of algorithm engines, and establishing a connection between each of the algorithm engines and the message lists of the same algorithm type; Control the algorithm engine layer to actively send a request to obtain a task to the message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list; If the algorithm task exists in the message list, control the message queue layer to send the algorithm task to the algorithm engine layer; If the algorithm task does not exist in the message list, controlling the algorithm engine layer to continuously monitor the message list until the algorithm task is obtained; The control algorithm engine layer actively sends a request to obtain a task to the message list of the same algorithm type and monitors in real time whether there is an algorithm task in the message list, and further includes: Control the algorithm engine layer to monitor in real time the status of each algorithm engine executing the previous algorithm task; When the algorithm engine layer detects that the algorithm engine has completed executing the previous algorithm task, the algorithm engine layer is controlled to actively send a request to obtain the task to the message queue layer; After receiving the task acquisition request, the message queue layer controls the message queue layer to acquire the algorithm type from the task acquisition request, determines a message list with the same algorithm type as a target message list, and detects whether there is a new algorithm task in the target message list; If the message list does not contain the algorithm task, the method further includes: Control the message queue layer to detect whether a new algorithm task is added to the message list within a preset time threshold; If a new algorithm task is added to the message list within the preset time threshold, the message queue layer is controlled to give the new algorithm task to the algorithm engine layer.
2. The control method according to claim 1, characterized in that: After the controlling the message queue layer detects whether a new algorithm task is added to the message list within a preset time threshold, the method further includes: If no new algorithm task is added to the message list within the preset time threshold, the message list is controlled to send a preset message to the algorithm engine layer.
3. The control method according to claim 1, characterized in that: If a new algorithm task is added to the message list within the preset time threshold, before controlling the message queue layer to give the new algorithm task to the algorithm engine layer, the method includes: After the message queue layer receives the algorithm task request sent by the Web service layer, it controls the message queue layer to create a corresponding key-value pair according to the algorithm task request, and adds the algorithm task carried in the algorithm task request to the message list with the same algorithm type. The algorithm task request carries the algorithm task and algorithm type.
4. The control method according to claim 3, characterized in that: After the controlling the message queue layer to send the algorithm task to the algorithm engine layer, or the controlling the algorithm engine layer to continuously monitor the message list until the algorithm task is acquired, the method further includes: After the algorithm engine layer receives the algorithm task, it controls the algorithm engine layer to execute the algorithm task and generate a calculation result, and sends the calculation result to the message queue layer.
5. The control method according to claim 4, characterized in that: After the algorithm engine layer receives the algorithm task, it controls the algorithm engine layer to execute the algorithm task and generate a calculation result, and sends the calculation result to the message queue layer, further comprising: After receiving the calculation result, the message queue layer controls the message queue layer to update the key-value pair according to the calculation result and synchronizes the updated key-value pair to the Web service layer.
6. A control device based on an algorithm service platform, characterized in that: The control device is applied to the control method based on the algorithm service platform according to any one of claims 1 to 5, comprising: A construction module is used to construct an algorithm service platform, wherein the algorithm service platform includes a Web service layer, a message queue layer, and an algorithm engine layer, wherein the message queue layer includes multiple message lists, and the algorithm engine layer includes multiple algorithm engines, and establishes a connection between each of the algorithm engines and the message lists of the same algorithm type; A processing module, used to control the algorithm engine layer to actively send a request to obtain a task to the message list of the same algorithm type and monitor in real time whether there is an algorithm task in the message list; A first judgment module, configured to control the message queue layer to send the algorithm task to the algorithm engine layer if the algorithm task exists in the message list; The second judgment module is used to control the algorithm engine layer to continuously monitor the message list until the algorithm task is obtained if the algorithm task does not exist in the message list.
7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the control method based on the algorithm service platform as described in any one of claims 1 to 5 when executing the computer program.
8. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the control method based on the algorithm service platform as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Real-time charging system based on message triggering in cloud environment
CN107995006A
Scheme processing method and device, computer equipment and storage medium
CN113656471A