Message scheduling method

By managing message queues according to partition coding of message channels and custom orchestration strategies in the 5G message system, the problems of low resource utilization and insufficient orchestration and control capabilities in the prior art are solved, and more efficient message queue services and finer service control are achieved.

CN119584062AActive Publication Date: 2025-03-07CHINA MOBILE INTERNET CO LTD +1
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411517826.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-03-07
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

In the existing 5G message system, message queue middleware lacks the ability to orchestrate and control services in complex business scenarios, resulting in problems such as low system resource utilization, low message channel utilization, and inaccurate priority control.

Method used

By determining the namespace of the message queue based on the partition encoding of the message channel, saving the message to the namespace, and determining the key of the message queue according to the custom orchestration strategy, maintaining the index and ordered collection with the key as conditions, triggering the scheduling notification event, and realizing refined message queue services.

Benefits of technology

Supports business custom orchestration strategies, improves the utilization rate of system resources and message channels, ensures the accuracy of message priority, and solves the problems of low resource utilization and insufficient orchestration and control capabilities in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119584062A_ABST
    Figure CN119584062A_ABST
Patent Text Reader

Abstract

The invention discloses a message scheduling method, belongs to the field of 5G messages, and is used for improving the business arrangement, regulation and control capability. The method comprises the following steps: determining a namespace of a message queue according to a partition code of a message channel; storing the message in the namespace; and determining a key of the message queue according to a self-defined arrangement strategy, maintaining an index and an ordered set of the message queue by taking the key as a condition, and triggering a scheduling notification event.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of 5G messages and specifically relates to a message scheduling method. Background Art

[0002] The 5G messaging system brings together Chatbot applications from thousands of industries and is required to have more extreme control over message distribution based on business priority, timeliness, multiple message channels, etc. The chatbot application access module of the 5G messaging system is responsible for maximizing the use of limited message channel resources through reasonable orchestration and dispatching a large number of industry application messages to user terminals. That is, it is necessary to be able to automatically schedule and control messages through flexible strategies under the limited quota of the southbound message channel + the upper limit resources allocated by the platform when the number of Chatbot accesses changes dynamically and messages are sent dynamically. The 5G message sending function is implemented based on the message queue middleware. Limited by the technical characteristics of the message queue middleware described above, it generally adopts a solution of pre-defining a fixed number of queues by priority, and then saving messages of different priorities to the corresponding priority queues for distribution. It has the following problems: Overall utilization of system resources: Each queue has exclusive use of message producer and consumer server resources. Since server resources are not shared and overall utilization is low, some queues are very busy while some queues are very idle but idle resources cannot be used, and system resources are not fully utilized.

[0003] Application-level (chatbot-level) orchestration is not supported: each queue is shared, but multiple chatbot applications send messages at the same time. The same queue stores messages from multiple chatbot applications. The service completion time of each chatbot cannot be estimated. Message scheduling by chatbot application is not supported, which is not conducive to chatbot service control.

[0004] Low utilization of message channels: The message sending service needs to meet the flow control of both the chatbot and the message channel level. Since the chatbot to which the message is sent is not fixed, the actual throughput of the message channel fluctuates greatly and the utilization rate is low.

[0005] Inaccurate priority control: Based on the first-in-first-out (FIFO) feature of the queue, when a message retry mechanism occurs, the message returns to the end of the queue and cannot be sent according to the requested time, which may cause the message to expire.

[0006] Fixed message priority: Since the overall situation of message scheduling cannot be perceived, the message priority needs to be pre-set and cannot be adjusted dynamically. Since the priority cannot be adjusted, the message may be distributed to a busy queue, resulting in sending timeouts and other situations that affect the sending success rate.

[0007] The above shows that the message queue middleware has distinct technical features and single functions. In complex business scenarios, it lacks the ability to fine-tune the orchestration and control of the business. Summary of the invention

[0008] The embodiment of the present application provides a message scheduling method, which can solve the problem of lack of refined orchestration and control capabilities for services.

[0009] In a first aspect, an embodiment of the present application provides a message scheduling method, the method comprising: determining a namespace of a message queue according to a partition code of a message channel; saving the message to the namespace; determining a key of the message queue according to a custom orchestration strategy, maintaining an index and an ordered set of the message queue based on the key as a condition, and triggering a scheduling notification event.

