A method and system for resource scaling

By predicting future resource demands and combining historical load data and message queue length, a gradual scaling-up and scaling-down strategy was adopted to solve the problems of lag and jitter in resource scaling-up and scaling-down in the live streaming field, thereby improving resource utilization and service stability.

CN120896866BActive Publication Date: 2025-12-16HANGZHOU MICROFRAME INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511436989.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2025-12-16
Estimated Expiration
2045-10-09

AI Technical Summary

Technical Problem

Existing technologies for scaling up and down resources in the live streaming field suffer from lag and instability, leading to unstable server load, impacting user experience, and increasing labor costs.

Method used

By predicting future resource demands and combining historical load data, message queue length, and resource reservation data, a gradual scaling-up/scaling strategy is adopted to dynamically adjust the number of resources and avoid frequent scaling-up/scaling oscillations.

Benefits of technology

This improved resource utilization, enhanced service stability and user experience, reduced labor costs, and prevented service instability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120896866B_ABST
    Figure CN120896866B_ABST
Patent Text Reader

Abstract

The application discloses a resource expansion and contraction method and system, and the method comprises the following steps: predicting the required resources in a next first time interval to obtain a predicted resource requirement quantity; calculating a target expansion quantity or a target contraction quantity of the resources according to a current resource usage quantity and the predicted resource requirement quantity; and performing an expansion and contraction task according to an expansion and contraction strategy. The application realizes automatic elastic scaling of the resources by accurately predicting resource requirements of various data, effectively improves resource utilization, and completely liberates manpower. The progressive expansion and contraction strategy is adopted, the resource quantity is changed smoothly while the resources are saved, service jitter is avoided, and the stability of the service is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, in particular to a resource expansion and contraction method and system. BACKGROUND

[0002] With the wide application of cloud computing, micro-service architecture and containerization technology, dynamic resource management has become the core function of modern computing platforms. Its core goal is to automatically adjust the allocation scale of computing, storage, network and other resources according to the actual workload demand, that is, to realize the elastic expansion and contraction of resources. Precise expansion and contraction strategy can maximize resource utilization while ensuring application service performance, thereby reducing operating costs.

[0003] In current technical practice, reactive expansion is the most common method, which is usually based on pre-set static thresholds or rules. For example, the system continuously monitors key indicators such as CPU utilization, memory usage, concurrent connection number, code rate or packet loss rate. When a certain indicator exceeds the pre-set upper threshold, the system automatically triggers the expansion operation; on the contrary, when the indicator is below the lower threshold, the contraction operation is triggered. The advantage of this method is that it is simple and direct. However, its inherent defects are further magnified in the live streaming field: first, it always lags behind the actual load changes. From the sudden influx of a large number of users in the live streaming room (such as the start of a popular live streaming or the triggering of a hot event) leading to a sharp increase in traffic, to the monitoring indicators exceeding the threshold, to the resource instances completing the startup and taking over the traffic, there is a fatal time difference. During this window period, the server may be overwhelmed, causing video lag, audio and video out of sync, or even service crashes, seriously affecting user experience. Secondly, in the face of the inherent high burstiness of live streaming traffic and the obvious "tide effect" (such as the large difference in active user quantity at different times), static thresholds are difficult to adapt, and are prone to "jitter" (frequent expansion and contraction oscillation), which damages system stability and increases control overhead.

[0004] In addition, another commonly used method is to rely on manual experience to manually adjust the expansion and contraction, but due to the particularity of the live streaming industry, the demand for resources changes in real time, and in order to save resources, human cost is required for operation, resulting in an increase in human cost.

[0005] Both pure reactive and manual operation have obvious limitations. SUMMARY

[0006] In view of the above problems of the existing method, the embodiments of the present application provide a resource expansion and contraction method and system.

[0007] Specifically, the embodiments of the present application provide the following technical solutions:

