Algorithm service calling method, system and device, storage medium and program product

By using the message queue protocol and request thread queue in the calling method of the algorithm service, the problem of high concurrent message processing performance overhead when calling the HTTP interface is solved, and the effect of reducing the cost of algorithm service calling and high concurrent message processing is achieved.

CN119440846APending Publication Date: 2025-02-14中移信息技术有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411571949.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, when calling algorithm services through HTTP interfaces, high concurrent message processing requires more performance overhead, resulting in higher cost of calling algorithm services.

Method used

Using an algorithm service call method, the message queue request information is determined based on the algorithm service information and the preset message queue protocol; the message queue request information is sent to the algorithm adjusted end, based on the pre-pre- The request thread queue sets to perform algorithm service calls to obtain processing results.

Benefits of technology

Through the use of preset message queue protocol and request thread queue, the performance overhead brought by the HTTP stateless protocol is avoided, the cost of calling algorithm services is reduced, and high concurrent messages can be effectively processed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119440846A_ABST
    Figure CN119440846A_ABST
Patent Text Reader

Abstract

The invention discloses an algorithm service calling method, system and device, a storage medium and a program product, relates to the technical field of communication, is applied to an algorithm calling end, and comprises the steps of obtaining to-be-called algorithm service information, and determining message queue request information according to the algorithm service information and a preset message queue protocol; the message queue request information is sent to an algorithm adjusted end, and the algorithm adjusted end is used for conducting algorithm service calling based on the message queue request information and a preset request thread queue to obtain a processing result. The technical problem that the calling cost of the algorithm service is relatively high is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information technology, and in particular to a method, system, device, storage medium and program product for calling an algorithm service. Background Art

[0002] With the continuous development of IT (Information Technology), users have also put forward higher requirements on the way of calling algorithm services.

[0003] Currently, when calling an algorithm service, the algorithm service written by the algorithm is usually called through the HTTP (HyperText Transfer Protocol) interface. However, this method of calling the algorithm service will require more performance overhead when processing high-concurrency messages because HTTP is a stateless protocol. Therefore, this method of calling the algorithm service will require more performance overhead when processing high-concurrency messages, thereby resulting in a high calling cost for the algorithm service.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a method, system, storage medium and program product for calling an algorithm service, aiming to solve the technical problem of high calling cost of algorithm services.

[0006] To achieve the above-mentioned purpose, the present application provides a method for calling an algorithm service, which is applied to an algorithm calling end, and the method for calling an algorithm service includes:

[0007] Obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and a preset message queue protocol;

[0008] The message queue request information is sent to the algorithm called end, wherein the message queue request information is set to perform an algorithm service call based on a preset request thread queue to obtain a processing result.

[0009] To achieve the above purpose, the present application also provides a calling system for an algorithm service, the calling system for the algorithm service comprising:

[0010] The algorithm calling end is used to obtain the algorithm service information to be called, and determine the message queue request information according to the algorithm service information and the preset message queue protocol; and send the message queue request information to the algorithm called end;

[0011] The algorithm called end is used to obtain the message queue request information sent by the algorithm calling end, and make an algorithm service call according to the message queue request information and a preset request thread queue; and send the processing result of the algorithm service call to the algorithm calling end.

[0012] The present application also provides an algorithm service calling device, which includes: at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, and the instructions being executed by the at least one processor so that the at least one processor can execute the steps of the algorithm service calling method as described above.

[0013] The present application also provides a storage medium, on which is stored a program for implementing a method for calling an algorithm service. When the program for the method for calling an algorithm service is executed by a processor, the steps of the method for calling an algorithm service as described above are implemented.

[0014] The present application also provides a program product, including an algorithm service calling program, which implements the steps of the algorithm service calling method as described above when executed by a processor.

[0015] The algorithm service calling method of the present application is applied to the algorithm calling end, by obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and the preset message queue protocol; the message queue request information is sent to the algorithm called end, wherein the algorithm called end is used to call the algorithm service based on the message queue request information and the preset request thread queue to obtain the processing result.

[0016] By determining the message queue request information according to the algorithm service information and the preset message queue protocol, the algorithm service call is then performed based on the preset request thread queue at the algorithm called end to obtain the processing result. This avoids the problem in the prior art that HTTP is a stateless protocol, which causes a lot of performance overhead when processing high-concurrency messages. On the one hand, the algorithm service calling method of the present application can provide a new algorithm service calling method through the use of the preset message queue protocol and the preset request thread queue. On the other hand, through the preset message queue protocol and the preset request thread queue, the characteristics of the preset request thread queue can be used to process high-concurrency messages without adding more performance overhead, so as to reduce the calling cost of the algorithm service. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0019] Figure 1 A flowchart of a method for calling an algorithm service provided in Example 1 of the present application;