[0010] In the second aspect, an embodiment of the present application provides a message scheduling device, which includes: a determination module for determining a namespace of a message queue based on a partition code of a message channel; a saving module for saving messages to the namespace; and an operation module for determining a key of the message queue based on a custom orchestration strategy, maintaining an index and an ordered set of the message queue based on the key as a condition, and triggering a scheduling notification event.

[0011] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0012] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0013] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer performs the steps of the method described in the first aspect.

[0014] In an embodiment of the present application, the namespace of the message queue is determined according to the partition code of the message channel; the message is saved in the namespace; the key of the message queue is determined according to a custom orchestration strategy, and the index and ordered set of the message queue are maintained based on the key, and a scheduling notification event is triggered. The business logic customizes the orchestration strategy, thereby realizing a refined and controllable message queue service. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a flowchart of a message scheduling method provided in an embodiment of the present application; Figure 2 This is another message scheduling process diagram provided by an embodiment of the present application; Figure 3 This is another message scheduling process diagram provided by an embodiment of the present application; Figure 4 It is a structural diagram of a message scheduling device provided in an embodiment of the present application; Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0017] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0018] The message scheduling method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0019] Figure 1 A message scheduling method provided by an embodiment of the present application is shown, and the method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device, and the method includes the following steps: Step 102: Determine the namespace of the message queue according to the partition code of the message channel.

[0020] In one implementation, the data structure and small messages of the message queue are stored in a first-level distributed memory database, and the large messages and data structure of the message queue are stored in a second-level distributed key-value storage engine.

[0021] The embodiment of the present application uses a two-level distributed storage solution. The first-level distributed memory database saves the data structure and small messages of the queue, and the second-level distributed key-value storage engine saves large messages and data structures, taking into account functionality, performance, and economy. The distributed memory database stores data in memory and uses snapshots and log appending to achieve data persistence, so it has very fast read and write performance and low latency. The distributed key-value storage engine stores data persistently on disk and uses a distributed protocol to ensure strong consistency replication of data to meet the needs of large-scale data storage and query.

[0022] In an embodiment of the present application, different message channels are defined with independent partition codes, and the distributed memory database supports namespaces, which use partition codes as namespaces to isolate queue data between message channels. The queue data structure consists of an ordered set, a queue index, a message body, and the like. Among them, the system is set with a small message threshold. When the message data is less than the threshold, it is saved in the memory database, otherwise it is saved in the distributed storage server. The ordered set saves the storage type and message ID of the message, and is sorted by the time the message enters the queue by default. The specific sorting conditions can be determined by the orchestration strategy of the business-defined message channel, which is responsible for connecting all messages in the same queue. The queue index saves the properties of the queue and is mainly used to control and operate the queue. The definition of the message queue data structure is as follows: Message queue ordered set:

[0023] Message queue index:

[0024] Message body:

[0025] Sending queue: Use a sorted set data to save the sending queue key

[0026] Queue to be sent: Use a sorted set data to save the queue key to be sent

[0027] Message Cache in Sending

[0028] The message queue supports business-defined orchestration strategies. The message producer service implements the producer function of the message queue, provides the message queue push function to the business module, and triggers queue events. The message producer service first determines the namespace of the queue through the partition code of the message channel.

[0029] Step 104: Save the message to the namespace.

[0030] Specifically, after the namespace of the queue is determined by the partition code of the message channel, the message can be saved in the namespace.

[0031] In one implementation, saving the message to the namespace includes: saving the message to a message area of ​​the namespace.

[0032] Specifically, saving the message to the namespace means saving the message to the message area message of the namespace.

[0033] Step 106: Determine the key of the message queue according to the custom orchestration strategy, maintain the index and ordered set of the message queue based on the key, and trigger a scheduling notification event.

[0034] In one implementation, determining the key of the message queue according to a custom orchestration policy, and maintaining the index and ordered set of the message queue based on the key, includes: determining the key of the message queue according to the custom orchestration policy; querying the index of the message queue from the index area of ​​the namespace based on the key; and maintaining the index and ordered set of the message queue based on the status of the index.

[0035] Specifically, the mq_key of the queue is determined according to the business-defined orchestration strategy, and the queue index is queried from the index area of ​​the namespace based on the mq_key. If the queue index does not exist, the queue index is created (the initial state is 0). The status of the queue index saves the status of the queue. The subsequent processing flow of the message producer service is as follows according to the different queue states: When status is equal to 0, put the queue mq_key into the "queue to be sent" ordered set, and the score is "priority + scheduling request time". Update the message queue index: programme_req_time = current system time, status = 1; save "storage_type + message_id" to the sorted set. Issue a scheduling notification event.