[0008] In a first aspect, the embodiments of the present application provide a resource expansion and contraction method, comprising: predicting required resources in a next first time interval to obtain a predicted resource requirement quantity; calculating a target expansion quantity or a target contraction quantity of the resources according to a current resource usage and the predicted resource requirement quantity; and performing an expansion and contraction task according to an expansion and contraction strategy.

[0009] In a second aspect, the embodiments of the present application provide a resource expansion and contraction system, comprising:

[0010] A prediction module is configured to predict required resources in a next first time interval to obtain a predicted resource requirement quantity.

[0011] A calculation module is configured to calculate a target expansion quantity or a target contraction quantity of the resources according to a current resource usage and the predicted resource requirement quantity.

[0012] An execution module is configured to perform an expansion and contraction task according to an expansion and contraction strategy.

[0013] According to the above technical solution, the present application has the following beneficial effects: relying on accurate prediction of resource requirements based on various data, realizing automatic elastic scaling of resources, effectively improving resource utilization, and completely liberating manpower. The progressive expansion and contraction strategy is adopted to save resources while making the resource quantity change smoothly, avoid service jitter, and ensure the stability of the service. BRIEF DESCRIPTION OF DRAWINGS

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0015] Figure 1 is a flowchart of the resource expansion and contraction method provided by an embodiment of the present application.

[0016] Figure 2 is a structural schematic diagram of the resource expansion and contraction system provided by an embodiment of the present application. DETAILED DESCRIPTION

[0017] The specific embodiments of the present application will be further described below in combination with the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and cannot limit the protection scope of the present application.

[0018] Figure 1 shows a flowchart of the resource expansion and contraction method provided by an embodiment of the present application, as shown in Figure 1 The resource expansion and contraction method provided by the embodiments of the present application specifically includes the following contents:

[0019] Step 1, predicting the required resources in the next first time interval to obtain a predicted resource requirement quantity.

[0020] As an implementation manner, the step of predicting the required resources in the next first time interval to obtain a predicted resource requirement quantity comprises:

[0021] obtaining a first predicted resource requirement quantity according to historical load data.

[0022] obtaining a second predicted resource requirement quantity according to current message queue length data.

[0023] obtaining a third predicted resource requirement quantity according to resource reservation data.

[0024] selecting the maximum value of one or more of the first predicted resource requirement quantity, the second predicted resource requirement quantity and the third predicted resource requirement quantity as the predicted resource requirement quantity.

[0025] Specifically, the step of obtaining a first predicted resource requirement quantity according to historical load data comprises:

[0026] analyzing the historical load data and extracting time characteristics corresponding to a change rate of resource usage of two adjacent first time intervals exceeding a set threshold.

[0027] determining a time characteristic to which the next first time interval belongs.

[0028] selecting historical load data corresponding to the same time characteristic of the nearest one as the first predicted resource requirement quantity according to the time characteristic to which the next first time interval belongs.

[0029] For example, assuming that the first time interval is 1 second, the current time is November 11, 2025, 0:00:00, and the preset change rate of resource usage is 200%.

[0030] When analyzing the historical load data, it is found that on November 11, the resource usage of 0:00:00-0:00:01 increases sharply (for example, double eleven activities), and the growth rate of resource usage in the time interval of 0:00:00-0:00:01 is 500% compared with the resource usage of the previous second, which exceeds the threshold of 200%. Therefore, the special time of 0:00:00-0:00:01 of November 11 of each year with annual periodicity is extracted as a time characteristic.

[0031] It is detected that the current time is November 11, 0:00:00, the next first time interval is 0:00:00-0:00:01, and belongs to the time feature, so the historical load data of November 11, 2024, 0:00:00-0:00:01 is selected as the first predicted resource requirement quantity.

[0032] For example, it is assumed that the first time interval is 1 second, the current time is September 14, 2025, 12:00:00, Sunday, and the preset resource usage change rate threshold is 200%.

[0033] When analyzing the historical load data, it is found that every Sunday, the resource usage at 12:00:00-12:00:01 increases sharply (for example, due to the fixed event held at 12:00 every Sunday), and the growth rate of the resource usage at 12:00:00-12:00:01 compared with the resource usage of the previous second is 300%, which exceeds the threshold of 200%. Therefore, every Sunday, 12:00:00-12:00:01 is extracted as a time feature.