[0020] Figure 2 A schematic diagram of a scenario for calling methods of common algorithm services;

[0021] Figure 3 A flowchart of a method for invoking the algorithm service of this application;

[0022] Figure 4 A flowchart of a method for calling an algorithm service provided in Embodiment 3 of the present application;

[0023] Figure 5 A schematic diagram of the structure of the calling system of the algorithm service provided in Example 5 of the present application;

[0024] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Example 6 of the present application.

[0025] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0026] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 belong to the scope of protection of the present invention.

[0027] Embodiment 1

[0028] With the widespread use of high-level programming languages, the rich tool libraries they provide have enabled many algorithm services to be written in high-level programming code. Take the call of Python (Python Programming Language, a high-level programming language) as an example (it can also be the call of other programming languages, such as Java, etc., this application uses Python for illustration), because at the application level, many are written in non-Python languages, which creates the need for non-Python applications to call Python algorithm services. The commonly used algorithm service calling method is to call the algorithm service written by the algorithm called end through the HTTP interface, which can be referred to Figure 2 , Figure 2 A schematic diagram of a scenario of a commonly used algorithm service calling method is shown in the figure. The algorithm service is exposed to the outside in the form of an HTTP (Hypertext Transfer Protocol) interface. Non-Python languages ​​call the algorithm service written in Python by implementing an HTTP client. The specific technical solution is as follows: Implement an HTTP server on the Python algorithm service (called service) side, and expose the algorithm service to the outside in the form of an HTTP interface; Implement an HTTP client in a non-Python language (calling service), and call the algorithm service written in Python through the HTTP interface. However, the HTTP interface calling the algorithm service written by the called end of the algorithm has at least the following defects: First, the delay problem is significant: HTTP interface calling involves multiple steps (HTTP is a stateless protocol), including establishing a connection, sending a request, server processing, and returning a response, etc. This series of processes is prone to cause significant delays and is difficult to adapt to scenarios with strict real-time requirements. Moreover, each request is independent of each other. For scenarios that need to maintain status, each request needs to pass the necessary status information, which requires additional processing operations. Secondly, the performance overhead is large: HTTP interface calling may generate large performance overhead in scenarios with a large number of requests and high concurrency, and complex issues such as load balancing and performance optimization need to be considered additionally. Finally, reliability is a challenge: HTTP is based on a request-response model. If the network connection is abnormal or the server crashes, the request may fail. In this case, a retry mechanism and a fault-tolerant solution need to be designed.

[0029] Therefore, based on the above defects in calling the algorithm service, the present application proposes a new algorithm service calling method, which can at least achieve the goal of not requiring more performance overhead when processing high-concurrency messages, thereby reducing the calling cost of the algorithm service.

[0030] The present application embodiment provides a method for calling an algorithm service. In the first embodiment of the method for calling an algorithm service of the present application, reference is made to Figure 1 , Figure 1This is a flow chart of a method for calling an algorithm service provided in Embodiment 1 of the present application. The method for calling an algorithm service is applied to an algorithm calling end (subsequent embodiments are described with non-Python applications). The method for calling an algorithm service includes:

[0031] Step S10, obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and the preset message queue protocol;

[0032] In this embodiment, in order to avoid the calling defects caused by HTTP, a calling method of the algorithm service of this embodiment is proposed. The calling of the algorithm service is realized by using the message queue protocol and the request thread queue, thereby effectively avoiding the calling defects caused by HTTP. At the same time, there are still the advantages of the message queue protocol and the request thread queue, such as multi-threaded synchronous processing of high-concurrency messages, and there is no need to increase more performance overhead to reduce the calling cost of the algorithm service. When the calling method of the entire algorithm service is applied to the algorithm calling end (taking the calling of the Python algorithm as an example, the algorithm calling end is the end written in a non-Python language), the algorithm service information to be called is used, and then the message queue request information is determined according to the algorithm service information and the preset message queue protocol, that is, the algorithm service information is delivered to the queue with a specific message queue protocol so that the algorithm is called by the end. Algorithm service information refers to the relevant parameters that need to call the Python algorithm, message queue request information refers to the queue information obtained by delivering the algorithm service information to the queue, and the preset message queue protocol refers to the user-defined transmission protocol, such as the protocol corresponding to Rabbitmq (Rabbit Message Queue, message-oriented middleware). Of course, it can also be other transmission protocols, which are not limited here, and thus the relevant information of the algorithm service that needs to be called can be transmitted to the Rabbitmq queue so that the algorithm can be called by the calling end.