[0036] When status is equal to 1, put the queue mq_key into the "queue to be sent" ordered set, and the score is "priority + scheduling request time"; save "storage_type + message_id" to the sorted set.

[0037] When status is equal to 2, save "storage_type+message_id" to the sorted set.

[0038] When status is equal to 3, the push fails.

[0039] The orchestration and scheduling service monitors scheduling events or triggers scheduling notification events at regular intervals. The system uses a distributed lock mechanism to ensure that at most only one orchestration and scheduling job is running at the same time.

[0040] The message scheduling method provided in the embodiment of the present application determines the namespace of the message queue according to the partition code of the message channel; saves the message to the namespace; determines the key of the message queue according to the custom orchestration strategy, and maintains the index and ordered set of the message queue based on the key; runs the scheduling notification event, and can perform the business logic custom orchestration strategy, realizing a refined and controllable message queue service, solving the problem that the message queue middleware has distinct technical characteristics and single functions, and lacks the ability to fine-tune the orchestration and regulation of the business in complex business scenarios. Supports business custom orchestration strategies, and the business decides which messages are sent first and have higher resource usage rights according to the business characteristics, and has good scalability: This message queue service adopts a storage and computing separation architecture with good scalability, and reserves parameters to support the business to control the queue service through monitoring, dialing, big data, AI and other technologies or means to achieve more accurate message sending control. High overall utilization of system resources: Each queue of the message queue middleware has exclusive computing resources of producers, servers and consumers. In the embodiment of the present application, all queues share the computing resources of producers, servers and consumers, which are dynamically allocated according to the orchestration results, and the overall utilization rate of system resources is higher.

[0041] In one implementation, the triggering of the scheduling notification event includes: in response to the running scheduling notification event, calculating a new scheduling result based on the scheduling formula and the custom scheduling strategy; calculating a call-out difference set and a call-in difference set according to the new scheduling result and the old scheduling result; and notifying the queue distributor through a task message to complete the call-out and call-in scheduling.

[0042] The orchestration and scheduling service is responsible for performing orchestration calculations and service scheduling according to the business-defined orchestration strategy, allocating message queue services and message channel resources to specified queues, and determining which queues need to wait.

[0043] The orchestration and scheduling service monitors scheduling events or triggers orchestration and scheduling jobs at regular intervals. The system uses a distributed lock mechanism to ensure that at most only one orchestration and scheduling job is running at the same time. Main parameters of arrangement: The maximum throughput of the system = the maximum number of instances of the message scheduler planned to be deployed * the number of sending threads per instance * the single-thread benchmark throughput. The real-time throughput of the system = the number of real-time instances of the message scheduler * the number of sending threads per instance * the single-thread benchmark throughput. The number of instances of the message scheduler can be obtained from the registration center, and the single-thread benchmark throughput can be obtained through testing.

[0044] The maximum throughput of the channel = MIN (the maximum throughput supported by the message channel, the maximum throughput of the system). The pre-allocated throughput of the channel = the sum of the pre-allocated throughputs for the channel queue. The pre-allocated throughput of the system = the sum of the pre-allocated throughputs of all channels. In one implementation, the orchestration formula includes a first formula and a second formula, the first formula being: the pre-allocated throughput of the channel is less than or equal to the maximum throughput of the channel, and the second formula being: the pre-allocated throughput of the system is less than or equal to the maximum real-time throughput of the system. That is, the first formula: the pre-allocated throughput of the channel <= the maximum throughput of the channel. The second formula: the pre-allocated throughput of the system <= the maximum real-time throughput of the system.

[0045] In one implementation, the calculating a new orchestration result based on the orchestration formula and the custom orchestration strategy includes: calculating a new candidate sending set and a pre-allocated throughput of a message queue according to the first formula, the maximum throughput capacity of a message channel, and the custom orchestration strategy; when it is determined that the second formula holds true according to the system real-time maximum throughput and the pre-allocated throughput, determining that the candidate sending set is a core sending queue set of the orchestration result; when it is determined that the second formula does not hold true according to the system real-time maximum throughput and the pre-allocated throughput, recalculating the pre-allocated throughput of each message channel according to a preset calculation process.

[0046] Specifically, first obtain the configuration parameters of each message channel:

