Safe atomic force elastic capacity expansion and shrinkage and flow distribution method, device, equipment and medium
By classifying instances and building traffic prediction models, resource allocation strategies are dynamically adjusted, solving the problem of unreasonable resource allocation in existing technologies and realizing flexible allocation and stable operation of the secure atomic capability system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING YIAN TECHNOLOGY CO LTD
- Filing Date
- 2026-01-19
- Publication Date
- 2026-04-21
AI Technical Summary
Existing methods for allocating secure atomic capabilities are ill-suited to the dynamic changes in business traffic, leading to either over-allocation or under-allocation of resources, which in turn affects system performance and stability.
By classifying instances based on historical load and business type, a traffic prediction model is built to determine scaling thresholds and allocation strategies, and resource allocation is dynamically adjusted to adapt to load changes.
It improves the reliability and rationality of resource management, ensuring that the system can adjust resource allocation in a timely manner when the load changes, avoiding waste and shortage, and ensuring stable system operation.
Smart Images

Figure CN121907844A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of resource management, and in particular to a method, apparatus, device, and medium for secure atomic capability flexible expansion and contraction and flow allocation. Background Technology
[0002] In today's rapidly developing cloud computing and internet business environment, the load of various application systems exhibits complex and ever-changing trends depending on time and business needs. For application systems related to security atomic capabilities, different business types also have significantly different requirements for security atomic capability resources. This trend makes the efficient utilization and flexible allocation of security atomic capability resources crucial. In security-related business scenarios, such as network security protection and data security assurance, the rational scheduling of security atomic capability resources can more accurately address various security threats, ensure the safe and stable operation of the system, provide users with a better service experience, and have a profound impact on the company's business development and market competitiveness.
[0003] Currently, two main approaches are commonly used to address load variations and resource allocation issues in secure atomic capability systems. One is static resource allocation, which involves pre-allocating a fixed amount of resources to the system based on empirically estimated maximum loads. This approach is relatively simple and straightforward during system deployment, requiring no complex real-time monitoring or adjustment mechanisms. The other is dynamic adjustment based on fixed thresholds, which sets preset load thresholds.
[0004] However, current resource allocation and scaling methods have significant drawbacks. Static resource allocation struggles to adapt to dynamic changes in business traffic, potentially leading to over-allocation and waste, or insufficient resources that disrupt normal business operations. Dynamic adjustment based on fixed thresholds relies too heavily on preset thresholds, failing to accurately allocate resources according to actual business needs and load conditions. This can easily result in untimely or excessive scaling, impacting system performance and stability. Summary of the Invention
[0005] To improve the reliability of resource management, this application provides a method, apparatus, device, and medium for secure atomic capability flexible expansion and contraction and flow allocation.
[0006] In a first aspect, this application provides a method for flexible expansion and contraction of safe atomic capabilities and flow allocation, employing the following technical solution: A method for flexible expansion / contraction and flow allocation of safe atomic capabilities includes: The instances are categorized according to historical load and business type to determine multiple instance clusters and the instance category of each instance cluster, with each instance cluster corresponding to one instance category; Construct a traffic prediction model for each of the instance categories; Based on the traffic prediction model, the predicted number of requests and the predicted CPU load rate of the target instance cluster are predicted. The scaling threshold of the target instance cluster is determined based on the target instance category, where the target instance category is the instance category corresponding to the target instance cluster; Whether scaling up or down is necessary is determined based on the predicted CPU load rate, the predicted number of requests, and the scaling up / down threshold of the target instance cluster. If scaling up or down is required, the scaling up or down strategy for the target instance cluster is determined based on the predicted number of requests and the target instance category, and the traffic allocation strategy for the target instance cluster is determined based on the preset allocation rules.
[0007] By adopting the above technical solution, instances are classified into instance clusters and corresponding instance categories according to historical load and business type, which helps to manage different types of instances in a targeted manner. Different instance clusters correspond to different traffic prediction models, making the traffic prediction models more accurate and improving the accuracy of predicting the number of requests and the CPU load rate of the target instance cluster. Targeted scaling thresholds are set for instance clusters of different instance categories to determine whether scaling is needed, improving the reliability of scaling decisions and thus improving the reliability of resource management. When scaling is needed, the scaling strategy for the target instance cluster is determined based on the predicted request count and the target instance category, and further, the traffic allocation strategy for the target instance cluster is determined based on preset allocation rules, making the scaling process and traffic allocation more reasonable and further improving the reliability of resource management.
[0008] Optionally, the step of classifying instances according to historical load and service type to determine multiple instance clusters and the instance category of each instance cluster includes: The instances are divided according to the business type to obtain multiple instance clusters; Obtain historical operational data of the instance cluster, including historical time, historical request count, and historical CPU load rate; The historical operational data is analyzed to determine the request fluctuation coefficient and CPU fluctuation coefficient of the instance cluster. The instance category of the instance cluster is determined by analyzing the request fluctuation coefficient and the CPU fluctuation coefficient using preset thresholds.
[0009] By adopting the above technical solution, all instances are first divided into multiple instance clusters according to the business type. Then, the historical operation data of each instance cluster is analyzed to determine the request fluctuation coefficient and CPU fluctuation coefficient, that is, to determine the stability of historical traffic, thereby determining the instance type. This makes the instance type of the instance cluster not only reflect the business type, but also the stability of traffic, which facilitates the subsequent targeted formulation of scaling thresholds and scaling strategies, making scaling more reliable.
[0010] Optionally, constructing the traffic prediction model for each of the instance categories includes: The Long Short-Term Memory network is trained using historical operating data from each instance cluster to construct the traffic prediction model for each instance category.
[0011] Optionally, the scaling threshold includes a request scaling threshold and a CPU scaling threshold, and determining the scaling threshold of the target instance cluster based on the target instance category includes: The CPU scaling threshold of the target instance cluster is obtained based on the target instance category; The single-instance request threshold for each instance in the target instance cluster is determined based on the CPU scaling threshold and the correlation between CPU and request. The request scaling threshold is determined based on the single instance request threshold and the current number of instances in the target instance cluster.
[0012] By adopting the above technical solution, when determining the scaling threshold of the target instance cluster, the CPU scaling threshold is first determined by considering the resource (CPU) status of the target instance cluster and the target instance category. Then, the request scaling threshold is further determined based on the correlation between CPU and requests, which makes the scaling threshold of the target instance cluster more reliable.
[0013] Optionally, determining the scaling strategy for the target instance cluster based on the predicted number of requests and the target instance category includes: The redundancy coefficient is determined based on the target instance category; The target number of instances is determined based on the predicted number of requests, the stable number of requests per instance, and the redundancy coefficient. The scaling up / down quantity is determined based on the current number of instances and the target number of instances; The scaling strategy is determined based on the scaling-up / scaling-down quantity and the target instance cluster.
[0014] By adopting the above technical solution, different redundancy coefficients are set for different instance categories, which fully takes into account the differences in traffic stability of different instance categories. The scaling up and down numbers are determined based on the predicted number of requests, the number of stable requests per instance, the redundancy coefficient, and the current number of instances, which improves the rationality of the scaling up and down numbers and thus improves the reliability of the scaling up and down strategy.
[0015] Optionally, determining the traffic allocation strategy for the target instance cluster based on preset allocation rules includes: Determine the CPU idle load of each instance in the target instance cluster; The allocation weight of each instance is calculated based on the CPU idle load; The traffic allocation ratio for each instance is calculated based on the allocation weights. The traffic allocation strategy is determined based on the traffic allocation ratio.
[0016] By adopting the above technical solution, the allocation weight of each instance is determined based on the CPU idle load of each instance, and then the traffic allocation ratio and traffic allocation strategy are further determined based on the allocation weight, which improves the rationality of traffic allocation and thus improves the reliability of resource management.
[0017] Optionally, calculating the traffic allocation ratio for each instance based on the allocation weight includes: If a new instance is added to the target instance cluster, the current stage of the new instance is obtained. The weight cap and traffic cap of the newly added instance in the current stage are determined based on the target instance category; The allocation weight of the newly added instance is updated based on the weight cap and the allocation weight; The traffic allocation ratio of the newly added instance is calculated based on the updated allocation weight; The traffic allocation ratio of the newly added instance is updated based on the traffic allocation ratio and the traffic limit. The traffic allocation ratio of the original instance is calculated based on the updated traffic allocation ratio and the allocation weight of the original instance.
[0018] By adopting the above technical solution, different weight and traffic limits are set for new instances according to their different stages. This reduces the occurrence of new instance response delays or even failures caused by the large CPU idle load at the beginning of a new instance, which leads to a large weight allocation and a high traffic allocation ratio. This improves the rationality of traffic allocation.
[0019] Secondly, this application provides a safe atomic capability flexible expansion / contraction and flow distribution device, which adopts the following technical solution: A safe atomic-capacity flexible expansion / contraction and flow distribution device, comprising: The cluster category division module is used to classify instances according to historical load and business type, determine multiple instance clusters and the instance category of each instance cluster, and the instance clusters correspond one-to-one with the instance categories; A prediction model building module is used to build a traffic prediction model for each of the instance categories; The prediction model prediction module is used to predict the number of predicted requests and the CPU load rate of the target instance cluster based on the traffic prediction model. The cluster threshold determination module is used to determine the scaling threshold of the target instance cluster based on the target instance category, wherein the target instance category is the instance category corresponding to the target instance cluster; The cluster scaling determination module is used to determine whether scaling is required based on the predicted CPU load rate, the predicted number of requests, and the scaling threshold of the target instance cluster. The scaling-up / scaling strategy determination module is used to determine the scaling-up / scaling strategy of the target instance cluster based on the predicted number of requests and the target instance category if scaling-up / scaling is required, and to determine the traffic allocation strategy of the target instance cluster based on preset allocation rules.
[0020] By adopting the above technical solution, instances are classified into instance clusters and corresponding instance categories according to historical load and business type, which helps to manage different types of instances in a targeted manner. Different instance clusters correspond to different traffic prediction models, making the traffic prediction models more accurate and improving the accuracy of predicting the number of requests and the CPU load rate of the target instance cluster. Targeted scaling thresholds are set for instance clusters of different instance categories to determine whether scaling is needed, improving the reliability of scaling decisions and thus improving the reliability of resource management. When scaling is needed, the scaling strategy for the target instance cluster is determined based on the predicted request count and the target instance category, and further, the traffic allocation strategy for the target instance cluster is determined based on preset allocation rules, making the scaling process and traffic allocation more reasonable and further improving the reliability of resource management.
[0021] Thirdly, this application provides an electronic device that adopts the following technical solution: An electronic device includes a processor coupled to a memory; The memory stores a computer program that can be loaded by a processor and executed by the secure atomic capability flexible scaling and flow allocation method described in any of the first aspects.
[0022] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium storing a computer program that can be loaded by a processor and executed by the secure atomic capability flexible scaling and flow allocation method according to any one of the first aspects. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating a method for flexible expansion and contraction of secure atomic capabilities and flow allocation provided in an embodiment of this application.
[0024] Figure 2 This is a structural block diagram of a secure atomic capability flexible expansion / contraction and flow distribution device provided in an embodiment of this application.
[0025] Figure 3 This is a structural block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0026] The present application will be further described in detail below with reference to the accompanying drawings.
[0027] This application provides a method for flexible scaling and traffic allocation of secure atomic capabilities. This method can be executed by an electronic device, which can be a server or a terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smartphone, tablet computer, desktop computer, etc., but is not limited to these.
[0028] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments 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.
[0029] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.
[0030] like Figure 1 As shown, a method for flexible expansion and contraction of safe atomic capabilities and flow allocation is described in the following main process flow (steps S101 to S106): Step S101: Classify instances according to historical load and business type to determine multiple instance clusters and the instance category of each instance cluster.
[0031] Each instance of the security atomic capability in the system has a corresponding business type (e.g., permission verification, compliance detection, vulnerability scanning, etc.), and the instance clusters and instance categories correspond one-to-one.
[0032] Specifically, instances are categorized based on historical load and business type to determine multiple instance clusters and the instance category of each instance cluster. This includes: dividing instances according to business type to obtain multiple instance clusters; obtaining historical operating data of the instance clusters, including historical time, historical request count, and historical CPU load rate; analyzing the historical operating data to determine the request fluctuation coefficient and CPU fluctuation coefficient of the instance clusters; and analyzing the request fluctuation coefficient and CPU fluctuation coefficient using preset thresholds to determine the instance category of the instance clusters.
[0033] In this embodiment, firstly, the instances corresponding to all security atomic capabilities are divided according to the business type to obtain multiple instance clusters. All instances in an instance cluster correspond to the same business type. Then, the instance category of the instance cluster is determined according to the stability of the requests and CPU load of each instance in the instance cluster.
[0034] Historical operational data (up to 24 hours) for each instance cluster is retrieved from the database. This historical operational data is then divided into multiple time windows at preset intervals (e.g., 10 minutes). For each time window, the single-window request fluctuation coefficient is calculated based on the maximum and minimum request values and the average request value for each instance within the current time window. The single-window request fluctuation coefficient for an instance is calculated as (maximum request value - minimum request value) / average request value. Next, the single-instance average request fluctuation coefficient for an instance across all time windows is calculated. This average single-instance request fluctuation coefficient is the average of the single-window request fluctuation coefficients for an instance across all time windows. Finally, the average of the single-instance average request fluctuation coefficients for all instances in an instance cluster is calculated, which is the request fluctuation coefficient for the instance cluster.
[0035] For example: If instance cluster A includes 3 instances, and historical execution data is divided into 2 time windows, the historical request counts for each instance in the first time window are as follows: Instance 1 (3, 6, 9, 12), Instance 2 (4, 7, 10, 13), Instance 3 (5, 8, 11, 14); and the historical request counts for each instance in the second time window are as follows: Instance 1 (15, 18, 21, 24), Instance 2 (16, 19, 22, 25), Instance 3 (17, 20, 23, 26). The single-window request volatility coefficient of Instance 1 in the first time window = (12-3) / [(3+6+9+12) / 4] = 1.20; the single-window request volatility coefficient of Instance 1 in the second time window = (24-15) / [(15+18+21+24) / 4] ≈ 0.46; the single-instance average request volatility coefficient of Instance 1 across all time windows = (1.2+0.46) / 2 = 0.83. The single-window request fluctuation coefficient of Instance 2 in the first time window is (13-4) / [(4+7+10+13) / 4]≈1.06, the single-window request fluctuation coefficient of Instance 2 in the second time window is (25-16) / [(16+19+22+25) / 4]≈0.44, and the single-instance average request fluctuation coefficient of Instance 3 in all time windows is (1.06+0.44) / 2=0.75; The single-window request fluctuation coefficient of Instance 3 in the first time window is (14-5) / [(5+8+11+14) / 4]≈0.95, the single-window request fluctuation coefficient of Instance 3 in the second time window is (26-17) / [(17+20+23+26) / 4]≈0.42, and the single-instance average request fluctuation coefficient of Instance 3 across all time windows is (0.95+0.42) / 2=0.69; The request fluctuation coefficient of instance cluster A is approximately 0.76 (0.83 + 0.75 + 0.69) / 3.
[0036] It is worth noting that the calculation method for the CPU fluctuation coefficient of the instance cluster is the same as that for the request fluctuation coefficient mentioned above. The only difference is that the number of requests in the above calculation process is replaced with the CPU load rate. The single-window CPU load fluctuation coefficient of an instance = (maximum CPU load rate in the window - minimum CPU load rate in the window) / average CPU load rate in the window. The single-instance average CPU load rate fluctuation coefficient is the average of the single-window CPU load rate fluctuation coefficients of an instance across all time windows. The CPU fluctuation coefficient of an instance cluster is the average of the single-instance average CPU load rate fluctuation coefficients of all instances in the instance cluster.
[0037] Instance categories are composed of stability level and business type. Stability levels include stable (A), fluctuating (B), and bursty (C). For example, instance category A is permission verification and C is vulnerability scanning. The preset thresholds include the request fluctuation coefficient threshold and CPU fluctuation coefficient threshold for each stability level. According to the stability level from high to low (from A to C), the preset threshold of the corresponding level is compared with the request fluctuation coefficient and CPU fluctuation coefficient of the instance cluster. If the request fluctuation coefficient and CPU fluctuation coefficient of the instance cluster simultaneously meet the request fluctuation coefficient threshold and CPU fluctuation coefficient threshold of a stability level, then the stability level is determined as the stability level of the instance cluster. Then, the instance category is generated by combining the business type of the instance cluster.
[0038] Step S102: Construct a traffic prediction model for each instance category.
[0039] One of the traffic prediction models can predict the total number of requests for a business type (one instance category corresponds to one business type) at a future time, as well as the CPU load rate of each instance when the total number of requests is evenly distributed among the instances in the instance cluster.
[0040] Specifically, a traffic prediction model for each instance category is constructed, including: training the Long Short-Term Memory network using historical running data from each instance cluster to construct a traffic prediction model for each instance category.
[0041] In this embodiment, the Long Short-Term Memory network is trained using historical running data corresponding to an instance cluster to obtain the traffic prediction model for that instance cluster (instance category). That is, each instance cluster (instance category) corresponds to a traffic prediction model, making the training of the traffic prediction model more targeted and improving the accuracy of the traffic prediction model.
[0042] Step S103: Based on the traffic prediction model, predict the number of requests and the CPU load rate of the target instance cluster.
[0043] Each instance cluster can be used as a target instance cluster for subsequent steps. The real-time request count and CPU load rate of each instance in the target instance cluster are input into the traffic prediction model to predict the total number of requests for the target instance cluster in the future, as well as the predicted CPU load rate of each instance in the target instance cluster.
[0044] Step S104: Determine the scaling threshold of the target instance cluster based on the target instance category.
[0045] Among them, the target instance category is the instance category corresponding to the target instance cluster, and the scaling threshold includes the request scaling threshold and the CPU scaling threshold. The request scaling threshold includes the request scaling threshold and the request scaling threshold, and the CPU scaling threshold includes the CPU scaling threshold and the CPU scaling threshold.
[0046] Specifically, determining the scaling threshold of the target instance cluster based on the target instance category includes: obtaining the CPU scaling threshold of the target instance cluster based on the target instance category; determining the single-instance request threshold for each instance in the target instance cluster based on the CPU scaling threshold and the relationship between CPU and requests; and determining the request scaling threshold based on the single-instance request threshold and the current number of instances in the target instance cluster.
[0047] In this embodiment, different stability levels correspond to different CPU scaling thresholds. The higher the stability level, the larger both the CPU scaling threshold and the CPU scaling threshold. The CPU scaling threshold of the target instance cluster is obtained from the database according to the stability level in the target instance category. The database pre-stores the association between CPU and requests obtained through stress testing (such as simulating requests with JMeter). The association includes the maximum number of requests that an instance can handle at various CPU load rates (the maximum number of requests that each instance in the same instance cluster can handle at the same CPU load rate is the same). The single instance request threshold includes the single instance request scaling threshold and the single instance request scaling threshold. The maximum number of requests corresponding to the CPU scaling threshold in the association is determined as the single instance request scaling threshold, and the maximum number of requests corresponding to the CPU scaling threshold in the association is determined as the single instance request scaling threshold.
[0048] The target instance cluster's request scaling-up threshold = the single instance request scaling-up threshold of the target instance cluster × the current number of instances in the target instance cluster; the target instance cluster's request scaling-down threshold = the single instance request scaling-down threshold of the target instance cluster × the current number of instances in the target instance cluster.
[0049] Step S105: Determine whether scaling up or down is necessary based on the predicted CPU load rate, predicted request count, and scaling up / down threshold of the target instance cluster.
[0050] If the predicted CPU load rate of the target instance cluster is greater than the CPU expansion threshold of the target instance cluster, and the predicted number of requests is greater than the request expansion threshold of the target instance cluster, then expansion is required; if the predicted CPU load rate of the target instance cluster is less than the CPU reduction threshold of the target instance cluster, and the predicted number of requests is less than the request reduction threshold of the target instance cluster, then reduction is required; otherwise, no expansion or reduction is required.
[0051] Step S106: If scaling up or down is required, determine the scaling up or down strategy of the target instance cluster based on the predicted number of requests and the target instance type, and determine the traffic allocation strategy of the target instance cluster based on the preset allocation rules.
[0052] Specifically, the scaling strategy for the target instance cluster is determined based on the predicted number of requests and the target instance category, including: determining the redundancy coefficient based on the target instance category; determining the number of target instances based on the predicted number of requests, the stable number of requests per instance, and the redundancy coefficient; determining the scaling up / down quantity based on the current number of instances and the target number of instances; and determining the scaling up / down strategy based on the scaling up / down quantity and the target instance cluster.
[0053] In this embodiment, different target instance categories correspond to different redundancy coefficients (affecting the number of instances that can be scaled up or down). The redundancy coefficient is obtained from the database based on the target instance category. The number of stable requests per instance is obtained from the database based on the business type in the target instance category. The number of stable requests per instance is the number of requests with the lowest probability of instance failure. That is, when the number of requests per instance is the number of stable requests per instance, the probability of instance failure is the lowest.
[0054] The scaling-up and scaling-down quantities include the scaling-up quantity and the scaling-down quantity. If scaling-up is required, the target number of instances after scaling-up = predicted number of requests / stable number of requests per instance × redundancy coefficient, and the scaling-up quantity = target number of instances after scaling-up - current number of instances in the target instance cluster. If scaling-down is required, the target number of instances after scaling-down = predicted number of requests / stable number of requests per instance × redundancy coefficient, and the scaling-down quantity = current number of instances in the target instance cluster - target number of instances after scaling-down. The scaling-up and scaling-down strategy is to increase (scale-up) or decrease (scale-down) instances according to the scaling-up and scaling-down quantities.
[0055] Specifically, the traffic allocation strategy for the target instance cluster is determined based on preset allocation rules, including: determining the CPU idle load of each instance in the target instance cluster; calculating the allocation weight of each instance based on the CPU idle load; calculating the traffic allocation ratio of each instance based on the allocation weight; and determining the traffic allocation strategy based on the traffic allocation ratio.
[0056] In this embodiment, the preset allocation rule is to determine the traffic allocation strategy based on the CPU idle load of each instance. Specifically, it includes: after scaling up or down, obtaining the CPU idle load of each instance in the target instance cluster from the monitoring system (calculated as: 1 - current CPU load rate); the allocation weight of an instance = the CPU idle load of that instance / the sum of the CPU idle loads of all instances in the target instance cluster; after determining the allocation weight of all instances in the target instance cluster, calculating the traffic allocation ratio of each instance based on the allocation weight; the traffic allocation strategy is to allocate traffic to each instance according to the traffic allocation ratio.
[0057] More specifically, the traffic allocation ratio for each instance is calculated based on the allocation weights, including: if a new instance exists in the target instance cluster, obtaining the current stage of the new instance; determining the weight cap and traffic cap of the new instance in the current stage based on the target instance category; updating the allocation weight of the new instance based on the weight cap and the allocation weights; calculating the traffic allocation ratio of the new instance based on the updated allocation weights; updating the traffic allocation ratio of the new instance based on the traffic allocation ratio and the traffic caps; and calculating the traffic allocation ratio of the original instances based on the updated traffic allocation ratio and the allocation weights of the original instances.
[0058] In this embodiment, after expansion, there will be new instances. The capacity warm-up of the new instances (such as JVM class loading and cache initialization) requires a certain amount of time. If a large amount of traffic is directly allocated, it may cause response delays or even failures. Therefore, it is necessary to gradually increase the traffic allocation according to the traffic carrying capacity gradient. The traffic carrying capacity gradient includes multiple traffic carrying capacity stages arranged in chronological order. The upper limit of the weight and the upper limit of the traffic for each traffic carrying capacity stage are different. At the same time, the traffic carrying capacity stages, the upper limit of the weight and the upper limit of the traffic for each traffic carrying capacity stage are different for different instance types.
[0059] If a new instance exists in the target instance cluster, the current stage of the new instance is obtained. The database stores the correspondence between the target instance category, the current stage, the weight limit, and the traffic limit. Based on the target instance category and the current stage, the current weight limit and traffic limit of the new instance are obtained from the database. If the allocated weight of the new instance calculated based on the CPU idle load is greater than the weight limit, the weight limit is used as the updated allocated weight of the new instance. If the allocated weight of the new instance calculated based on the CPU idle load is less than or equal to the weight limit, the allocated weight of the new instance does not need to be adjusted, and the allocated weight of the existing instance does not need to be adjusted.
[0060] The traffic allocation ratio for a new instance = the updated allocation weight of the new instance / the sum of the updated allocation weights of all instances in the target instance cluster (including new instances and existing instances); if the traffic allocation ratio of the new instance calculated according to the allocation weight is greater than the traffic limit, then the traffic limit will be used as the updated traffic allocation ratio of the new instance; if the traffic allocation ratio of the new instance calculated according to the allocation weight is less than or equal to the traffic limit, then there is no need to adjust the traffic allocation ratio of the new instance.
[0061] The traffic allocation ratio of an existing instance = (1 - the sum of the traffic allocation ratios of all new instances) × the allocation weight of the existing instance / the sum of the allocation weights of all existing instances in the target instance cluster. Traffic is allocated to each instance according to the traffic allocation ratio.
[0062] Figure 2 This is a structural block diagram of a secure atomic capability flexible expansion and contraction and flow distribution device 200 provided in an embodiment of this application.
[0063] like Figure 2 As shown, the safe atomic capability flexible expansion / contraction and flow distribution device 200 mainly includes: The cluster category division module 201 is used to classify instances according to historical load and business type, determine multiple instance clusters and the instance category of each instance cluster, and there is a one-to-one correspondence between instance clusters and instance categories; Prediction model building module 202 is used to build traffic prediction models for each instance category; The prediction module 203 is used to predict the number of predicted requests and the CPU load rate of the target instance cluster based on the traffic prediction model. The cluster threshold determination module 204 is used to determine the scaling threshold of the target instance cluster based on the target instance category, where the target instance category is the instance category corresponding to the target instance cluster. The cluster scaling determination module 205 is used to determine whether scaling is needed based on the predicted CPU load rate, predicted request quantity, and scaling threshold of the target instance cluster. The scaling strategy determination module 206 is used to determine the scaling strategy of the target instance cluster based on the predicted number of requests and the target instance type if scaling is required, and to determine the traffic allocation strategy of the target instance cluster based on the preset allocation rules.
[0064] As an optional implementation of this embodiment, the cluster category division module 201 is specifically used to classify instances according to historical load conditions and business types, and determine multiple instance clusters and the instance category of each instance cluster, including: dividing instances according to business types to obtain multiple instance clusters; obtaining historical operating data of the instance clusters, including historical time, historical request count, and historical CPU load rate; analyzing the historical operating data to determine the request fluctuation coefficient and CPU fluctuation coefficient of the instance clusters; and analyzing the request fluctuation coefficient and CPU fluctuation coefficient through preset thresholds to determine the instance category of the instance clusters.
[0065] As an optional implementation of this embodiment, the prediction model building module 202 is specifically used to build a traffic prediction model for each instance category, including: training the Long Short-Term Memory network with historical running data of each instance cluster to build a traffic prediction model for each instance category.
[0066] As an optional implementation of this embodiment, the scaling threshold includes a request scaling threshold and a CPU scaling threshold. The cluster threshold determination module 204 is specifically used to determine the scaling threshold of the target instance cluster based on the target instance category, including: obtaining the CPU scaling threshold of the target instance cluster based on the target instance category; determining the single instance request threshold of each instance in the target instance cluster based on the CPU scaling threshold and the association between CPU and requests; and determining the request scaling threshold based on the single instance request threshold and the current number of instances in the target instance cluster.
[0067] As an optional implementation of this embodiment, the scaling strategy determination module 206 is specifically used to determine the scaling strategy of the target instance cluster based on the predicted number of requests and the target instance category, including: determining the redundancy coefficient based on the target instance category; determining the number of target instances based on the predicted number of requests, the number of stable requests per instance, and the redundancy coefficient; determining the scaling quantity based on the current number of instances and the target number of instances; and determining the scaling strategy based on the scaling quantity and the target instance cluster.
[0068] As an optional implementation of this embodiment, the scaling up / down strategy determination module 206 is specifically used to determine the traffic allocation strategy of the target instance cluster based on preset allocation rules, including: determining the CPU idle load of each instance in the target instance cluster; calculating the allocation weight of each instance based on the CPU idle load; calculating the traffic allocation ratio of each instance based on the allocation weight; and determining the traffic allocation strategy based on the traffic allocation ratio.
[0069] As an optional implementation of this embodiment, the scaling-up / scaling strategy determination module 206 is specifically used to calculate the traffic allocation ratio of each instance based on the allocation weight, including: if there is a new instance in the target instance cluster, obtaining the current stage of the new instance; determining the weight limit and traffic limit of the new instance in the current stage based on the target instance category; updating the allocation weight of the new instance based on the weight limit and the allocation weight; calculating the traffic allocation ratio of the new instance based on the updated allocation weight; updating the traffic allocation ratio of the new instance based on the traffic allocation ratio and the traffic limit; and calculating the traffic allocation ratio of the original instance based on the updated traffic allocation ratio and the allocation weight of the original instance.
[0070] In one example, the module in any of the above devices may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms.
[0071] For example, when modules in a device can be implemented via a processing element scheduler, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of calling programs. Alternatively, these modules can be integrated together as a system-on-a-chip (SOC).
[0072] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0073] Figure 3 This is a structural block diagram of an electronic device 300 provided in an embodiment of this application.
[0074] like Figure 3 As shown, the electronic device 300 includes a processor 301 and a memory 302, and may further include one or more of an information input / output (I / O) interface 303, a communication component 304, and a communication bus 305.
[0075] The processor 301 controls the overall operation of the electronic device 300 to complete all or part of the steps of the aforementioned secure atomic capability flexible scaling and flow allocation method. The memory 302 stores various types of data to support the operation of the electronic device 300. This data may include, for example, instructions for any application or method operating on the electronic device 300, as well as application-related data. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as one or more of 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.
[0076] I / O interface 303 provides an interface between processor 301 and other interface modules, such as keyboards, mice, and buttons. These buttons can be virtual or physical. Communication component 304 is used for wired or wireless communication between electronic device 300 and other devices. Wireless communication includes Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination thereof. Therefore, the corresponding communication component 304 may include a Wi-Fi component, a Bluetooth component, and an NFC component.
[0077] The electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the secure atomic capability flexible scaling and flow allocation method given in the above embodiments.
[0078] The communication bus 305 may include a path for transmitting information between the aforementioned components. The communication bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus 305 may be divided into an address bus, a data bus, a control bus, etc.
[0079] Electronic device 300 may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers, and may also be servers.
[0080] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described secure atomic capability flexible scaling and flow allocation method.
[0081] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0082] The terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0083] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the foregoing application concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions claimed in this application.
Claims
1. A method for flexible expansion / contraction and flow distribution of safe atomic capabilities, characterized in that, include: The instances are categorized according to historical load and business type to determine multiple instance clusters and the instance category of each instance cluster, with each instance cluster corresponding to one instance category; Construct a traffic prediction model for each of the instance categories; Based on the traffic prediction model, the predicted number of requests and the predicted CPU load rate of the target instance cluster are predicted. The scaling threshold of the target instance cluster is determined based on the target instance category, where the target instance category is the instance category corresponding to the target instance cluster; Whether scaling up or down is necessary is determined based on the predicted CPU load rate, the predicted number of requests, and the scaling up / down threshold of the target instance cluster. If scaling up or down is required, the scaling up or down strategy for the target instance cluster is determined based on the predicted number of requests and the target instance category, and the traffic allocation strategy for the target instance cluster is determined based on the preset allocation rules.
2. The method according to claim 1, characterized in that, The step of classifying instances based on historical load and service type to determine multiple instance clusters and the instance category of each instance cluster includes: The instances are divided according to the business type to obtain multiple instance clusters; Obtain historical operational data of the instance cluster, including historical time, historical request count, and historical CPU load rate; The historical operational data is analyzed to determine the request fluctuation coefficient and CPU fluctuation coefficient of the instance cluster. The instance category of the instance cluster is determined by analyzing the request fluctuation coefficient and the CPU fluctuation coefficient using preset thresholds.
3. The method according to claim 1, characterized in that, The construction of the traffic prediction model for each instance category includes: The Long Short-Term Memory network is trained using historical operating data from each instance cluster to construct the traffic prediction model for each instance category.
4. The method according to claim 1, characterized in that, The scaling thresholds include request scaling thresholds and CPU scaling thresholds. Determining the scaling thresholds for the target instance cluster based on the target instance category includes: The CPU scaling threshold of the target instance cluster is obtained based on the target instance category; The single-instance request threshold for each instance in the target instance cluster is determined based on the CPU scaling threshold and the correlation between CPU and request. The request scaling threshold is determined based on the single instance request threshold and the current number of instances in the target instance cluster.
5. The method according to claim 4, characterized in that, The process of determining the scaling strategy for the target instance cluster based on the predicted request count and the target instance category includes: The redundancy coefficient is determined based on the target instance category; The target number of instances is determined based on the predicted number of requests, the stable number of requests per instance, and the redundancy coefficient. The scaling up / down quantity is determined based on the current number of instances and the target number of instances; The scaling strategy is determined based on the scaling-up / scaling-down quantity and the target instance cluster.
6. The method according to claim 1, characterized in that, The process of determining the traffic allocation strategy for the target instance cluster based on preset allocation rules includes: Determine the CPU idle load of each instance in the target instance cluster; The allocation weight of each instance is calculated based on the CPU idle load; The traffic allocation ratio for each instance is calculated based on the allocation weights. The traffic allocation strategy is determined based on the traffic allocation ratio.
7. The method according to claim 6, characterized in that, The calculation of the traffic allocation ratio for each instance based on the allocation weight includes: If a new instance is added to the target instance cluster, the current stage of the new instance is obtained. The weight cap and traffic cap of the newly added instance in the current stage are determined based on the target instance category; The allocation weight of the newly added instance is updated based on the weight cap and the allocation weight; The traffic allocation ratio of the newly added instance is calculated based on the updated allocation weight; The traffic allocation ratio of the newly added instance is updated based on the traffic allocation ratio and the traffic limit. The traffic allocation ratio of the original instance is calculated based on the updated traffic allocation ratio and the allocation weight of the original instance.
8. A safe atomic-capacity flexible expansion / contraction and flow distribution device, characterized in that, include: The cluster category division module is used to classify instances according to historical load and business type, determine multiple instance clusters and the instance category of each instance cluster, and the instance clusters correspond one-to-one with the instance categories; A prediction model building module is used to build a traffic prediction model for each of the instance categories; The prediction model prediction module is used to predict the number of predicted requests and the CPU load rate of the target instance cluster based on the traffic prediction model. The cluster threshold determination module is used to determine the scaling threshold of the target instance cluster based on the target instance category, wherein the target instance category is the instance category corresponding to the target instance cluster; The cluster scaling determination module is used to determine whether scaling is required based on the predicted CPU load rate, the predicted number of requests, and the scaling threshold of the target instance cluster. The scaling-up / scaling strategy determination module is used to determine the scaling-up / scaling strategy of the target instance cluster based on the predicted number of requests and the target instance category if scaling-up / scaling is required, and to determine the traffic allocation strategy of the target instance cluster based on preset allocation rules.
9. An electronic device, characterized in that, Includes a processor, which is coupled to a memory; The processor is configured to execute a computer program stored in the memory to cause the electronic device to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It includes a computer program or instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 7.