[0033] Step S20, sending the message queue request information to the algorithm called end, wherein the algorithm called end is used to call the algorithm service based on the message queue request information and the preset request thread queue to obtain the processing result.

[0034] In this embodiment, after the message queue request information is delivered to the queue (message request queue) in Rabbitmq, the message queue request information will be sent to the algorithm called end. Alternatively, the algorithm called end can detect the existence of the message queue request information in the message request queue in Rabbitmq, and then obtain the message queue request information based on the consumption and production pika corresponding to the preset message queue protocol. At this time, when the message queue request information is sent to the algorithm called end, the message queue request information will be placed in the preset request thread queue, and then the algorithm service will be called in the preset request thread queue based on the relevant parameters in the message queue request information, and then the processing result of the algorithm service call will be obtained. Among them, the preset request thread queue can be a Queue queue, which refers to a queue for storing request messages. Because pika has thread safety issues, only a single Pika response message thread can be started. Due to the limitation of thread safety issues, high concurrent processing cannot be achieved at this time. Therefore, the acquisition result of pika is placed in the Queue queue for processing, so that high concurrent processing can be achieved. The processing result refers to the result of the algorithm service call, such as successful call, failed call, etc., and then the entire algorithm service call process can be completed. Through the preset message queue protocol and the preset request thread queue, the characteristics of the preset request thread queue can be used to process high concurrent messages without adding more performance overhead, so as to reduce the calling cost of the algorithm service.

[0035] In one embodiment, after the step of sending the message queue request information to the algorithm called end, the following steps are included:

[0036] Step S21, based on the preset message monitoring thread, obtain the processing result sent by the algorithm calling end

[0037] In this embodiment, there may also be a message monitoring thread at the algorithm calling end, which monitors the consumption messages in the Rabbitmq response message queue in real time to determine the algorithm calling result processing and complete the closed-loop processing of the entire non-Python application calling the Python algorithm. If relevant information about the processing result is found in the Rabbitmq response message queue, this information will be received at the algorithm calling end.

[0038] As an example, the calling method of the algorithm service includes, through steps S10 to S20: applied to the algorithm calling end, by obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and the preset message queue protocol; sending the message queue request information to the algorithm called end, wherein the algorithm called end is used to call the algorithm service based on the message queue request information and the preset request thread queue to obtain the processing result. By determining the message queue request information according to the algorithm service information and the preset message queue protocol, the algorithm service is called based on the preset request thread queue at the algorithm called end to obtain the processing result. Thus, the problem of high concurrent message processing requiring more performance overhead due to HTTP being a stateless protocol in the prior art is avoided. On the one hand, the calling method of the algorithm service of the present application can provide a new calling method of the algorithm service through the use of the preset message queue protocol and the preset request thread queue. On the other hand, through the preset message queue protocol and the preset request thread queue, the characteristics of the preset request thread queue can be used to process high concurrent messages without adding more performance overhead, so as to reduce the calling cost of the algorithm service.

[0039] Embodiment 2

[0040] Further, in another embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above description and will not be described in detail later. On this basis, the step of determining the message queue request information according to the algorithm service information and the preset message queue protocol includes:

[0041] Step S11, serializing the algorithm service information based on a preset message queue protocol to obtain request information to be processed;

[0042] Step S12, determining the binding information corresponding to the algorithm service information, and performing binding processing on the request information to be processed based on the binding information to obtain the message queue request information, wherein the binding processing includes delivering the request information to be processed to the message request queue corresponding to the binding information based on the binding information.

[0043] In this embodiment, after determining that there is algorithm service information, the algorithm service information will be serialized based on the preset message queue protocol to obtain pending request information, that is, at this time, the algorithm service information will be converted into information that can be transmitted and transmitted to Rabbitmq. Because Rabbitmq also has multiple queues, the pending request information will be bound based on the binding information to obtain message queue request information, wherein the binding processing includes delivering the pending request information to the message request queue corresponding to the binding information based on the binding information, that is, accurately delivering the algorithm service information to the corresponding message request queue, so that the algorithm called end can extract and call based on the information in the request queue. Among them, the pending request information refers to the data that can be used for storage and transmission after serialization, and the binding information refers to the binding information that needs to be delivered to the queue for accurate delivery.