[0047] Following the first formula, based on the maximum throughput of the channel, according to the customized orchestration strategy of each channel, the new candidate sending and waiting queue sets and the pre-allocated throughput of each candidate sending queue are calculated. According to the orchestration parameter calculation formula, the "system real-time maximum throughput" is calculated, and the "channel pre-allocated throughput" and "system pre-allocated total throughput" are calculated according to the pre-orchestration results.

[0048] If the second formula is established, the candidate sending queue set is determined as the new sending queue set, and the scheduling is completed. Otherwise, the pre-allocated throughput of each message channel is recalculated according to the preset calculation process.

[0049] In one implementation, the recalculating the pre-allocated throughput of each message channel according to a preset accounting process includes: calculating a revised pre-allocated total throughput according to the pre-allocated excess throughput, the system concurrency ratio, the total system concurrency ratio of the excess channels, the surplus throughput of the underfilled channels and the pre-allocated throughput; and calculating the new orchestration result according to the revised pre-allocated total throughput.

[0050] Specifically, first calculate the system pre-allocated excess throughput: system real-time maximum throughput = number of message scheduler instances * number of sending threads per instance * single-thread benchmark throughput; system pre-allocated total throughput = sum of pre-allocated throughputs of each channel; system pre-allocated excess throughput = system pre-allocated total throughput - system real-time maximum throughput.

[0051]

[0052] Calculate the pre-allocated excess throughput of each channel: pre-allocated excess throughput = pre-allocated total throughput - system real-time maximum throughput * system concurrency ratio.

[0053]

[0054] Calculate the surplus throughput of the non-excess channels and the total system concurrency ratio of the excess channels.

[0055]

[0056] Calculate the total approved pre-allocated throughput for each channel: For excess channels: pre-allocated throughput reduction = pre-allocated excess throughput - system concurrency ratio / total system concurrency ratio of excess channels * surplus throughput of unfilled channels; For non-oversubscribed channels: The pre-allocated throughput reduction is 0.

[0057] Corrected total pre-allocation throughput = pre-allocation throughput - pre-allocation throughput reduction.

[0058]

[0059] Following the first formula, based on the revised pre-allocated total throughput, a new candidate sending queue set is calculated according to the scheduling strategy of each message channel.

[0060] The scheduling process provided in the embodiment of the present application includes the following steps: If the real-time scheduling notification is a "call-out completion" notification, delete the corresponding mq_key from the "call-out difference set", and then compete for the scheduling authority. After obtaining the scheduling authority, the current thread executes the scheduling job and enters step b. Perform a scheduling reset operation at a specified interval (configurable parameters), save all queues in the "sending queue" collection to the "queue to be sent" collection, then clear the "sending queue" collection, cache the "scheduling reset time", "call-out difference set", and "call-out time", and end this scheduling. When the cached "call-out difference set" is not empty, if the "call-out time" has not timed out, end this scheduling; if the "call-out time" has timed out, clear the "call-out difference set" and "call-out time" caches, and enter step d to perform the call-in operation. When the cached "incoming difference set" is not empty, the throughput field of the queue index of the cached new sending queue is updated to the newly arranged flow control value, the new sending queue is saved in the "sending queue" set, and deleted from the "queue to be sent" set, the dispatching field of the queue index of the incoming difference set is updated to false, the task message is sent, and the scheduling ends. When there is no cached "outgoing difference set" or "incoming difference set", the scheduling process is performed, the flow control value of the new sending queue, the queue to be sent and the sending queue is calculated, the difference set between the old sending queue and the new sending queue is calculated, that is, the outgoing difference set, and the difference set between the new sending queue set and the old sending queue set is calculated, that is, the incoming difference set. If the outgoing difference set is not empty, the information such as "outgoing time", "outgoing difference set", "incoming difference set", "new sending queue and flow control value" is cached, the mq_key of the outgoing set is saved to the "queue to be sent" set, and then deleted from the "sending queue" set, and the scheduling ends. If the outgoing difference set is empty and the incoming difference set is not empty, update the throughput field of the queue index of the new sending queue to the newly arranged flow control value, save the new sending queue in the "sending queue" set, and delete it from the "queue to be sent" set, update the dispatching field of the queue index of the incoming difference set to false, send the task message, and end this scheduling. If both the outgoing difference set and the incoming difference set are empty, update the throughput field of the queue index of the new sending queue to the newly arranged flow control value, and end this scheduling. Regularly check the queues whose dispatching status dispatching is false for the old sending queue index, and compensate them with dispatching task messages.