[0034] It is detected that the current time is Sunday 12:00:00, the next first time interval is 12:00:00-12:00:01, and belongs to the time feature, so the historical load data of September 7, 2025 (Sunday) 12:00:00-12:00:01 is selected as the first predicted resource requirement quantity.

[0035] The second predicted resource requirement quantity is predicted according to the current message queue length data, which comprises:

[0036] The target resource load rate threshold is determined according to the current message queue length and the resource load rate dynamic threshold strategy.

[0037] The corresponding required resource number is calculated according to the current message queue length.

[0038] It should be noted that the number of resources required by the present application embodiment for a single message is not limited, and can be calculated according to the actual situation, for example, 1 resource number is required to process 1 message, so the corresponding required resource number is equal to the current message queue length; if 2 resource numbers are required to process 1 message, then the corresponding required resource number is 2 times the current message queue length.

[0039] The second predicted resource requirement quantity is calculated according to the target resource load rate threshold and the corresponding required resource number.

[0040] The resource load rate dynamic threshold strategy comprises:

[0041] A plurality of continuous message queue length gradient ranges [n i ,m i ] are preset, i is a natural number.

[0042] Each gradient range sets a corresponding resource load rate threshold T i .

[0043] Wherein, the higher the message queue length gradient range numerical level, the greater the corresponding resource load rate threshold T i .

[0044] According to the gradient range of the message queue length in the current first time interval, the corresponding target resource load rate threshold is determined.

[0045] For example, three consecutive message queue length gradient ranges and corresponding resource load rate thresholds are preset, which are gradient range [0, 160], corresponding load rate threshold is 0.6; Gradient range [161, 200], corresponding load rate threshold is 0.8; Gradient range [201, 300], corresponding load rate threshold is 0.95. The number of resources required to process one message is 1.

[0046] If the message queue length in the current first time interval is 170, the corresponding target resource load rate threshold is 0.8.

[0047] The third predicted resource quantity is predicted according to the resource reservation data, comprising:

[0048] A resource usage account-scaling factor mapping table is maintained in the database.

[0049] The mapping table records the resource usage account and its corresponding resource reservation scaling factor, wherein the value range of the scaling factor is not less than 0.

[0050] For example, when the scaling factor = 1.0, it means that the actual resource usage of the account is equal to the resource reservation amount, the resource reservation amount is 100% reliable, and the resource reservation amount is 100% adopted in prediction.

[0051] When the scaling factor > 1.0, it means that the actual resource usage of the account usually exceeds the resource reservation amount (for example, an average of 20%). When predicting, the resource reservation amount * scaling factor should be adopted (for example, reservation 100, then predict that it will use 120).

[0052] When the scaling factor < 1.0, it means that the actual resource usage of the account is usually insufficient for the resource reservation amount (for example, an average of only 80%). When predicting, the resource reservation amount * factor should be adopted (for example, reservation 100, then predict that it will use 80).

[0053] When the scaling factor = 0, it means that the account never uses resources after reserving resources, and the reservation amount should be completely ignored in prediction.

[0054] It can be understood that the embodiment of the present application does not limit the specific value of the initial value of the scaling factor, which can be set according to actual conditions. For example, the newly added resource usage account has no historical data as a reference, and the credibility of the resource reservation of the newly added resource usage account is higher by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 1; or the resource reservation of the newly added resource usage account is neither completely trusted nor completely untrusted by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 0.5; or a certain amount of buffer needs to be left for the resource reservation of the newly added resource usage account by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 1.2.

[0055] Obtaining the resource reservation quantity of each resource usage account in the next first time interval, reading the scaling factor corresponding to each resource usage account in the resource usage account-scaling factor mapping table, and calculating a third predicted resource demand quantity, expressed as follows:

[0056]