[0044] For example, refer to Figure 3 , Figure 3 A flowchart of the calling method of the algorithm service of this application, such as defining the algorithm message object in the non-Python application, that is, the algorithm service information, that is, the calling object corresponding to the parameter information, according to the parameter information required by Python algorithm A (specifically, when developing non-Python applications, it is necessary to define the algorithm message object according to the Python algorithm interface parameters), setting the message converter through the Rabbitmq configuration item, and then generating the algorithm call message and serializing the algorithm call message according to the set message converter. Among them, serialization is the process of converting a data structure or object into a format that can be stored or transmitted. Through serialization, complex data can be converted into a byte stream, so that it can be easily stored (such as written to a file) or transmitted over the network (such as sent over the network), and then the algorithm service information after serialization is sent to the message request queue of the Rabbitmq message queue, so that the Python application can extract it and use it as a basis for subsequent calls.

[0045] Further, after the step of binding the request information to be processed based on the binding information to obtain the message queue request information, the method includes:

[0046] Step S111, obtaining the delivery result of the message request queue, and detecting whether the delivery result is successful;

[0047] Step S112, when the delivery result is successful, executing the step of sending the message queue request information to the algorithm called end;

[0048] Step S113, when the delivery result is that the delivery is unsuccessful, executing the step of binding the request information to be processed based on the binding information to obtain the message queue request information.

[0049] In this embodiment, to ensure that the message arrives reliably at the Rabbitmq service and the message request queue, a callback function is set in Rabbitmq and the message request queue. The callback function will carry information such as whether the message has successfully arrived at Rabbitmq and the message request queue, the unique associated data of the current message (i.e. the unique ID of the message), and the reason if the message has not successfully arrived at Rabbitmq and the message request queue. The following is an example of the Rabbitmq callback function of a java application:

[0050] Introduce spring-boot-starter-amqp dependency;

[0051] Set Rabbitmq configuration item: spring.Rabbitmq.publisher-confirm-type:correlated;

[0052] Customize RabbitTemplate and set the confirmation callback through setConfirmCallback. The callback function has three parameters (correlationData, ack, cause).

[0053] correlationData: the unique correlation data of the current message (this is the unique ID of the message);

[0054] ack: whether the message was successfully received;

[0055] cause: the reason for failure;

[0056] As long as the message arrives at the Broker, ack=true, that is, the entire execution process will prioritize whether it has arrived at Rabbitmq before determining the binding information corresponding to the pending request information. If it has arrived, the subsequent steps will continue to be executed, and the pending request information after serialization in the non-Python application will be deleted. Otherwise, the pending request information will continue to be delivered to Rabbitmq until the number of deliveries reaches a certain number of times, then an alarm will be issued to the user, or other operations will be performed. If it successfully arrives at Rabbitmq, the pending request information will be delivered to the message request queue again, because the message request queue is bound to the switch Exchange and routing key Routing Key. When the non-Python application sends the pending request information, the switch Exchange and routing key Routing Key have been specified. The pending request information will be delivered to the specified message request queue through the switch and routing key information. To ensure that the message request queue is reliably delivered to the message request queue, a message delivery failure callback needs to be set. As long as the message is not delivered to the message request queue normally, the failure callback will be triggered. The callback function will carry detailed information of the failed delivery message, the switch to which the failed delivery message is delivered, the routing key for the failed delivery message, and other information. The following is an example of the message request queue callback function of a Java application:

[0057] Introduce spring-boot-starter-amqp dependency;

[0058] Set Rabbitmq configuration item: spring.Rabbitmq.publisher-returns:true;

[0059] spring.Rabbitmq.template.mandatory:true;

[0060] Customize RabbitTemplate and set the failure callback through setReturnCallback. The failure callback function has 5 parameters (message, replyCode, replyText, exchange, routingKey);

[0061] message: detailed information of the message that failed to be delivered;

[0062] replyCode: the status code of the reply;

[0063] replyText: the text content of the reply;

[0064] exchange: the switch to which the message was sent;

[0065] routingKey: which routing key was used for this message at that time;

[0066] As long as the message is not successfully delivered to the specified queue, this failure callback is triggered;

[0067] That is, through the above steps, the algorithm A call message can be reliably delivered to the message request queue. At the same time, the maximum number of deliveries can be set in the message request queue, that is, the maximum number of deliveries allowed after failure, to ensure the reliability of the entire processing of the A call message. If it arrives, continue to execute the subsequent steps and delete the serialized pending request information in Rabbitmq. Otherwise, continue to deliver the pending request information to the message request queue until the number of deliveries reaches a certain number, then an alarm will be issued to prompt the user, or other operations will be performed.