[0061] In one implementation, after the queue distributor is notified through the task message to complete the call-out and call-in scheduling, the method further includes: distributing the messages in the message queue to the message asynchronous sender at a specified rate based on a token bucket flow control service.

[0062] The queue distributor listens to task messages and is dynamically bound to the queue one-to-one. The queue distributor is responsible for distributing queue messages to the asynchronous message sender at a specified rate.

[0063] The orchestration and scheduling service publishes a task message, which contains the queue identifier mq_id (format: partition code.mq_key).

[0064] After receiving the task message, the queue dispatcher competes for the dispatching rights of the queue through the distributed lock service. Only one queue dispatcher can obtain the dispatching rights of each queue. If the queue dispatcher successfully competes for the dispatching rights of the queue, the queue index dispatching is updated to true, and the queue dispatcher is successfully bound to the queue.

[0065] If the queue distributor exits abnormally, it returns a Nack or reject status to the task event notification queue. The message is automatically pushed to the program exception dead letter queue by the MQ server, and the dead letter queue resumes the interrupted distribution task.

[0066] The queue distribution process provided in the embodiment of the present application includes the following steps: First, check whether the queue is in the "queues to be sent" collection. If so, update the queue index status to 1, send a "call out confirmation" notification, and release the queue distribution permission. If it is not in the "queues to be sent" collection, query the queue index, calculate the queue distribution batch size, and obtain at most X (batch size) send tokens. Failed to obtain the send token, sleep (the duration is the configuration parameter), and continue with step a. Successfully obtain the send token, pull at most messages corresponding to the number of send tokens from the queue, and save the pulled messages to the buffer. Distribute the pulled messages to the sender. All distributions are successful, clear the buffer, and continue with step a. The sender returns a 509 response code and retries to distribute to other sender instances. Partially successful, the undistributed part is retried to distribute to other sender instances until the remaining number of retries is 0, and the retry service is called to set the retry timer for the message that failed to be distributed, clear the buffer, sleep (the duration is the configuration parameter), output the alarm log of insufficient concurrency, and continue with step a. All distributions fail, and the retry service is called to set a retry timer for the message that failed to be distributed, sleep (the duration is a configuration parameter), output an alarm log of insufficient concurrency, and continue with step a. The retry timer of the message is responsible for pushing the message back into the queue after the specified time arrives. If the message pulled is empty, delete the queue from the sending queue set, update the queue index status to 0, send a "distribution completed" notification, and release the distribution authority. In one implementation, after the token bucket-based flow control service distributes the messages in the message queue to the message asynchronous sender at a specified rate, it also includes: assigning the received message scheduling task to an idle message scheduling thread based on the asynchronous sender; and sending the message through the sending thread.

[0067] like Figure 2 As shown, the asynchronous message sender receives the batch message scheduling task from the queue distributor and immediately assigns it to an idle message sending thread, which then calls the business module to send the message through the message channel.

[0068] 1. The batch message scheduling interface of the message asynchronous sender receives the message scheduling tasks distributed by the queue distributor. The message scheduling tasks contain message path information (format: partition code.mq_key.mq_type. storage_type+message_id).

[0069] 2. The interface service first obtains at most X (number of tasks) threads from the idle sending thread set. If the obtained sending thread is zero, a response status code 509 is returned and the dispatcher reroutes it to other instances. Otherwise, it goes to step 3.

[0070] 3. Traverse the task list and perform idempotency check on each message. If the check fails, the message is discarded. For messages that pass the idempotency check, cache their message paths, set the message scheduling timeout timer through the timeout service, and accept the sending tasks with the number of sending thread tokens obtained.

[0071] 4. The accepted message sending tasks are handed over to the sending thread for processing, and the unaccepted tasks are returned to the queue distributor through the interface response, and the distributor reroutes them to other instances.

[0072] 5. The sending message line obtains storage_type and message_id from the message path information of the task message. When storage_type==1, the message body is obtained from the memory database with message_id as the key. When storage_type==2, the message body is obtained from the distributed storage engine with message_id as the key.

[0073] 6. Save the idempotence verification data, call the corresponding message channel's message sending business module to send the message, and the business module returns the sending result after the sending is completed, as well as whether to retry and the retry parameters when the sending fails. If the sending fails and can be retried, delete the idempotence verification data.