[0057] wherein, α i represents the scaling factor corresponding to the i th resource usage account, A i represents the resource reservation quantity of the i th resource usage account in the next first time interval, and N represents the number of resource usage accounts.

[0058] In another embodiment, after calculating the third predicted resource demand quantity, the method further comprises updating the resource usage account-scaling factor mapping table according to the actual resource usage quantity of the resource usage account, comprising:

[0059] Recalculating the scaling factor of the resource usage account according to the actual resource usage quantity of the resource usage account, expressed as follows:

[0060] α i _new= (α i _old * (M-1) + (A' i / A i )) / M

[0061] wherein, α i _old represents the original scaling factor, A i represents the resource reservation quantity, A' i represents the actual resource usage quantity, and M represents a smoothing coefficient. The larger the value of M is, the smoother the change of the scaling factor is, and the more resistant to the interference of single abnormal value.

[0062] Step 2, calculating the target expansion quantity or target contraction quantity of the resource according to the current resource usage quantity and the predicted resource demand quantity.

[0063] Specifically, if the predicted resource demand quantity is greater than the current resource usage, a target expansion quantity = predicted resource demand quantity - current resource usage is obtained.

[0064] If the predicted resource demand quantity is less than the current resource usage, a target contraction quantity = current resource usage - predicted resource demand quantity is obtained.

[0065] Step 3: performing an expansion / contraction task according to the expansion / contraction strategy.

[0066] A second time interval, a first threshold S1, and a second threshold S2 are preset.

[0067] The second time interval is not greater than the first time interval.

[0068] An expansion step is set according to the target expansion quantity and a growth rate of the messages to be consumed in the message queue within the second time interval, and progressive expansion is performed:

[0069] If the target expansion quantity is not less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, emergency expansion is performed, and the expansion rate is w1.

[0070] If the target expansion quantity is less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, large-step expansion is performed, and the expansion rate is w2.

[0071] If the target expansion quantity is not less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, medium-step expansion is performed, and the expansion rate is w3.

[0072] If the target expansion quantity is less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, small-step expansion is performed, and the expansion rate is w4.

[0073] Similarly, a contraction step is set according to the target contraction quantity and a reduction rate of the messages to be consumed in the message queue within the second time interval, and progressive contraction is performed:

[0074] If the target contraction quantity is not less than the first threshold S1 and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, emergency contraction is performed, and the contraction rate is w1.

[0075] If the target contraction quantity is less than the first threshold S1 and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, large-step contraction is performed, and the contraction rate is w2.

[0076] If the target shrinkage quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then stepwise shrinkage is performed, and the shrinkage rate is w4.

[0077] If the target shrinkage quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then stepwise shrinkage is performed, and the shrinkage rate is w4.

[0078] Wherein, w1>w2>w3>w4.

[0079] It should be noted that the present embodiment does not limit the specific setting value of the expansion rate or the shrinkage rate, and the actual situation can be set.

[0080] Based on the same inventive concept, Figure 2 The structure of the system for resource expansion and shrinkage provided by the embodiment of the present application is shown in the figure. Figure 2 The system for resource expansion and shrinkage provided by the embodiment of the present application specifically includes the following contents:

[0081] The prediction module is configured to predict the required resources in the next first time interval to obtain a predicted resource requirement quantity.

[0082] As an implementation manner, the prediction of the required resources in the next first time interval to obtain a predicted resource requirement quantity includes:

[0083] The first predicted resource requirement quantity is obtained according to historical load data.

[0084] The second predicted resource requirement quantity is obtained according to current message queue length data.

[0085] The third predicted resource requirement quantity is obtained according to resource reservation data.

[0086] The maximum value of one or more of the first predicted resource requirement quantity, the second predicted resource requirement quantity, and the third predicted resource requirement quantity is selected as the predicted resource requirement quantity.

[0087] Specifically, in one embodiment, the first predicted resource requirement quantity is obtained according to historical load data, including:

[0088] The historical load data is analyzed, and the time characteristics corresponding to the change rate of the resource usage of two adjacent first time intervals exceeding a set threshold are extracted.

[0089] The time characteristics to which the next first time interval belongs are determined.

[0090] According to a time feature to which the next first time interval belongs, historical load data corresponding to a same time feature is selected as the first predicted resource requirement quantity.

[0091] In one embodiment, the second predicted resource requirement quantity is predicted according to the current message queue length data, and the prediction includes:

[0092] According to the current message queue length and a resource load rate dynamic threshold strategy, a target resource load rate threshold is determined.

[0093] According to the current message queue length, a corresponding required resource quantity is calculated.

[0094] It should be noted that the resource quantity required by a single message is not limited by the embodiment of the present application, and can be calculated according to actual conditions. For example, if one resource quantity is required to process one message, then the corresponding required resource quantity is equal to the current message queue length; if two resource quantities are required to process one message, then the corresponding required resource quantity is twice the current message queue length.

[0095] According to the target resource load rate threshold and the corresponding required resource quantity, the second predicted resource requirement quantity is calculated.

[0096] The resource load rate dynamic threshold strategy includes:

[0097] A plurality of continuous message queue length gradient ranges [n i ,m i ] are preset, and i is a natural number.

[0098] A corresponding resource load rate threshold T i is set for each gradient range.

[0099] The higher the value level of the message queue length gradient range is, the larger the corresponding resource load rate threshold T i is.

[0100] According to the gradient range into which the message queue length in the current first time interval falls, a corresponding target resource load rate threshold is determined.

[0101] In one embodiment, the third predicted resource requirement quantity is predicted according to resource reservation data, and the prediction includes:

[0102] A resource usage account-scaling factor mapping table is maintained in a database.

[0103] The mapping table records resource usage accounts and corresponding resource reservation scaling factors, and the value range of the scaling factor is not less than 0.

[0104] It can be understood that the embodiment of the application does not limit the specific value of the initial value of the scaling factor, which can be set according to actual conditions. For example, the newly added resource usage account has no historical data as a reference, and the credibility of the resource reservation of the newly added resource usage account is higher by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 1; or the resource reservation of the newly added resource usage account is neither completely trusted nor completely untrusted by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 0.5; or a certain amount of buffer needs to be left for the resource reservation of the newly added resource usage account by default, so the initial value of the scaling factor of the newly added resource usage account can be set to 1.2.

[0105] The number of resource reservations of each resource usage account in the next first time interval is obtained, the scaling factor corresponding to each resource usage account in the resource usage account-scaling factor mapping table is read, and the third predicted resource demand quantity is calculated, and the expression is as follows:

[0106]

[0107] Wherein, α i indicates the scaling factor corresponding to the i th resource usage account, A i indicates the number of resource reservations of the i th resource usage account in the next first time interval, and N indicates the number of resource usage accounts.

[0108] In another embodiment, after the third predicted resource demand quantity is calculated, the resource usage account-scaling factor mapping table is further updated according to the actual resource usage quantity of the resource usage account, comprising:

[0109] The scaling factor of the resource usage account is recalculated according to the actual resource usage quantity of the resource usage account, and the expression is as follows:

[0110] α i _new= (α i _old * (M-1) + (A' i / A i )) / M

[0111] Wherein, α i _old indicates the original scaling factor, A i indicates the number of resource reservations, A' i indicates the actual resource usage quantity, and M indicates the smoothing coefficient. The greater the value of M, the smoother the change of the scaling factor, and the more resistant to the interference of single abnormal value.

[0112] The computing module is configured to calculate the target expansion quantity or the target contraction quantity of the resource according to the current resource usage quantity and the predicted resource demand quantity.

[0113] Specifically, if the predicted resource demand quantity is greater than the current resource usage, a target expansion quantity = predicted resource demand quantity - current resource usage is obtained.

[0114] If the predicted resource demand quantity is less than the current resource usage, a target contraction quantity = current resource usage - predicted resource demand quantity is obtained.

[0115] The execution module is configured to execute the expansion / contraction task according to the expansion / contraction strategy.

[0116] A second time interval, a first threshold S1, and a second threshold S2 are preset.

[0117] The second time interval is not greater than the first time interval.

[0118] An expansion step is set according to the target expansion quantity and a growth rate of the messages to be consumed in the message queue within the second time interval, and gradual expansion is performed:

[0119] If the target expansion quantity is not less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, emergency expansion is performed, and the expansion rate is w1.

[0120] If the target expansion quantity is less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, large-step expansion is performed, and the expansion rate is w2.

[0121] If the target expansion quantity is not less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, medium-step expansion is performed, and the expansion rate is w3.

[0122] If the target expansion quantity is less than the first threshold S1 and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, small-step expansion is performed, and the expansion rate is w4.

[0123] Similarly, a contraction step is set according to the target contraction quantity and a reduction rate of the messages to be consumed in the message queue within the second time interval, and gradual contraction is performed:

[0124] If the target contraction quantity is not less than the first threshold S1 and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, emergency contraction is performed, and the contraction rate is w1.

[0125] If the target contraction quantity is less than the first threshold S1 and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, large-step contraction is performed, and the contraction rate is w2.

[0126] If the target shrinkage quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then stepwise shrinkage is performed, and the shrinkage rate is w4.

[0127] If the target shrinkage quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then stepwise shrinkage is performed, and the shrinkage rate is w4.

[0128] Wherein, w1>w2>w3>w4.

[0129] It should be noted that the present application does not limit the specific setting value of the expansion rate or the shrinkage rate, which can be set according to the actual situation.

[0130] In addition, in the embodiments of the present application, the relationship terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. In the description of the present application, the description of "in one embodiment", "in another embodiment" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment are contained in at least one embodiment of the present application. In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments. In addition, the different embodiments described in the present specification and the features of the different embodiments can be combined and combined by those skilled in the art without contradiction.

[0131] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for resource scaling, the method comprising: The method comprises the following steps: predicting resources required in the next first time interval to obtain a predicted resource requirement quantity; calculating a target expansion quantity or a target contraction quantity of the resources according to a current resource usage quantity and the predicted resource requirement quantity; and performing an expansion or contraction task according to an expansion or contraction strategy; The method comprises the following steps: predicting a first predicted resource requirement quantity according to historical load data; predicting a second predicted resource requirement quantity according to current message queue length data; predicting a third predicted resource requirement quantity according to resource reservation data; selecting a maximum value of one or more of the first predicted resource requirement quantity, the second predicted resource requirement quantity and the third predicted resource requirement quantity as the predicted resource requirement quantity; The method comprises the following steps: analyzing historical load data and extracting time characteristics corresponding to a resource usage rate change exceeding a set threshold in two adjacent first time intervals from the historical load data; determining a time characteristic to which the next first time interval belongs; selecting historical load data corresponding to the same time characteristic of the nearest one as the first predicted resource requirement quantity according to the time characteristic to which the next first time interval belongs.

2. The method for resource scaling according to claim 1, wherein, The method comprises the following steps: determining a target resource load rate threshold according to a current message queue length and a resource load rate dynamic threshold strategy; calculating a corresponding required resource quantity according to the current message queue length; calculating the second predicted resource requirement quantity according to the target resource load rate threshold and the corresponding required resource quantity.

3. The method of claim 2, wherein, The resource load rate dynamic threshold strategy comprises the following steps: Pre-set multiple continuous message queue length gradient ranges [n i ,m i ], i is a natural number; Each gradient range sets a corresponding resource load rate threshold T i ; Wherein, the higher the message queue length gradient range numerical level is, the greater the corresponding resource load rate threshold T i is; determining a corresponding target resource load rate threshold according to a gradient range into which a message queue length in a current first time interval falls.

4. The method for resource scaling according to claim 1, wherein, The method comprises the following steps: maintaining a resource usage account-scaling factor mapping table in a database; The mapping table records resource usage accounts and corresponding resource reservation scaling factors, wherein the value range of the scaling factor is not less than 0; obtaining a resource reservation quantity of each resource usage account in the next first time interval, reading the corresponding scaling factor of each resource usage account in the resource usage account-scaling factor mapping table, and calculating the third predicted resource requirement quantity, the expression being as follows: ; wherein, α i represents the scaling factor corresponding to the i-th resource usage account, A i represents the resource reservation quantity of the i-th resource usage account in the next first time interval, and N represents the number of resource usage accounts.

5. The method of claim 4, wherein, After the third predicted resource requirement quantity is calculated, the method further comprises updating the resource usage account-scaling factor mapping table according to an actual resource usage quantity of the resource usage account: recomputing the scaling factor of the resource usage account according to the actual resource usage quantity of the resource usage account, the expression being as follows: α i _new= (α i _old * (M-1) + (A' i / A i )) / M; Wherein, A i represents the number of resource reservations, A' i represents the actual number of resource usage, M represents a smoothing factor, α i _old represents the original scaling factor; updating the recomputed scaling factor to the resource usage account-scaling factor mapping table.

6. The method for resource scaling according to claim 1, wherein, The method comprises the following steps: presetting a second time interval, a first threshold S1 and a second threshold S2; The second time interval is not greater than the first time interval; setting an expansion step according to the target expansion quantity and a growth rate of messages to be consumed in the message queue in the second time interval to perform gradual expansion: If the target expansion quantity is not less than the first threshold S1, and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, then emergency expansion is performed, and the expansion rate is w1; If the target expansion quantity is less than the first threshold S1, and the growth rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, then large-step expansion is performed, and the expansion rate is w2; If the target expansion quantity is not less than the first threshold S1, and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, then middle-step expansion is performed, and the expansion rate is w3; If the target expansion quantity is less than the first threshold S1, and the growth rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, then small-step expansion is performed, and the expansion rate is w4; According to the target contraction quantity and the reduction rate of the messages to be consumed in the message queue within the second time interval, a contraction step is set, and gradual contraction is performed: If the target contraction quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, then emergency contraction is performed, and the contraction rate is w1; If the target contraction quantity is less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue within the second time interval is not less than the second threshold S2, then large-step contraction is performed, and the contraction rate is w2; If the target contraction quantity is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, then middle-step contraction is performed, and the contraction rate is w3; If the target contraction quantity is less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue within the second time interval is less than the second threshold S2, then small-step contraction is performed, and the contraction rate is w4; Wherein, w1>w2>w3>w4.

7. A system for resource scaling, the system comprising: Comprise: A prediction module for predicting the resources required in the next first time interval to obtain a predicted resource requirement quantity; The prediction module for predicting the resources required in the next first time interval to obtain a predicted resource requirement quantity comprises: Obtaining a first predicted resource requirement quantity according to historical load data; Obtaining a second predicted resource requirement quantity according to current message queue length data; Obtaining a third predicted resource requirement quantity according to resource reservation data; Selecting the maximum value of one or more of the first predicted resource requirement quantity, the second predicted resource requirement quantity, and the third predicted resource requirement quantity as the predicted resource requirement quantity; The method for obtaining a first predicted resource requirement quantity according to historical load data comprises: Analyzing historical load data and extracting time characteristics corresponding to a change rate of resource usage of two adjacent first time intervals exceeding a set threshold from the historical load data; Determining the time characteristics to which the next first time interval belongs; Selecting historical load data corresponding to the same time characteristics of the nearest one as the first predicted resource requirement quantity according to the time characteristics to which the next first time interval belongs; A calculation module for calculating a target expansion quantity or a target contraction quantity of resources according to a current resource usage and a predicted resource requirement quantity; The execution module is configured to execute the scaling task according to the scaling strategy.

8. The system for resource scaling according to claim 7, wherein, The second predicted resource requirement quantity is predicted according to the current message queue length data, and the method comprises: determining a target resource load rate threshold according to the current message queue length and a resource load rate dynamic threshold strategy; calculating a corresponding required resource quantity according to the current message queue length; calculating a second predicted resource requirement quantity according to the target resource load rate threshold and the corresponding required resource quantity.

9. The system for resource scaling according to claim 8, wherein, The resource load rate dynamic threshold strategy comprises: Pre-set multiple continuous message queue length gradient ranges [n i ,m i ], i is a natural number; Each gradient range sets a corresponding resource load rate threshold T i ; Wherein, the higher the message queue length gradient range numerical level is, the greater the corresponding resource load rate threshold T i is; determining a corresponding target resource load rate threshold according to a gradient range into which the message queue length falls within a current first time interval.

10. The system for resource scaling according to claim 7, wherein, The third predicted resource requirement quantity is predicted according to resource reservation data, and the method comprises: maintaining a resource usage account-scaling factor mapping table in a database; the mapping table records resource usage accounts and corresponding resource reservation scaling factors, wherein the value range of the scaling factor is not less than 0; obtaining the resource reservation quantity of each resource usage account in the next first time interval, reading the corresponding scaling factor of each resource usage account in the resource usage account-scaling factor mapping table, and calculating the third predicted resource requirement quantity, which is expressed as follows: ; wherein, α i represents the scaling factor corresponding to the i-th resource usage account, A i represents the resource reservation quantity of the i-th resource usage account in the next first time interval, and N represents the number of resource usage accounts.

11. The system for resource scaling according to claim 10, wherein, after the third predicted resource requirement quantity is calculated, the method further comprises updating the resource usage account-scaling factor mapping table according to the actual resource usage quantity of the resource usage account: recalculating the scaling factor of the resource usage account according to the actual resource usage quantity of the resource usage account, which is expressed as follows: α i _new= (α i _old * (M-1) + (A' i / A i )) / M; Wherein, A i represents the resource reservation quantity, A' i represents the resource actual use quantity, M represents the smoothing coefficient, α i _old represents the original scaling factor; updating the recalculated scaling factor to the resource usage account-scaling factor mapping table.

12. The system for resource scaling according to claim 7, wherein, The execution module is configured to execute the scaling task according to the scaling strategy, and the method comprises: presetting a second time interval, a first threshold S1, and a second threshold S2; the second time interval is not greater than the first time interval; setting a scaling step according to the target scaling quantity and the growth rate of the to-be-consumed messages in the message queue within the second time interval, and performing gradual scaling: if the target scaling quantity is not less than the first threshold S1 and the growth rate of the to-be-consumed messages in the message queue within the second time interval is not less than the second threshold S2, performing emergency scaling at a scaling rate w1; if the target scaling quantity is less than the first threshold S1 and the growth rate of the to-be-consumed messages in the message queue within the second time interval is not less than the second threshold S2, performing large-step scaling at a scaling rate w2; if the target scaling quantity is not less than the first threshold S1 and the growth rate of the to-be-consumed messages in the message queue within the second time interval is less than the second threshold S2, performing middle-step scaling at a scaling rate w3; if the target scaling quantity is less than the first threshold S1 and the growth rate of the to-be-consumed messages in the message queue within the second time interval is less than the second threshold S2, performing small-step scaling at a scaling rate w4; setting a scaling step according to the target scaling quantity and the reduction rate of the to-be-consumed messages in the message queue within the second time interval, and performing gradual scaling: if the target scaling quantity is not less than the first threshold S1 and the reduction rate of the to-be-consumed messages in the message queue within the second time interval is not less than the second threshold S2, performing emergency scaling at a scaling rate w1; If the target number of shrinkage is less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is not less than the second threshold S2, then large-step shrinkage is performed, and the shrinkage rate is w2; If the target number of shrinkage is not less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then medium-step shrinkage is performed, and the shrinkage rate is w3; If the target number of shrinkage is less than the first threshold S1, and the reduction rate of the messages to be consumed in the message queue in the second time interval is less than the second threshold S2, then small-step shrinkage is performed, and the shrinkage rate is w4; Wherein, w1>w2>w3>w4.

Citation Information

Patent Citations

  • Capacity expansion and contraction method and system, electronic equipment and storage medium

    CN120223702A