Resource request method, apparatus and system
By setting up a plugin in the message processing platform to periodically count message volume and calculate target resource volume, and request resource allocation in advance, the problems of message backlog and resource allocation lag are solved, thereby improving message processing efficiency and user experience.
Patent Information
- Application Number
- CN202210156095.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-21
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2042-02-21
AI Technical Summary
In existing technologies, message processing platforms are prone to message backlog when the message volume is too large, and the lag in resource allocation leads to untimely message processing, affecting platform reliability and user experience.
By setting up a plugin in the message processing platform, the number of messages received and processed can be periodically counted. The target amount of resources can be calculated using a preset algorithm, and a resource acquisition request can be generated to request the resource management platform to allocate resources in advance, thus avoiding message backlog.
It enables timely resource addition before message backlog, improves message processing efficiency, avoids backlog, enhances user experience, and reduces manpower and maintenance costs.
Smart Images

Figure CN114528109B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a resource request method, apparatus, and system. Background Technology
[0002] In network platforms with a large volume of message exchanges, timely message processing is crucial for ensuring platform reliability and stability. Currently, network platforms can use middleware systems to relay messages. When a message is sent from the front end to the back end, it is forwarded to the appropriate message processing platform.
[0003] When the message volume is too large, the message processing platform may be unable to process these messages in a timely manner, leading to message backlog. In existing technologies, resource management platforms can detect when a message backlog occurs on the message processing platform and allocate resources to the platform based on the amount of backlogged messages, thereby enabling the platform to process the backlogged messages promptly.
[0004] However, this resource allocation method has a lag, which can easily lead to untimely message processing. Summary of the Invention
[0005] This application provides a resource request method, apparatus, and system to solve the problem of untimely message processing that is common in the prior art.
[0006] Firstly, this application provides a resource request method applied to a message processing platform, comprising:
[0007] The message receiving volume and message processing volume of the message processing platform are periodically statistically analyzed.
[0008] The target resource quantity is calculated based on the message reception volume, message processing volume, and preset algorithm within each period of a preset time period.
[0009] Based on the target resource quantity and the resource parameters of the message processing platform, a resource acquisition request is generated and sent, which is used to request resources from the resource management platform.
[0010] Optionally, the step of calculating the target resource quantity based on the message reception volume, the message processing volume, and a preset algorithm within each period of a preset time period includes:
[0011] Within a preset time period, the average message processing speed is determined based on the message processing volume and cycle duration in each period.
[0012] Within a preset time period, the average message backlog is determined based on the message reception volume and message processing volume in each period.
[0013] The target resource quantity is determined based on the average message processing speed and the average message backlog.
[0014] Optionally, generating a resource acquisition request based on the target resource quantity and the resource parameters of the message processing platform includes:
[0015] Based on the target resource quantity and the resource parameters, determine the required resource quantity;
[0016] The resource acquisition request is generated based on the stated resource quantity.
[0017] Optionally, when the message processing platform is deployed using containerization technology, the number of resources is the number of replicas, and the resource acquisition request is used to request the resource management platform to increase the number of replicas of the message processing platform.
[0018] Optionally, when the message processing platform is deployed using non-containerized technology, the number of resources is the number of interfaces, and the resource acquisition request is used to request the resource management platform to increase the number of interfaces of the message processing platform.
[0019] Optionally, before calculating the target resource quantity based on the message reception volume, the message processing volume, and the preset algorithm within each period of a preset time period, the method further includes:
[0020] The queuing percentage for each period is determined based on the message reception volume and message processing volume within each period.
[0021] The number of backlogs where the queue percentage exceeds a threshold is counted within a preset time period;
[0022] When the number of backlogs is less than the number of times, the target resource quantity is determined according to a preset value.
[0023] Optionally, determining the queuing percentage for each period based on the message reception volume and message processing volume within each period includes:
[0024] The message queuing volume is determined based on the difference between the message reception volume and the message processing volume.
[0025] The queuing ratio is determined based on the ratio of the message queuing volume to the message receiving volume.
[0026] Optionally, before calculating the target resource quantity based on the message reception volume, the message processing volume, and the preset algorithm within each period of a preset time period, the method further includes:
[0027] The current message processing speed is determined based on the message processing volume and cycle duration within the current period.
[0028] The probability of message backlog is determined based on the current message processing speed and the amount of messages received in the current period;
[0029] When the probability of message backlog is less than the probability threshold, the target resource quantity is determined according to a preset value.
[0030] Optionally, determining the message backlog probability based on the current message processing speed and the message reception volume within the current period includes:
[0031] The actual processing time is determined based on the ratio of the number of messages received to the current message processing speed.
[0032] The message backlog probability is determined based on the ratio of the actual processing time to the cycle duration.
[0033] Optionally, the method further includes:
[0034] Obtain the historical message reception volume for the next cycle from the historical records of the message processing platform;
[0035] The historical processing time is determined based on the ratio of the historical message reception volume to the current message processing speed.
[0036] The historical backlog probability is determined based on the ratio of the historical processing time to the cycle duration.
[0037] The message backlog probability is updated based on the weighted sum of the message backlog probability and the historical backlog probability.
[0038] Secondly, this application provides a resource request apparatus applied to a message processing platform, comprising:
[0039] The acquisition module is used to periodically count the number of messages received and processed by the message processing platform.
[0040] The processing module is used to calculate the target resource quantity based on the message reception volume, the message processing volume, and the preset algorithm in each period within a preset time period; and to generate and send a resource acquisition request based on the target resource quantity and the resource parameters of the message processing platform, wherein the resource acquisition request is used to request resources from the resource management platform.
[0041] Optionally, the processing module is specifically used for:
[0042] Within a preset time period, the average message processing speed is determined based on the message processing volume and cycle duration in each period.
[0043] Within a preset time period, the average message backlog is determined based on the message reception volume and message processing volume in each period.
[0044] The target resource quantity is determined based on the average message processing speed and the average message backlog.
[0045] Optionally, the processing module is specifically used for:
[0046] Based on the target resource quantity and the resource parameters, determine the required resource quantity;
[0047] The resource acquisition request is generated based on the stated resource quantity.
[0048] Optionally, when the message processing platform is deployed using containerization technology, the number of resources is the number of replicas, and the resource acquisition request is used to request the resource management platform to increase the number of replicas of the message processing platform.
[0049] Optionally, when the message processing platform is deployed using non-containerized technology, the number of resources is the number of interfaces, and the resource acquisition request is used to request the resource management platform to increase the number of interfaces of the message processing platform.
[0050] Optionally, the processing module is further configured to:
[0051] The queuing percentage for each period is determined based on the message reception volume and message processing volume within each period.
[0052] The number of backlogs where the queue percentage exceeds a threshold is counted within a preset time period;
[0053] When the number of backlogs is less than the number of times, the target resource quantity is determined according to a preset value.
[0054] Optionally, the processing module is specifically used for:
[0055] The message queuing volume is determined based on the difference between the message reception volume and the message processing volume.
[0056] The queuing ratio is determined based on the ratio of the message queuing volume to the message receiving volume.
[0057] Optionally, the processing module is further configured to:
[0058] The current message processing speed is determined based on the message processing volume and cycle duration within the current period.
[0059] The probability of message backlog is determined based on the current message processing speed and the amount of messages received in the current period;
[0060] When the probability of message backlog is less than the probability threshold, the target resource quantity is determined according to a preset value.
[0061] Optionally, the processing module is specifically used for:
[0062] The actual processing time is determined based on the ratio of the number of messages received to the current message processing speed.
[0063] The message backlog probability is determined based on the ratio of the actual processing time to the cycle duration.
[0064] Optionally, the processing module is specifically used for:
[0065] Obtain the historical message reception volume for the next cycle from the historical records of the message processing platform;
[0066] The historical processing time is determined based on the ratio of the historical message reception volume to the current message processing speed.
[0067] The historical backlog probability is determined based on the ratio of the historical processing time to the cycle duration.
[0068] The message backlog probability is updated based on the weighted sum of the message backlog probability and the historical backlog probability.
[0069] Thirdly, this application provides a message processing system, including: a resource management platform and at least one message processing platform, wherein the resource management platform is used to manage resources in the message processing system, each message processing platform is used to process a type of message, each message processing platform corresponds to at least one server, and the server has a container replica or an interface deployed thereon.
[0070] Fourthly, this application provides a readable storage medium storing a computer program, wherein when at least one processor of a message processing platform executes the computer program, the message processing platform executes the resource request method of the first aspect and any possible design of the first aspect.
[0071] Fifthly, this application provides a computer program product comprising a computer program that, when at least one processor of a message processing platform executes the computer program, enables the message processing platform to execute the resource request method of the first aspect and any possible design of the first aspect.
[0072] The resource request method provided in this application periodically analyzes message processing data, including the number of messages received and processed. After monitoring the message reception and processing volumes for each period within a preset time period, the method periodically calculates the target resource quantity using these data. Based on the resource parameters and the target resource quantity, the method calculates the required resource quantity. A resource acquisition request is then generated based on this request quantity. This request is sent to the resource management platform, enabling the platform to allocate resources accordingly. This improves the processing efficiency of the resource processing platform, avoids message backlog through message distribution, and prevents resource waste in the resource management platform. Attached Figure Description
[0073] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0074] Figure 1 This application provides a schematic diagram of a system flow for requesting resources, as shown in one embodiment.
[0075] Figure 2 A flowchart illustrating a resource request method provided in one embodiment of this application;
[0076] Figure 3 A flowchart illustrating a resource request method provided in one embodiment of this application;
[0077] Figure 4 A flowchart illustrating a resource request method provided in one embodiment of this application;
[0078] Figure 5 This is a schematic diagram of the structure of a resource request device provided in an embodiment of this application;
[0079] Figure 6 This is a schematic diagram of the structure of a message processing system provided in an embodiment of this application. Detailed Implementation
[0080] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0081] The terms "first," "second," "third," "fourth," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be used interchangeably where appropriate. For example, without departing from the scope of this document, first information can also be referred to as second information, and similarly, second information can also be referred to as first information.
[0082] Depending on the context, the word "if" as used here can be interpreted as "when," "when," or "in response to determination."
[0083] Furthermore, as used herein, the singular forms “a,” “one,” and “the” are intended to also include the plural forms, unless the context indicates otherwise.
[0084] It should be further understood that the terms "comprising" or "including" indicate the presence of the said features, steps, operations, elements, components, items, types, and / or groups, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, types, and / or groups.
[0085] The terms “or” and “and / or” as used herein are interpreted as inclusive, or mean any one or any combination thereof. Therefore, “A, B, or C” or “A, B, and / or C” means “any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C”. Exceptions to this definition occur only when combinations of elements, functions, steps, or operations are inherently mutually exclusive in some way.
[0086] In network platforms with a large volume of message exchanges, timely message processing is crucial for ensuring platform reliability and stability. Currently, network platforms can use middleware to relay messages. In a message processing system, this middleware can forward messages to the appropriate message processing platform when the frontend sends a message to the backend. JMQ is a highly available and reliable message middleware system. This middleware system is widely used in scenarios such as order generation, payment processing, and warehouse management.
[0087] In practical use, the message volume in a message processing system is constantly changing. However, the processing efficiency of each message processing platform within the system is fixed; that is, the consumption capacity of message consumers is constant. Therefore, as the message volume increases, there may be situations where message processing platforms are unable to process these messages in a timely manner. This situation may further lead to message backlog, message processing anomalies, and other problems.
[0088] In existing technologies, a resource management platform can send a message alert when it detects a backlog of messages on a message processing platform, reminding the administrator to address the backlog. Upon receiving the alert, the administrator can assess the backlog and generate a resource acquisition request based on the assessment result. This request can then request resources from the resource management platform to allocate to the message processing platform, enabling resource expansion during a backlog. Alternatively, the message processing platform can also generate a resource acquisition request based on the amount of backlogged messages when it detects a backlog.
[0089] However, this method of resource acquisition is often delayed. Message processing platforms typically only request resources after a backlog of messages has already occurred. This can easily lead to untimely message processing, potentially causing losses for users or resulting in a poor user experience.
[0090] To address the aforementioned issues, this application proposes a resource request method. This application implements a plugin within a message processing platform to periodically statistically analyze the platform's message reception and processing volumes. The plugin can also determine whether message backlog is likely within a preset time period based on the message reception and processing volumes in each period. If the plugin anticipates potential message backlog, it can calculate a target resource quantity based on the message reception and processing volumes in each period and a preset algorithm. This target resource quantity indicates the resources the plugin estimates are needed to process the potentially backlogged messages. In this message processing platform, resource parameters are typically related to the message processing program. When the message processing program runs in a replica of a container, the platform's resource parameters indicate the number of resources included in a replica. Otherwise, when the message processing program retrieves messages through an interface, the platform's resource parameters indicate the number of resources included in an interface. The plugin can obtain these resource parameters from the message processing platform. The plugin can also determine the required resource quantity based on the target resource quantity and the resource parameters. This plugin can generate a resource acquisition request based on the required number of resources. This request can then be sent to the resource management platform.
[0091] This application, through the aforementioned methods, can proactively detect and automatically and promptly increase resources when there are signs of escalating impact, thereby improving message processing efficiency and preventing message backlog. Using this method can effectively prevent the spread of harm and avoid incalculable losses. Furthermore, this method can enhance user experience and system processing efficiency, while reducing labor costs and maintenance time costs.
[0092] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0093] Figure 1 This illustration shows a system flowchart for resource requests according to an embodiment of this application. The consumer end is a message processing platform used to process messages. The message processing platform can monitor itself by installing plugins. Based on the monitoring results, the message processing platform can determine its own message processing capacity. The message processing platform can also determine the message queuing status in the message queue based on the monitoring results. The message processing platform can pre-store backlog processing rules. When the message processing queue determines that the situation meets the backlog processing rules, the message processing platform can trigger backlog processing. During the backlog processing, the message processing platform can calculate the required amount of resources. The message processing platform can request resources from the resource management platform. After receiving resources allocated by the resource management platform, the message processing platform can expand its resource allocation.
[0094] In one example, the resources allocated by the resource management platform to the message processing platform can be dynamic resources. The message processing platform can use the resource for a certain period after acquiring it. After this period, the resource quantity of the message processing platform reverts to its initial value. The resource allocated to the message processing platform by the resource management platform is released. The resource management platform can then reassign the resource to another message management platform.
[0095] In one example, the message processing platform may include a management server with plugins installed. This management server can retrieve all messages required by the platform and send them to other servers within the platform for processing. The plugins in the management server can also perform message statistics for the platform.
[0096] In another example, each server in the message processing platform can have a statistics plugin installed. This plugin can be used to track message queuing and processing status on each server. The message processing platform can also have a management plugin installed. This plugin aggregates the statistical results from all the statistics plugins on the platform.
[0097] In this application, a message processing platform is used as the execution entity to perform the resource request method of the following embodiments. Specifically, the execution entity can be a hardware device of the message processing platform, a software application implementing the following embodiments in the message processing platform, a computer-readable storage medium on which the software application implementing the following embodiments is installed, or code implementing the software application of the following embodiments.
[0098] Figure 2 A flowchart illustrating a resource request method according to an embodiment of this application is shown. Figure 1 Based on the illustrated embodiments, as Figure 2 As shown, with the message processing platform as the execution entity, the method in this embodiment may include the following steps:
[0099] S101. Periodically count the number of messages received and processed on the message processing platform.
[0100] In this embodiment, a plugin can be installed in the message processing platform. This plugin can be java-javaagent:MessageBacklog.jar. This plugin is used to monitor messages within the message processing platform. The plugin is typically introduced into the message processing platform via a startup script or hard-coded methods. The message processing platform can use this plugin to scan the compiled code of its business system. The compiled code of the business system can be class bytecode. After completing the scan, the plugin can automatically add bytecode to the message consumption methods in the business system of the message processing platform. The message consumption methods refer to the functions / methods / classes in the message processing platform that implement the specific message consumption process. The bytecode is used to add logical functionality. For example, after adding this bytecode, statistical logic can be added before and after message consumption in the business functions of the business system. That is, the message processing platform can perform statistics on received messages before message processing. The message processing platform can also perform statistics on processed messages after message processing.
[0101] For example, project A may include multiple message types such as topic1 and topic2. Different message types can be assigned to different message processing platforms for processing. A single message processing platform can handle at least one message type.
[0102] The message processing platform can periodically analyze message processing data. This data can include both the number of messages received and processed. For example, Table 1 shows the message processing data collected by the platform over multiple periods with a period length of 5 minutes.
[0103] Table 1
[0104] Start time Joining the team deal with End time 2021 / 8 / 24 14:05 3000 2500 2021 / 8 / 24 14:10 2021 / 8 / 24 14:10 3500 3200 2021 / 8 / 25 14:15 2021 / 8 / 24 14:15 2000 1300 2021 / 8 / 26 14:20 2021 / 8 / 24 14:25 3000 2500 2021 / 8 / 27 14:30
[0105] S102. Calculate the target resource quantity based on the message reception volume, message processing volume, and preset algorithm within each period of the preset time period.
[0106] In this embodiment, the message processing platform can calculate a target resource quantity when message backlog occurs or when a potential backlog is anticipated. This target resource quantity indicates the amount of resources required to process existing backlogged messages or messages expected to experience backlog. The message processing platform can periodically calculate the target resource quantity using the message reception and processing volumes within each period of a preset time frame.
[0107] In one example, the calculation process for the target resource quantity may specifically include the following steps:
[0108] Step 1: Within a preset time period, the message processing platform determines the average message processing speed based on the message processing volume and cycle duration within each period.
[0109] In this step, the message processing platform can determine the message processing speed for each period by calculating the ratio of message processing volume to period length within a preset time period. For example, as shown in Table 1, the message processing speed for the period from 14:05 to 14:10 on August 24, 2021, is 2500 / 5 = 500. The message processing platform can calculate the average message processing speed by calculating the average of the message processing speeds for each period within the preset time period. For example, as shown in Table 1, the message processing speeds for each period within the preset time period from 14:05 to 14:25 on August 24, 2021, are 500, 640, 260, and 500 respectively. The average message processing speed can be (500 + 640 + 260 + 500) / 4 = 475.
[0110] Alternatively, the message processing platform can determine the average message processing speed by statistically analyzing the total message volume within the preset time period and calculating the ratio of this total volume to the duration of the preset time period. For example, as shown in Table 1, during the preset time period from 14:05 to 14:25 on August 24, 2021, the total message volume was 9500. The average message processing speed was 9500 / 20 = 475.
[0111] Step 2: Within a preset time period, the message processing platform determines the average message backlog based on the message reception and processing volume in each period.
[0112] In this step, the message processing platform can determine the message backlog for each period by calculating the difference between the number of messages received and processed within each period of the preset time period. For example, as shown in Table 1, the message backlog for the period from 14:05 to 14:10 on August 24, 2021, is 3000 - 2500 = 500. The message processing platform can calculate the average message backlog by calculating the average of the message backlog for each period within the preset time period. For example, as shown in Table 1, the message backlog for each period from 14:05 to 14:25 on August 24, 2021, is 500, 300, 700, and 500 respectively. The average message backlog can be calculated as (500 + 300 + 700 + 500) / 4 = 500.
[0113] Alternatively, the message processing platform can calculate the total message backlog by statistically analyzing the total number of messages received and processed within the preset time period, and then calculating the difference between them. For example, as shown in Table 1, during the preset time period from 14:05 to 14:25 on August 24, 2021, the total number of messages received was 11,500, and the total number of messages processed was 9,500. The message processing platform can calculate the total message backlog as 11,500 - 9,500 = 2,000. The average message backlog could be 2,000 / 4 = 500.
[0114] Step 3: The message processing platform determines the target resource quantity based on the average message processing speed and the average message backlog.
[0115] In this step, the message processing platform can calculate the target resource quantity based on the average message processing speed and average message backlog obtained in the previous two steps. The formula for calculating the target resource quantity is as follows:
[0116] Target resource quantity = Average message backlog / Average message processing speed
[0117] The target resource volume can be understood as the processing time required for the current resources of the message processing platform to process the backlog of messages.
[0118] S103. Based on the target resource quantity and the resource parameters of the message processing platform, generate and send a resource acquisition request. The resource acquisition request is used to request resources from the resource management platform.
[0119] In this embodiment, because the message processing platform is always operational, it cannot process the backlog of messages. To process these backlogged messages, the resource management server needs to allocate resources to the message processing platform to improve its processing capacity. The message processing platform can calculate the required resource quantity based on its resource parameters and the target resource quantity. The platform can then generate a resource acquisition request based on this message quantity. This request can be sent to the resource management platform. The resource management platform then allocates resources to the message processing platform based on the resource acquisition request.
[0120] In one example, the specific steps by which a message processing platform generates a resource acquisition request based on the target resource quantity and resource parameters may include:
[0121] Step 1: The message processing platform determines the required resource quantity based on the target resource quantity and resource parameters.
[0122] In this step, the target resource quantity can be understood as the time required to process the backlog of messages using the current resources of the message processing platform. When the time duration is in units of time, the resources required to process the backlog of messages within a unit of time can also be calculated based on this target resource quantity.
[0123] In one implementation, when the message processing platform is deployed using containerization technology, the smallest unit of resources in the platform is a replica. The number of resources can be described using the number of replicas. Resource parameters describe the resources in each replica. The message processing platform can determine the number of resources that need to be added based on the ratio of the resources required to process the backlog of messages within a unit of time to the resource parameters. This number of resources is the number of replicas. That is, when the number of resource replicas is increased in the message processing platform, the backlog of messages can be processed within a unit of time.
[0124] In another implementation, when the message processing platform is deployed using non-containerized technology, the smallest unit of resource in the platform is the interface. The quantity of this resource can be described by the number of interfaces. Resource parameters describe the resources within each interface. The message processing platform can determine the number of additional resources needed based on the ratio of the resources required to process the backlog of messages within a unit of time to the resource parameters. This number of resources is the number of interfaces. When the number of interfaces is increased by this resource quantity, the backlog of messages can be processed within a unit of time.
[0125] Step 2: The message processing platform generates a resource acquisition request based on the resource quantity.
[0126] In this step, the message processing platform can generate a resource acquisition request based on the resource quantity calculated in the previous step.
[0127] In one implementation, when the message processing platform is deployed using containerization technology, the resource acquisition request is used to request the resource management platform to increase the number of replicas of the message processing platform.
[0128] In another implementation, when the message processing platform is deployed using non-containerized technology, the resource acquisition request is used to request the resource management platform to increase the number of interfaces of the message processing platform.
[0129] In one example, when a message processing platform is deployed using containerization technology, each server can run at least one container. Each container has at least one replica. When there are still some idle resources in the message processing platform, the platform can increase the number of replicas, thereby increasing the resources available for message processing. For example, the platform can use the following instructions to increase the number of resources through a rolling upgrade.
[0130] kubectl scale deployment nginx-deployment--replicas 5
[0131] This command is used to indicate the number of replicas in the container. Specifically, `--replicas 5` indicates that the number of replicas should be changed to 5. `-deployment` specifies the deployment file for the project corresponding to this message processing platform.
[0132] In another example, when the message processing platform is deployed using non-containerized technology, each server can run at least one interface program. The message processing platform can use an interface by running an interface program. The resource management platform can send the address of the newly allocated server to the message processing platform. The message processing platform can then use remote control code to connect to the server and store local information on it.
[0133] scp -P 22remote@www.test.com: / usr / local / test.jar / home / export
[0134] The message processing platform can connect to the www.test.com server and store local information in the / usr / local / test.jar / home / export directory. The `scp -P 22 remote` command is used for remote control. The above operations are used to remotely deploy this newly allocated server. After deployment, the server...
[0135] Once the remote deployment of local files is complete, the message processing platform can start the interface using the script command . / start.sh.
[0136] The resource request method provided in this application allows a message processing platform to periodically track message processing data. This data can include the number of messages received and processed. After monitoring the message reception and processing volumes for each period within a preset timeframe, the platform periodically calculates the target resource quantity using these data. The platform then calculates the required resource quantity based on its resource parameters and the target resource quantity. Based on this resource quantity, the platform generates a resource acquisition request and sends it to a resource management platform. The resource management platform allocates resources to the message processing platform based on the request. This application improves the platform's processing efficiency by increasing resources when message backlog occurs, avoids backlog through message distribution, and prevents resource waste in the resource management platform.
[0137] Figure 3 A flowchart illustrating a resource request method according to an embodiment of this application is shown. Figure 2 Based on the embodiments, such as Figure 3 As shown, with the message processing platform as the execution entity, the method in this embodiment may include the following steps:
[0138] S201. Periodically count the number of messages received and processed on the message processing platform.
[0139] Among them, step S201 and Figure 2 The implementation of step S101 in the embodiment is similar, and will not be repeated here.
[0140] S202. Determine the queuing percentage for each period based on the amount of messages received and processed in each period.
[0141] In this embodiment, after the message processing platform obtains the message reception and message processing volume in each cycle, it can calculate the queuing ratio within that cycle based on the message reception and message processing volume. This queuing ratio can be used to indicate the ratio of messages that have not been processed at the end of the cycle to the messages that were enqueued in that cycle.
[0142] In one example, the calculation process for this queuing percentage may specifically include the following steps:
[0143] Step 1: The message processing platform determines the message queue size based on the difference between the number of messages received and the number of messages processed.
[0144] Step 2: The message processing platform determines the queuing ratio based on the ratio of message queuing volume to message reception volume.
[0145] S203. Count the number of backlogs where the queuing percentage is greater than the percentage threshold within a preset time period.
[0146] In this embodiment, the message processing platform can preset some statistical rules. These statistical rules can be used to determine whether message backlog has occurred or whether message backlog is likely to occur. For example, the statistical rule can be used to count the number of backlogs within a preset time period where the queuing percentage is greater than a percentage threshold. The statistical rules can also preset a frequency threshold. The message processing platform can determine whether message backlog has occurred by comparing the number of backlogs with the frequency threshold. When the number of backlogs is less than the frequency threshold, the message processing platform can continue to execute step S204. When the number of backlogs is greater than or equal to the frequency threshold, the message processing platform can continue to execute step S205. For example, the frequency threshold can be 2 times, 3 times, etc. The preset time period can be determined according to the system accuracy. When the system needs to maintain a high level of accuracy and stability, the preset time period can be 2 minutes. When the system can use a lower level of accuracy and stability, the preset time period can be 5 minutes.
[0147] S204. When the number of backlogs is less than the number of times, the target resource quantity is determined according to the preset value.
[0148] In this embodiment, when the number of backlogs is less than a preset number, it can be considered that there is no message backlog in the message processing platform. Therefore, the message processing voucher can determine the target resource amount as a preset value. This preset value can be a parameter such as 0 or -1, used to indicate that the message processing voucher does not need to request resources in this case. When this step is executed, the calculation of this cycle ends.
[0149] S205. When the number of message backlogs is greater than or equal to the number of times, the target resource quantity is calculated based on the message reception volume, message processing volume and preset algorithm in each period within the preset time period.
[0150] S206. Based on the target resource quantity and the resource parameters of the message processing platform, generate and send a resource acquisition request. The resource acquisition request is used to request resources from the resource management platform.
[0151] Among them, steps S205 and S206 are related to Figure 2 Steps S102 and S103 in the embodiment are implemented in a similar manner, and will not be described again here.
[0152] The resource request method provided in this application allows the message processing platform to periodically analyze message processing data. This data can include the number of messages received and processed. The platform can determine the queuing percentage for each period based on these data. It can also count the number of backlogs where the queuing percentage exceeds a threshold within a preset time period. When the number of backlogs falls below a threshold, the platform terminates the calculation for that period. When the probability of message backlog is greater than or equal to a probability threshold, the platform calculates the target resource quantity based on the message received and processed data within each period and a preset algorithm. The platform then calculates the required resource quantity based on its resource parameters and the target resource quantity. Based on this quantity, the platform generates a resource acquisition request. This application improves the platform's processing efficiency by increasing the resource quantity when message backlog occurs, and avoids backlog through message diversion. In this application, the resource processing platform can also determine whether there is a backlog and request resources in a timely manner when a backlog occurs, thereby avoiding the waste of resources in the resource management platform.
[0153] Figure 4 A flowchart illustrating a resource request method according to an embodiment of this application is shown. Figure 2 and Figure 3 Based on the embodiments, such as Figure 4 As shown, with the message processing platform as the execution entity, the method in this embodiment may include the following steps:
[0154] S301, Periodically calculate the message reception and message processing volume of the message processing platform.
[0155] Among them, step S301 and Figure 2 The implementation of step S101 in the embodiment is similar, and will not be repeated here.
[0156] S302. Determine the current message processing speed based on the message processing volume and cycle duration within the current cycle.
[0157] In this embodiment, the message processing platform can calculate the message processing volume within the current period. Based on the ratio of this message processing volume to the period duration, the message processing platform can determine the current message processing speed within the current period.
[0158] S303. Determine the message backlog probability based on the current message processing speed and the amount of messages received in the current period.
[0159] In this embodiment, the message processing platform can also count the number of messages received within the current period. The platform can determine the actual processing time based on the ratio of the current message processing speed to the number of messages received within the current period. Furthermore, the platform can determine the message backlog probability based on the ratio of the actual processing time to the period duration. When the platform can process all messages within the period, the message backlog probability is a value less than or equal to 1. When the platform cannot process all messages within the period, the message backlog probability is a value greater than 1.
[0160] In one example, the message processing platform can also obtain the historical message reception volume corresponding to the next period of the current period. For example, the current period is from 14:05 to 14:10 on August 24, 2021. The next period is from 14:10 to 14:15 on August 24, 2021. The historical message reception volume can be the message reception volume within the period from 14:10 to 14:15 on August 23, 2021. The message processing platform can determine the historical processing time based on the ratio of historical message reception volume to the current message processing speed. The message processing platform can determine the historical backlog probability based on the ratio of historical processing time to the period duration. When the historical backlog probability is greater than 1, it means that the message processing platform cannot process all messages enqueued within the period duration. When the historical backlog probability is less than 1, it means that the message processing platform can process all messages enqueued within the period duration. The message processing platform can preset weights for message backlog probabilities and historical backlog probabilities. The platform can then calculate a new message backlog probability based on the weighted sum of these two probabilities.
[0161] In another example, the message processing platform can also obtain multiple historical message reception volumes across multiple historical time periods. Based on these historical message reception volumes, the platform can calculate multiple historical processing times. The platform can then calculate the average historical processing time and the average historical backlog probability based on these historical processing times. A new message backlog probability can be calculated by weighting the message backlog probability and the average historical backlog probability. The platform can also store a probability threshold. When the message backlog probability is less than this threshold, the platform can proceed to step S304. When the message backlog probability is greater than or equal to the probability threshold, the platform can proceed to step S305. For example, the probability threshold could be 1.2, 1.3, etc.
[0162] S304. When the probability of message backlog is less than the probability threshold, determine the target resource amount according to the preset value.
[0163] In this embodiment, when the probability of message backlog is less than the probability threshold, it can be considered that there is no message backlog in the message processing platform. Therefore, the message processing voucher can determine the target resource amount as a preset value. This preset value can be a parameter such as 0 or -1, used to indicate that the message processing voucher does not need to request resources in this case. When this step is executed, the calculation of this cycle ends.
[0164] S305. When the probability of message backlog is greater than or equal to the probability threshold, the target resource quantity is calculated based on the message reception volume, message processing volume and preset algorithm in each period within the preset time period.
[0165] S306. Based on the target resource quantity and the resource parameters of the message processing platform, generate and send a resource acquisition request. The resource acquisition request is used to request resources from the resource management platform.
[0166] Among them, steps S305 and S306 are related to Figure 2 Steps S102 and S103 in the embodiment are implemented in a similar manner, and will not be described again here.
[0167] The resource request method provided in this application allows a message processing platform to periodically track message processing data. This data can include the number of messages received and processed. The platform can track the number of messages processed within the current period. Based on the ratio of this processing volume to the period duration, the platform can determine the current message processing speed within the current period. The platform can also track the number of messages received within the current period. Based on the ratio of the current processing speed to the number of messages received within the current period, the platform can determine the actual processing time. Furthermore, based on the ratio of the actual processing time to the period duration, the platform can determine the message backlog probability. When the message backlog probability is less than a probability threshold, the platform can terminate the calculation for that period. When the message backlog probability is greater than or equal to the probability threshold, the platform can calculate the target resource quantity based on the number of messages received, processed, and a preset algorithm within a preset time period. The platform can then calculate the required resource quantity based on its resource parameters and the target resource quantity. Finally, the platform can generate a resource acquisition request based on this resource quantity. In this application, by increasing the number of resources on the resource processing platform when message backlog occurs, the processing efficiency of the resource processing platform is improved, and message diversion avoids backlog. In this application, the resource processing platform can also determine whether backlog has occurred and promptly request resources when backlog occurs, avoiding resource waste in the resource management platform.
[0168] Figure 5 The diagram shows a schematic representation of a resource request device according to an embodiment of this application. Figure 5 As shown, the resource request device 10 of this embodiment is used to implement the operation corresponding to the message processing platform in any of the above method embodiments. The resource request device 10 of this embodiment includes:
[0169] The acquisition module 11 is used to periodically count the number of messages received and processed by the message processing platform.
[0170] Processing module 12 is used to calculate the target resource quantity based on the message reception volume, message processing volume, and a preset algorithm within a preset time period. Based on the target resource quantity and the resource parameters of the message processing platform, it generates and sends a resource acquisition request, which is used to request resources from the resource management platform.
[0171] In one example, processing module 12 is specifically used for:
[0172] Within a preset time period, the average message processing speed is determined based on the message processing volume and cycle duration within each cycle.
[0173] Within a preset time period, the average message backlog is determined based on the message reception and processing volume in each period.
[0174] The target resource quantity is determined based on the average message processing speed and the average message backlog.
[0175] In one example, processing module 12 is specifically used for:
[0176] Determine the required resource quantity based on the target resource quantity and resource parameters.
[0177] Generate a resource acquisition request based on the amount of resources.
[0178] In one example, when the message processing platform is deployed using containerization technology, the number of resources is the number of replicas, and the resource acquisition request is used to request the resource management platform to increase the number of replicas of the message processing platform.
[0179] In one example, when the message processing platform is deployed using non-containerized technology, the number of resources is equal to the number of interfaces, and the resource acquisition request is used to request the resource management platform to increase the number of interfaces of the message processing platform.
[0180] In one example, processing module 12 is also used for:
[0181] The queuing percentage for each period is determined based on the amount of messages received and processed in each period.
[0182] The number of backlogs within a preset time period where the percentage of queues exceeds a certain threshold is recorded.
[0183] When the number of backlogs is less than the threshold, the target resource quantity is determined based on a preset value.
[0184] In one example, processing module 12 is specifically used for:
[0185] The message queuing volume is determined based on the difference between the message reception volume and the message processing volume.
[0186] The queuing percentage is determined by the ratio of message queuing volume to message reception volume.
[0187] In one example, processing module 12 is also used for:
[0188] The current message processing speed is determined based on the message volume and cycle duration within the current cycle.
[0189] The probability of message backlog is determined based on the current message processing speed and the amount of messages received in the current period.
[0190] When the probability of message backlog is less than the probability threshold, the target resource quantity is determined according to the preset value.
[0191] In one example, processing module 12 is specifically used for:
[0192] The actual processing time is determined by the ratio of the number of messages received to the current message processing speed.
[0193] The probability of message backlog is determined by the ratio of actual processing time to cycle duration.
[0194] In one example, processing module 12 is specifically used for:
[0195] Retrieve the historical message reception volume for the next period from the message processing platform's historical records.
[0196] The historical processing time is determined by the ratio of historical message reception volume to current message processing speed.
[0197] The historical backlog probability is determined based on the ratio of historical processing time to cycle duration.
[0198] Update the message backlog probability based on the weighted sum of the message backlog probability and the historical backlog probability.
[0199] The resource request device 10 provided in this application embodiment can execute the above method embodiment. Its specific implementation principle and technical effects can be found in the above method embodiment, and will not be repeated here.
[0200] Figure 6 A schematic diagram of the structure of a message processing system provided in an embodiment of this application is shown. Figure 6As shown, the message processing system 20 may include a resource management platform 21 and at least one message processing platform 22.
[0201] One message processing system can correspond to one application scenario. For example, the message processing system could be for an online shopping mall. Or, it could be for a short video website.
[0202] A message processing system 20 may include a resource management platform 21. This resource management platform 21 manages all resources within the message processing system 20. The resource management platform 21 may correspond to a dedicated server. Alternatively, the resource management platform 21 may be a program running on a server. This program can be accessed through an interface.
[0203] A message processing system 20 may include at least one message processing platform 22. Each message processing platform 22 may be used to process at least one type of message. For example, a first message processing platform may be used to process order generation messages. A second message processing platform may be used to process payment-related messages. A third message processing platform may be used to process inventory-related messages. Each message processing platform 22 may include at least one server. When the smallest unit of resource is a replica in a container, each server may run at least one replica of a container. When the smallest unit of resource is an interface, each server may run at least one interface program.
[0204] In one example, the message processing system 20 may also include a message forwarding platform. Clients can send messages to the message forwarding platform. The message forwarding platform can then allocate messages to the corresponding message processing platform 22 based on message type. When a message processing platform 22 includes multiple interfaces or replicas, the message forwarding platform can evenly distribute multiple messages across the various interfaces or replicas of the message processing platform 22.
[0205] The message processing platform provided in this embodiment can be used to execute the resource request method described above. Its implementation and technical effects are similar, and will not be described again here.
[0206] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the methods provided in the various embodiments described above.
[0207] The computer-readable storage medium can be a computer storage medium or a communication medium. A communication medium includes any medium that facilitates the transfer of a computer program from one location to another. A computer storage medium can be any available medium accessible to a general-purpose or special-purpose computer. For example, a computer-readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the computer-readable storage medium. Of course, the computer-readable storage medium can also be a component of the processor. The processor and the computer-readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the ASIC can reside in a user equipment. Of course, the processor and the computer-readable storage medium can also exist as discrete components in a communication device.
[0208] Specifically, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0209] This application also provides a computer program product comprising a computer program stored in a computer-readable storage medium. At least one processor of the device can read the computer program from the computer-readable storage medium, and the at least one processor executes the computer program to cause the device to implement the methods provided in the various embodiments described above.
[0210] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0211] The modules can be physically separate, for example, installed in different locations within a single device, installed on different devices, distributed across multiple network units, or distributed across multiple processors. Alternatively, the modules can be integrated, for example, installed in the same device, or integrated into a single codebase. The modules can exist in hardware form, software form, or a combination of both. This application can select some or all of the modules to achieve the objectives of this embodiment based on actual needs.
[0212] When the various modules are implemented as integrated software functional modules, they can be stored in a computer-readable storage medium. The aforementioned software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, platform, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application.
[0213] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0214] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A resource request method, characterized in that, The method, applied to a message processing platform, includes: The message receiving volume and message processing volume of the message processing platform are periodically statistically analyzed. The current message processing speed is determined based on the message processing volume and cycle duration within the current period. The actual processing time is determined based on the ratio of the number of messages received to the current message processing speed. The message backlog probability is determined based on the ratio of the actual processing time to the cycle duration; the message backlog probability is used to indicate whether all messages can be processed within the cycle duration. The message backlog probability is updated based on the weighted sum of the message backlog probability and the historical backlog probability; the historical backlog probability is determined based on the historical message reception volume and the current message processing speed for the next cycle. When the updated message backlog probability is greater than or equal to the probability threshold, a target resource quantity is calculated based on the message reception volume, message processing volume, and a preset algorithm within each period of a preset time period. The target resource quantity is the processing time required for the current resources of the message processing platform to process the backlog of messages. The target resource quantity is determined based on the average message processing speed and average message backlog volume within the preset time period, and the average message processing speed and average message backlog volume are determined based on the message processing volume and message reception volume. Based on the target resource quantity and the resource parameters of the message processing platform, a resource acquisition request is generated and sent. The resource acquisition request is used to request the required amount of resources from the resource management platform.
2. The method according to claim 1, characterized in that, The step of calculating the target resource quantity based on the message reception volume, message processing volume, and a preset algorithm within a preset time period includes: Within a preset time period, the average message processing speed is determined based on the message processing volume and cycle duration in each period. Within a preset time period, the average message backlog is determined based on the message reception volume and message processing volume in each period. The target resource quantity is determined based on the average message processing speed and the average message backlog.
3. The method according to claim 1, characterized in that, The step of generating a resource acquisition request based on the target resource quantity and the resource parameters of the message processing platform includes: Based on the target resource quantity and the resource parameters, determine the required resource quantity; The resource acquisition request is generated based on the stated resource quantity.
4. The method according to claim 3, characterized in that, When the message processing platform is deployed using containerization technology, the number of resources refers to the number of replicas, and the resource acquisition request is used to request the resource management platform to increase the number of replicas of the message processing platform; or, when the message processing platform is deployed using non-containerization technology, the number of resources refers to the number of interfaces, and the resource acquisition request is used to request the resource management platform to increase the number of interfaces of the message processing platform.
5. The method according to any one of claims 1-4, characterized in that, Before calculating the target resource quantity based on the message reception volume, message processing volume, and preset algorithm within each period of a preset time period, the method further includes: The queuing percentage for each period is determined based on the message reception volume and message processing volume within each period. The number of backlogs where the queue percentage exceeds a threshold is counted within a preset time period; When the number of backlogs is less than the number of times, the target resource quantity is determined according to a preset value.
6. The method according to claim 5, characterized in that, The step of determining the queuing percentage for each period based on the message reception volume and message processing volume within each period includes: The message queuing volume is determined based on the difference between the message reception volume and the message processing volume. The queuing ratio is determined based on the ratio of the message queuing volume to the message receiving volume.
7. The method according to any one of claims 1-4, characterized in that, The method further includes: When the updated message backlog probability is less than the probability threshold, the target resource quantity is determined according to a preset value.
8. The method according to claim 1, characterized in that, The method further includes: Obtain the historical message reception volume for the next cycle from the historical records of the message processing platform; The historical processing time is determined based on the ratio of the historical message reception volume to the current message processing speed. The historical backlog probability is determined based on the ratio of the historical processing time to the cycle duration.
9. A message processing system, characterized in that, The system includes: a resource management platform and at least one message processing platform. The resource management platform is used to manage the resources of each message processing platform. Each message processing platform is used to process a type of message. Each message processing platform corresponds to at least one server. The server has a container replica or an interface deployed in it. The message processing platform is used to perform the method as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, is used to implement the resource request method as described in any one of claims 1-8.
Citation Information
Patent Citations
Message queue-based data processing method and device, computer equipment and medium
CN112612607A