[0074] 7. Call the timeout service to delete the message scheduling timeout timer. If the message fails to be sent and is retried, call the retry service to set a retry timer for the message. If the message is sent successfully or fails to be sent and is not retried, delete the message index and the cached message path.

[0075] 8. If the sending timeout occurs, the message retry timer is responsible for calling the retry service to set the retry timer for the message after the sending timeout.

[0076] 9. The message sending thread completes the sending task and re-enters the idle thread set.

[0077] Figure 3 A schematic diagram of another message scheduling method provided in an embodiment of the present application is shown. Figure 3 As shown, the message queue service adopts a storage-computation separation architecture, separating the two key components of storage and computing. The system uses a two-level distributed storage service. The computing module is mainly composed of key modules such as message producer, orchestration scheduling, queue distributor, message sender, and general modules such as token bucket flow control, distributed lock, microservice registration center, idempotence check, sending timeout timer, and failure retry timer. The key steps of the embodiment of the present application are: 1. The queue storage service uses a two-level storage distributed storage solution. The first-level distributed memory database saves the data structure and small messages of the queue, and the second-level distributed key-value storage engine saves large messages; 2. The queue supports business-defined orchestration strategies. The message producer service first determines the namespace of the queue through the partition coding of the message channel. The data of the queue is stored in the namespace, and then the message is saved in the message area of ​​the namespace. Then, the mq_key of the queue is determined according to the business-defined orchestration strategy, and the index and ordered set of the queue are maintained based on the mq_key, and the scheduling notification event is triggered; 3. The orchestration scheduling service monitors the scheduling event or triggers the orchestration scheduling job at a fixed time, based on the orchestration The formulas "channel pre-allocated throughput <= channel maximum throughput" and "system pre-allocated throughput <= system real-time maximum throughput" calculate the new orchestration result according to the business-defined orchestration strategy through calculation, accounting, correction, confirmation and other steps. The call-out difference set and call-in difference set are calculated based on the new and old orchestration results, and the queue distributor is notified through task messages to complete the call-out and call-in scheduling; 4. The queue distributor listens to the task message, and the distributor is dynamically bound to the queue one-to-one. The queue distributor is responsible for distributing the queue messages to the message asynchronous sender at the specified rate; 5. The message asynchronous sender receives the batch message sending task from the queue distributor and immediately assigns it to the idle message sending thread. The message sending thread calls the business module to send messages through the message channel.

[0078] The message scheduling method provided in the embodiment of the present application supports business customized arrangement: the message queue middleware has a single function and a fixed mode, and does not support customized business arrangement. The embodiment of the present application supports business customized arrangement strategy, and the business decides which messages are sent first and have higher resource usage rights according to the business characteristics.

[0079] Support for hundreds of millions of queues: The more queues a message queue middleware has, the more its performance degrades. In actual project experience, the number of queues or topics supported by mainstream message queue middleware generally does not exceed a thousand, otherwise the performance drops sharply. The embodiment of the present application is a high-concurrency message queue service based on distributed storage, which decouples the message sending service from the message queue middleware. Its performance and expansion capabilities are not limited by the message queue middleware. The number of queues supported is the number of keys supported by distributed storage, which usually reaches 1 billion.

[0080] Good scalability: This message queue service adopts a storage-computing separation architecture with good scalability. Parameters are reserved to support businesses to control queue services through monitoring, dialing, big data, AI and other technologies or means to achieve more precise message sending control.

[0081] High overall utilization of system resources: Each queue in the message queue middleware exclusively occupies the computing resources of the producer, server, and consumer. In this proposal, all queues share the computing resources of the producer, server, and consumer, and are dynamically allocated according to the orchestration results, resulting in a higher overall utilization of system resources.

[0082] It should be noted that the execution subject of the message scheduling method provided in the embodiment of the present application may be a message scheduling device, or a control module in the message scheduling device for executing the message scheduling method. In the embodiment of the present application, the message scheduling device provided in the embodiment of the present application is described by taking the execution of the message scheduling method by the message scheduling device as an example.

[0083] Figure 4 Schematic diagram of the structure of a message scheduling device according to an embodiment of the present application. Figure 4 As shown, the message scheduling device 400 includes: a determination module 410 , a storage module 420 and an operation module 430 .

[0084] The determination module 410 is used to determine the namespace of the message queue according to the partition code of the message channel; the saving module 420 is used to save the message to the namespace; the running module 430 is used to determine the key of the message queue according to the custom orchestration strategy, maintain the index and ordered set of the message queue based on the key, and trigger the scheduling notification event.