[0068] Embodiment 3

[0069] Further, based on the above-mentioned embodiment applied to the algorithm calling end, an embodiment applied to the algorithm called end is proposed, referring to Figure 4 , Figure 4 This is a flow chart of a method for calling an algorithm service provided in Embodiment 3 of the present application. The method for calling an algorithm service is applied to the algorithm called end (the subsequent embodiments are described in Python). The method for calling an algorithm service includes:

[0070] Step S30, obtaining the message queue request information sent by the algorithm calling end, and performing an algorithm service call according to the message queue request information and a preset request thread queue, wherein the algorithm calling end is used to determine the message queue request information according to the algorithm service information to be called and a preset message queue protocol;

[0071] In this embodiment, by obtaining the message queue request information sent by the algorithm call end, the algorithm service call can be made according to the message queue request information and the preset request thread queue, wherein the message queue request information is set to be determined in the non-Python application according to the algorithm service information to be called and the preset message queue protocol, and the preset request thread queue can be a Queue queue. That is, at this time, the message queue request information is delivered to the Queue queue, and then multiple threads can be used based on the Queue queue to achieve high concurrent messages, so as to reduce the calling cost of the entire algorithm service.

[0072] Step S40: sending the processing result of the algorithm service call to the algorithm call end based on the preset message queue protocol.

[0073] In this embodiment, in the Queue queue, in addition to using multiple threads to achieve high-concurrency messages to call each task in the message queue request information, the call result of each task will also be used as the processing result, and the processing result will be sent to the algorithm call end based on the preset message queue protocol to complete the closed-loop processing of the algorithm service call. That is, each message queue request information corresponds to a processing task. The task processing thread in the Queue queue obtains the parameter information required to call the algorithm by parsing the message queue request information and completes the algorithm call. After the algorithm call is completed, the processing result will be generated, and the task processing thread will encapsulate the processing result into a response message. At the same time, in order to ensure thread safety, each concurrent thread will store the response result message in the local response message queue Queue after the task processing is completed. And use pika to realize message consumption and production, that is, use pika to extract the processing results in the response message queue Queue, and send the processing results to the message response queue of the algorithm calling end (corresponding to the message request queue, one is a queue for storing request messages, and the other is a queue for storing response messages). At this time, the algorithm calling end can monitor the message queue response in the message response queue based on the message listening thread to complete the closed-loop processing of the entire algorithm service call.

[0074] As an example, the calling method of the algorithm service includes, through steps S30 to S40: applied to the algorithm called end, by obtaining the message queue request information sent by the algorithm calling end, and calling the algorithm service according to the message queue request information and the preset request thread queue, wherein the algorithm calling end is used to determine the message queue request information according to the algorithm service information to be called and the preset message queue protocol; based on the preset message queue protocol, the processing result of the algorithm service call is sent to the algorithm calling end. By calling the algorithm service according to the message queue request information and the preset request thread queue, the processing result of the algorithm service call is sent to the algorithm calling end based on the preset message queue protocol. Thereby avoiding the problem of high performance overhead caused by HTTP being a stateless protocol in the prior art, on the one hand, the calling method of the algorithm service of the present application can provide a new calling method of the algorithm service through the use of the preset message queue protocol and the preset request thread queue, and on the other hand, through the preset message queue protocol and the preset request thread queue, the characteristics of the preset request thread queue can be used to process high concurrent messages without adding more performance overhead, so as to reduce the calling cost of the algorithm service.

[0075] Embodiment 4

[0076] Further, in another embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above description and will not be described in detail later. On this basis, the steps of calling the algorithm service according to the message queue request information and the preset request thread queue include:

[0077] Step S31, based on the receiving thread of the preset message queue protocol, deserializes the message queue request information to obtain a task to be processed;

[0078] Step S32, calling the target algorithm service based on the task to be processed and the preset request thread queue, wherein after the target algorithm service is called, the processing result of the algorithm service call is obtained.