[0085] In one implementation, the saving module 420 is used to save the message to the message area of ​​the namespace.

[0086] In one implementation, the running module 430 is used to determine the key of the message queue according to a custom orchestration strategy; query the index of the message queue from the index area of ​​the namespace based on the key as a conditional query; and maintain the index and ordered set of the message queue according to the status of the index.

[0087] In one implementation, the operation module 430 is used to respond to the operation scheduling notification event, calculate a new orchestration result based on the orchestration formula and the custom orchestration strategy; calculate the call-out difference set and the call-in difference set according to the new orchestration result and the old orchestration result; and complete the call-out and call-in scheduling by notifying the queue distributor through a task message.

[0088] In one implementation, the orchestration formula includes a first formula and a second formula, the first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity, and the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity.

[0089] In one implementation, the running module 430 is used to calculate a new candidate sending set and a pre-allocated throughput of the message queue according to the first formula, the maximum throughput capacity of the message channel and the custom orchestration strategy; when it is determined that the second formula is established according to the system real-time maximum throughput and the pre-allocated throughput, the candidate sending set is determined to be the core sending queue set of the orchestration result; when it is determined that the second formula is not established according to the system real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to a preset calculation process.

[0090] In one implementation, the operation module 430 is used to calculate a revised pre-allocated total throughput based on the pre-allocated excess throughput, the system concurrency ratio, the total system concurrency ratio of excess channels, the surplus throughput of underfull channels and the pre-allocated throughput; and calculate the new orchestration result based on the revised pre-allocated total throughput.

[0091] In one implementation, the operation module 430 is further configured to distribute the messages in the message queue to the message asynchronous sender at a specified rate based on a token bucket flow control service.

[0092] In one implementation, the running module 430 is further configured to assign the received message scheduling task to an idle message scheduling thread based on the asynchronous sender; and to send the message through the sending thread. In one implementation, the data structure of the message queue and small messages are stored in a first-level distributed memory database, and the large messages and the data structure of the message queue are stored in a second-level distributed key-value storage engine.

[0093] The message scheduling device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0094] The message scheduling device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0095] The message scheduling device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.

[0096] like Figure 5 As shown, an embodiment of the present application further provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores a program or instruction that can be executed on the processor 501, and the program or instruction, when executed by the processor 501, implements: determining the namespace of the message queue according to the partition coding of the message channel; saving the message to the namespace; determining the key of the message queue according to a custom orchestration strategy, maintaining the index and ordered set of the message queue based on the key as a condition, and triggering a scheduling notification event.

[0097] In one implementation, the message is saved in a message area of ​​the namespace.

[0098] In one implementation, the key of the message queue is determined according to a custom orchestration strategy; the index of the message queue is queried from the index area of ​​the namespace based on the key as a conditional query; and the index and ordered set of the message queue are maintained according to the state of the index.

[0099] In one implementation, in response to the run scheduling notification event, a new scheduling result is calculated based on the scheduling formula and the custom scheduling strategy; a call-out difference set and a call-in difference set are calculated based on the new scheduling result and the old scheduling result; and a queue distributor is notified through a task message to complete the call-out and call-in scheduling.

[0100] In one implementation, the orchestration formula includes a first formula and a second formula, the first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity, and the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity.

[0101] In one implementation, a new candidate sending set and a pre-allocated throughput of a message queue are calculated based on the first formula, the maximum throughput capacity of a message channel, and a custom orchestration strategy; when it is determined that the second formula holds true based on the system real-time maximum throughput and the pre-allocated throughput, the candidate sending set is determined to be a core sending queue set of the orchestration result; when it is determined that the second formula does not hold true based on the system real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to a preset calculation process.

[0102] In one implementation, a revised pre-allocated total throughput is calculated based on the pre-allocated excess throughput, the system concurrency ratio, the total system concurrency ratio of excess channels, the surplus throughput of underfull channels, and the pre-allocated throughput; and the new orchestration result is calculated based on the revised pre-allocated total throughput.

[0103] In one implementation, after the queue distributor is notified of the completion of the call-out and call-in scheduling through the task message, the messages in the message queue are distributed to the message asynchronous sender at a specified rate based on the token bucket flow control service.

[0104] In one implementation, after the token bucket-based flow control service distributes the messages in the message queue to the message asynchronous sender at a specified rate, the asynchronous sender assigns the received message scheduling task to an idle message scheduling thread; and sends the message through the sending thread.