[0079] In this embodiment, because the Python application uses the pika library (Rabbitmq's own library) to start the message receiving thread, due to the thread safety problem of pika, only a single pika message receiving thread can be started. Due to the limitation of thread safety problems, high concurrency processing cannot be achieved at this time. In view of the thread safety problem of Pika, this embodiment uses a thread-safe Queue to store messages to achieve thread-safe and efficient processing (the prior art does not use Queue queues in combination with Rabbitmq to achieve a high-availability message processing solution, and this solution is to improve the defects of the pika library). Among them, pika can still be used to realize the consumption and production of messages: on the one hand, after the message is passed to the Rabbitmq message request queue, the Python application uses pika to obtain data from the Rabbitmq message queue; on the other hand, the Python application will generate a result message after processing the task. After the result message is generated, pika will be used to send the message to the Rabbitmq message response queue, and the non-Python application will then obtain the result message from Rabbitmq to complete the closed-loop processing of the algorithm service call.

[0080] In one embodiment, in order to achieve high concurrent message processing, refer to Figure 3, this embodiment introduces a thread-safe Queue queue. The pika message receiving thread (i.e., the receiving thread) does not perform actual task processing. It only takes out the message from the Rabbitmq message request queue and deserializes the message queue request information to obtain the pending task, wherein deserialization is the process of converting the serialized data (usually a byte stream or a string) back to the original data structure or object. Through deserialization, the information stored during serialization can be restored to make it available again, and then stored in the receiving Queue local queue. It is worth noting that in order to prevent exceptions caused by network jitter and other reasons, the pika message receiving thread needs to implement a retry mechanism, and automatically retry processing when it fails to obtain a message from the Rabbitmq queue. At the same time, when the pika message receiving thread obtains a message as a consumer thread, the message will be obtained only if there is a message in the message request queue to store it in the receiving Queue local queue. After the message is stored in the receiving Queue local queue, the Python application starts the business processing thread (1+n+1 threads, i.e., 1 message receiving thread, n business processing threads, and 1 message response thread), and executes the consumer thread in the business processing thread to obtain the information in the Queue local queue, and then the Queue local queue will process the message. Because the Queue queue has thread safety, multiple message consumer threads can be opened according to business needs, and the processed messages can be obtained from the Queue queue for concurrent processing. The result of the processing thread after processing is sent to the reply message receiving Queue local queue through the message response thread to complete the call processing flow in the Python application. At the same time, the combined use of Queue and Rabbitmq queues can achieve high concurrent message processing, and compared with the existing processing methods, the call cost of the algorithm service can be reduced.

[0081] Furthermore, the step of sending the processing result of the algorithm service call to the algorithm call end based on the preset message queue protocol includes:

[0082] Step S41, based on the receiving thread of the preset message queue protocol, the response information is serialized to obtain the processing result, and the processing result is sent to the algorithm calling end, wherein the response information includes the response result corresponding to the task to be processed in the preset response thread queue.

[0083] In this embodiment, when the algorithm is called based on the business processing thread, the result of each call will be obtained, and the result will be stored in the reply message receiving Queue local queue. To achieve high concurrency processing, the Pika response message thread (receiving thread) is responsible for taking the result of each call from the reply message receiving Queue local queue and serializing the message, and then sending it to the Rabbitmq response message queue. At this time, the algorithm call end can monitor the message queue response in the message response queue based on the message listening thread, and complete the closed-loop processing of the call of the entire algorithm service. Among them, the response information includes the response result corresponding to the pending task in the preset response thread queue. The preset response thread queue refers to the queue of the response result. The preset request thread queue can use one queue or two different queues. The response result refers to the result of the algorithm call for the pending task. Based on the above Queue and Rabbitmq combined to implement algorithm service calls, on the one hand, the throughput and stability of the system can be improved: that is, multiple messages can be processed concurrently based on the Queue, thereby improving the system's processing power and throughput, decoupling the message processing process based on the Queue, reducing the system's coupling, and improving the system's stability and reliability; on the other hand, the system's response time can be reduced: the asynchronous message processing mechanism (that is, the information being processed can be transmitted back in Rabbitmq), and time-consuming operations can be processed in the background, thereby reducing the system's response time and improving the user experience. Finally, because the entire solution is combined with the Rabbitmq message queue, it can facilitate the expansion and maintenance of the system. New message processing logic can be easily added through the message queue without affecting the operation of the original system.

[0084] Embodiment 5

[0085] The present application also provides a system for calling an algorithm service. Figure 5 , Figure 5 This is a schematic diagram of the structure of the algorithm service calling system provided in Embodiment 5 of the present application. The algorithm service calling system includes:

[0086] The algorithm calling end A10 is used to obtain the algorithm service information to be called, and determine the message queue request information according to the algorithm service information and the preset message queue protocol; and send the message queue request information to the algorithm called end;

[0087] The algorithm called end A20 is used to obtain the message queue request information sent by the algorithm calling end, and make an algorithm service call according to the message queue request information and a preset request thread queue; and send the processing result of the algorithm service call to the algorithm calling end.

[0088] Optionally, the algorithm calling terminal A10 is further used for:

[0089] The processing result sent by the algorithm called end is obtained based on a preset message monitoring thread.

[0090] Optionally, the algorithm calling terminal A10 is further used for:

[0091] Serializing the algorithm service information based on a preset message queue protocol to obtain request information to be processed;

[0092] Determine the binding information corresponding to the algorithm service information, and perform binding processing on the pending request information based on the binding information to obtain message queue request information, wherein the binding processing includes delivering the pending request information to the message request queue corresponding to the binding information based on the binding information.

[0093] Optionally, the algorithm calling terminal A10 is further used for:

[0094] Obtaining the delivery result of the message request queue, and detecting whether the delivery result is successful;

[0095] When the delivery result is successful, executing the step of sending the message queue request information to the algorithm called end;

[0096] When the delivery result is that the delivery is unsuccessful, the step of performing binding processing on the request information to be processed based on the binding information to obtain message queue request information is executed.

[0097] Optionally, the algorithm adjusted end A20 is further used for:

[0098] Based on a receiving thread of a preset message queue protocol, the message queue request information is deserialized to obtain a task to be processed;

[0099] The target algorithm service is called based on the to-be-processed task and the preset request thread queue, wherein after the target algorithm service is called, a processing result of the algorithm service call is obtained.

[0100] Optionally, the algorithm adjusted end A20 is further used for:

[0101] The receiving thread based on the preset message queue protocol serializes the response information to obtain the processing result, and sends the processing result to the algorithm calling end, wherein the response information includes the response result corresponding to the to-be-processed task in the preset response thread queue.

[0102] The algorithm service calling system provided by the present invention adopts the algorithm service calling method in the above embodiment, which solves the technical problem of high calling cost of the algorithm service. Compared with the prior art, the beneficial effects of the algorithm service calling system provided by the embodiment of the present invention are the same as the beneficial effects of the algorithm service calling method provided by the above embodiment, and other technical features in the algorithm service calling system are the same as the features disclosed in the above embodiment method, which will not be described in detail here.

[0103] Embodiment 6

[0104] An embodiment of the present invention provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the calling method of the algorithm service in the above-mentioned embodiment one.

[0105] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. The electronic device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0106] like Figure 6 As shown, the electronic device may include a processing system 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage system 1003 into a random access memory (RAM) 1004. Various programs and data required for the operation of the electronic device are also stored in the RAM 1004. The processing system 1001, the ROM 1002, and the RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus.

[0107] Typically, the following systems can be connected to the I / O interface 1006: an input system 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output system 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage system 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication system 1009. The communication system can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.

[0108] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication system 1009, or installed from the storage system 1003, or installed from the ROM 1002. When the computer program is executed by the processing system 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0109] The electronic device provided by the present invention adopts the calling method of the algorithm service in the above embodiment, which solves the technical problem of high calling cost of the algorithm service. Compared with the prior art, the beneficial effects of the electronic device provided by the embodiment of the present invention are the same as the beneficial effects of the calling method of the algorithm service provided by the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0110] It should be understood that the various parts of the present disclosure can be implemented with hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0111] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

[0112] Embodiment 7

[0113] This embodiment provides a storage medium, which may be a computer-readable storage medium having computer-readable program instructions stored thereon, and the computer-readable program instructions are used to execute the calling method of the algorithm service in the above embodiment.

[0114] The computer-readable storage medium provided in the embodiment of the present invention may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0115] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0116] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device executes at the algorithm calling end: obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and the preset message queue protocol; sending the message queue request information to the algorithm called end, wherein the algorithm called end is used to make an algorithm service call based on the message queue request information and the preset request thread queue to obtain a processing result. Execute at the algorithm called end: obtaining the message queue request information sent by the algorithm calling end, and making an algorithm service call according to the message queue request information and the preset request thread queue, wherein the algorithm calling end is used to determine the message queue request information according to the algorithm service information to be called and the preset message queue protocol; sending the processing result of the algorithm service call to the algorithm calling end based on the preset message queue protocol.

[0117] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0118] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0119] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of the module does not limit the unit itself in some cases.