[0105] In one implementation, the data structure of the message queue and small messages are stored in a first-level distributed memory database, and the large messages and the data structure of the message queue are stored in a second-level distributed key-value storage engine.

[0106] The specific execution steps can refer to the various steps of the above-mentioned message scheduling method embodiment, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.

[0107] It should be noted that the electronic devices in the embodiments of the present application include: servers, terminals, or other devices except terminals.

[0108] The above electronic device structure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, the input unit may include a graphics processing unit (GPU) and a microphone, and the display unit may be configured with a display panel in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit includes a touch panel and at least one of other input devices. The touch panel is also called a touch screen. Other input devices may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0109] The memory can be used to store software programs and various data. The memory may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory may include a volatile memory or a non-volatile memory, or the memory may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM).

[0110] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to the operating system, user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor.

[0111] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned message scheduling method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0112] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as ROM, RAM, magnetic disk or optical disk.

[0113] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the various processes of the embodiment of the above-mentioned message scheduling method and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0114] It should be noted that, in this article, the term "comprises", "includes" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0115] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0116] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A message scheduling method, characterized in that: include: Determine the namespace of the message queue based on the partition code of the message channel; Saving the message to the namespace; The key of the message queue is determined according to a custom orchestration strategy, the index and ordered set of the message queue are maintained based on the key, and a scheduling notification event is triggered.

2. The method according to claim 1, characterized in that The step of saving the message to the namespace includes: The message is saved to the message area of ​​the namespace.

3. The method according to claim 1, characterized in that Determining the key of the message queue according to the custom orchestration strategy, and maintaining the index and ordered set of the message queue based on the key, includes: Determining a key of the message queue according to a custom orchestration strategy; Querying the index of the message queue from the index area of ​​the namespace based on the key as a conditional query; According to the state of the index, the index and the ordered set of the message queue are maintained.

4. The method according to claim 1, characterized in that: The triggering scheduling notification event includes: In response to the operation scheduling notification event, a new orchestration result is calculated based on an orchestration formula and the user-defined orchestration strategy; According to the new arrangement result and the old arrangement result, a call-out difference set and a call-in difference set are calculated; The queue distributor is notified through task messages to complete the call-out and call-in scheduling.

5. The method according to claim 4, characterized in that The orchestration formula includes a first formula and a second formula, the first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity, and the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity.

6. The method according to claim 5, characterized in that The calculating a new orchestration result based on the orchestration formula and the custom orchestration strategy includes: According to the first formula, the maximum throughput capacity of the message channel and the custom scheduling strategy, the pre-allocated throughput of the new candidate sending set and the message queue is calculated; When it is determined that the second formula holds true according to the system real-time maximum throughput and the pre-allocated throughput, determining the candidate sending queue set as the core sending queue set of the orchestration result; When it is determined that the second formula is not valid according to the system real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to a preset calculation process.

7. The method according to claim 6, characterized in that The recalculating the pre-allocated throughput of each message channel according to the preset calculation process includes: The corrected total pre-allocated throughput is calculated based on the pre-allocated excess throughput, the system concurrency ratio, the total system concurrency ratio of the excess channels, the surplus throughput of the under-full channels, and the pre-allocated throughput. The new scheduling result is calculated according to the revised pre-allocated total throughput.

8. The method according to claim 4, characterized in that After the queue distributor is notified through the task message to complete the call-out and call-in scheduling, the method further includes: The token bucket flow control service distributes messages from the message queue to the asynchronous message sender at a specified rate.

9. The method according to claim 8, characterized in that After the token bucket flow control service distributes the messages in the message queue to the message asynchronous sender at a specified rate, the method further includes: Assign the received message scheduling tasks to the idle message scheduling threads based on the asynchronous sender; The message is sent via the sending thread.

10. The method according to claim 1, characterized in that The data structure and small messages of the message queue are saved through the first-level distributed memory database, and the large messages and data structure of the message queue are saved through the second-level distributed key-value storage engine.

Citation Information

Patent Citations

  • Distributed cache system as well as cache synchronization method and device

    CN108829713A

  • Asynchronous message interface fusing control method and device, computer equipment and storage medium

    CN109743358A

  • Message consumption method and device, computing equipment and storage medium

    CN113342541A

  • Message queue processing method, medium, equipment and system

    CN113505012A

  • Semantic method and device based on message middleware

    CN114416405A