[0120] The computer-readable storage medium provided by the present invention stores computer-readable program instructions for executing the above-mentioned algorithm service calling method, which solves the technical problem of high calling cost of the algorithm service. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the embodiment of the present invention are the same as the beneficial effects of the algorithm service calling method provided by the above-mentioned embodiment, and will not be repeated here.

[0121] Embodiment 8

[0122] The present application also provides a program product, including a computer program, which implements the steps of the calling method of the algorithm service as described above when executed by a processor.

[0123] The program product provided by this application solves the technical problem of high calling cost of algorithm services. Compared with the prior art, the beneficial effects of the program product provided by the embodiment of the present invention are the same as the beneficial effects of the calling method of the algorithm service provided by the above embodiment, which will not be repeated here.

[0124] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A method for calling an algorithm service, characterized in that: The calling method of the algorithm service is applied to the algorithm calling end, and the calling method of the algorithm service includes: Obtaining the algorithm service information to be called, and determining the message queue request information according to the algorithm service information and a preset message queue protocol; The message queue request information is sent to the algorithm called end, wherein the algorithm called end is used to perform an algorithm service call based on the message queue request information and a preset request thread queue to obtain a processing result.

2. The method for calling the algorithm service according to claim 1, characterized in that: After the step of sending the message queue request information to the algorithm called end, the method further includes: The processing result sent by the algorithm called end is obtained based on a preset message monitoring thread.

3. The method for calling the algorithm service according to claim 1, characterized in that: The step of determining the message queue request information according to the algorithm service information and the preset message queue protocol includes: Serializing the algorithm service information based on a preset message queue protocol to obtain request information to be processed; Determine the binding information corresponding to the algorithm service information, and perform binding processing on the pending request information based on the binding information to obtain message queue request information, wherein the binding processing includes delivering the pending request information to the message request queue corresponding to the binding information based on the binding information.

4. The method for calling the algorithm service as claimed in claim 3, characterized in that: After the step of binding the request information to be processed based on the binding information to obtain the message queue request information, the method further comprises: Obtaining the delivery result of the message request queue, and detecting whether the delivery result is successful; When the delivery result is successful, executing the step of sending the message queue request information to the algorithm called end; When the delivery result is that the delivery is unsuccessful, the step of performing binding processing on the request information to be processed based on the binding information to obtain message queue request information is executed.

5. A method for calling an algorithm service, characterized in that: The calling method of the algorithm service is applied to the algorithm called end, and the calling method of the algorithm service includes: Obtaining message queue request information sent by the algorithm calling end, and performing an algorithm service call according to the message queue request information and a preset request thread queue, wherein the algorithm calling end is used to determine the message queue request information according to the algorithm service information to be called and a preset message queue protocol; The processing result of the algorithm service call is sent to the algorithm call end based on a preset message queue protocol.

6. The method for calling the algorithm service as claimed in claim 5, characterized in that: The step of calling the algorithm service according to the message queue request information and the preset request thread queue includes: Based on a receiving thread of a preset message queue protocol, the message queue request information is deserialized to obtain a task to be processed; The target algorithm service is called based on the to-be-processed task and the preset request thread queue, wherein after the target algorithm service is called, a processing result of the algorithm service call is obtained.

7. The method for calling the algorithm service as claimed in claim 6, characterized in that: The step of sending the processing result of the algorithm service call to the algorithm call end based on a preset message queue protocol includes: The receiving thread based on the preset message queue protocol serializes the response information to obtain the processing result, and sends the processing result to the algorithm calling end, wherein the response information includes the response result corresponding to the to-be-processed task in the preset response thread queue.

8. A calling system for algorithm services, characterized in that: The calling system of the algorithm service includes: The algorithm calling end is used to obtain the algorithm service information to be called, and determine the message queue request information according to the algorithm service information and the preset message queue protocol; and send the message queue request information to the algorithm called end; The algorithm called end is used to obtain the message queue request information sent by the algorithm calling end, and make an algorithm service call according to the message queue request information and a preset request thread queue; and send the processing result of the algorithm service call to the algorithm calling end.

9. A device for calling an algorithm service, characterized in that: The calling device of the algorithm service includes: at least one processor; a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the algorithm service calling method described in any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores a program for implementing a method for calling an algorithm service, and the program for implementing a method for calling an algorithm service is executed by a processor to implement the steps of the method for calling an algorithm service as described in any one of claims 1 to 7.

11. A program product, characterized in that The program product comprises a calling program for an algorithm service, and when the calling program for the algorithm service is executed by a processor, the steps of the calling method for the algorithm service as claimed in any one of claims 1 to 7 are implemented.