A method and apparatus for container replica planning
By dynamically planning the number of container replicas, and based on the fluctuation characteristics of load data and the buffering coefficient, the problem that static buffering strategies cannot adapt to complex and ever-changing service requirements is solved, thereby improving resource utilization and service quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NEUSOFT CORP
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, container replica planning adopts a static buffering strategy, which cannot adapt to complex and ever-changing service processing needs, resulting in low resource utilization, insufficient service buffering, and affecting service quality.
By continuously collecting load data of the target service, obtaining the fluctuation characteristics of the load data, calculating the buffer coefficient, and adaptively planning the number of container replicas based on the buffer coefficient and load prediction value, an incremental strategy is adopted for adjustment, and the planning is optimized by combining service status feedback.
It achieves dynamic container replica planning, adaptively and precisely controls the number of container replicas, improves resource utilization efficiency, ensures service quality, avoids resource waste, and adapts to normal load fluctuations and abnormal traffic surges.
Smart Images

Figure CN122173203A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method and apparatus for container replication planning. Background Technology
[0002] With the widespread adoption of containerization technology, container replica planning has become a core element in ensuring service stability and improving resource utilization efficiency. To adapt to diverse and ever-changing service processing needs, container scaling systems must achieve refined utilization of server resources and avoid resource waste through reasonable replica planning, while meeting service processing requirements and ensuring service quality.
[0003] In existing technologies, container replica planning typically employs a static buffering strategy, configuring all services with a uniform resource reservation ratio, and relying solely on simple threshold judgments or fixed ratio calculations for replica quantity planning. This approach cannot adapt to complex and ever-changing service processing demands, resulting in low resource utilization, insufficient service buffering, and consequently impacting service quality. Summary of the Invention
[0004] To address the aforementioned issues, this application provides a method and apparatus for container replica planning, enabling dynamic container replica planning, adaptively and precisely controlling the number of container replicas, improving resource utilization efficiency while ensuring service quality.
[0005] This application discloses a method for container replica planning, the method comprising: Continuously collect load data of the target service; the types of load data include concurrency, task queue length, and queries per second; The fluctuation characteristics of the load data within a preset time period are obtained; the fluctuation characteristics include the fluctuation amplitude, the intensity of load mutation, and the trend of the load data relative to the historical baseline. Calculate the buffer coefficient based on the fluctuation characteristics; The number of replicas is obtained based on the buffer coefficient, the pre-obtained load prediction value, and the preset configuration of the target service.
[0006] Optionally, obtaining the fluctuation characteristics of the load data within a preset time period includes: For the time series of the load data, obtain the standard deviation and mean; The coefficient of variation, which characterizes the fluctuation range, is obtained by dividing the standard deviation by the mean. Obtain the maximum load change among adjacent sampling points in the time series; The quotient of the maximum load change and the mean value is used to obtain the mutation intensity coefficient, which characterizes the intensity of the load mutation. Get the load data value at the current moment; Obtain the absolute difference between the current load data value and the mean, and obtain the quotient of the absolute difference and the mean to obtain the trend strength coefficient characterizing the trend of change.
[0007] Optionally, calculating the buffer coefficient based on the fluctuation characteristics includes: The buffer coefficient is calculated based on the fluctuation characteristics and preset parameters; the preset parameters include a basic buffer coefficient, a maximum buffer coefficient, a volatility weight coefficient, a sudden change weight coefficient, and a trend weight coefficient; the volatility weight coefficient is used to control the influence of the variation coefficient on the buffer, the sudden change weight coefficient is used to control the influence of the sudden change intensity coefficient on the buffer, and the trend weight coefficient is used to control the influence of the trend intensity coefficient on the buffer.
[0008] Optionally, obtaining the number of replicas based on the buffer coefficient, the pre-obtained load forecast value, and the preset configuration of the target service includes: Obtain the quotient between the predicted load value and the single replica service capacity in the preset configuration to get the quotient value; Obtain the sum of the buffer coefficient and 1; Multiply the quotient by the sum to obtain the product, and round the product up to obtain the number of copies.
[0009] Optionally, after obtaining the number of replicas, the method further includes: A gradual strategy is adopted to adjust the number of replicas; the gradual strategy involves adjusting the number of replicas multiple times, with the magnitude of each adjustment being less than or equal to a preset portion of the current number of replicas, and the interval between each adjustment being greater than or equal to a preset interval.
[0010] Optionally, after performing replica number adjustment using a gradual strategy, the method further includes: Obtain the service status of the target service; the service status includes service response time and CPU / memory utilization. The service status is evaluated based on the preset configuration, and the evaluation results are fed back to optimize the replication quantity planning.
[0011] Optionally, after performing replica number adjustment using a gradual strategy, the method further includes: The service status of the target service is collected in real time; the service status includes service response time and CPU / memory utilization. If the service status deviates from the preset requirements, container replica planning will be triggered again.
[0012] Optionally, after calculating the buffer coefficient based on the fluctuation characteristics, the method further includes: The calculated buffer coefficient is constrained by an upper limit constraint, and the buffer coefficient is updated; the upper limit constraint is a preset value or is calculated based on historical data.
[0013] Optionally, after obtaining the number of replicas, the method further includes: The obtained number of replicas is constrained by the minimum number of replicas, the maximum number of replicas, and the resource quota in the preset configuration, and the number of replicas is updated.
[0014] Optionally, obtaining the fluctuation characteristics of the load data within a preset time period includes: Different priorities are set for each type of load data to obtain high-priority type load data and low-priority type load data; If the high-priority load data is valid, obtain the fluctuation characteristics of the high-priority load data within the preset time period; If the high-priority load data is invalid, obtain the fluctuation characteristics of the low-priority load data within the preset time period.
[0015] Based on the above-mentioned method for planning container replicas, this application also discloses an apparatus for planning container replicas, including: a collection unit, an acquisition unit, a calculation unit, and a planning unit; The collection unit is used to continuously collect load data of the target service; the types of load data include concurrency, task queue length, and queries per second. The acquisition unit is used to acquire the fluctuation characteristics of the load data within a preset time period; the fluctuation characteristics include fluctuation amplitude, load change intensity, and the change trend of the load data relative to the historical baseline; The calculation unit is used to calculate the buffer coefficient based on the fluctuation characteristics; The planning unit is used to obtain the number of replicas based on the buffer coefficient, the pre-acquired load forecast value, and the preset configuration of the target service.
[0016] Optionally, the acquisition unit includes: The first acquisition subunit is used to acquire the standard deviation and mean of the time series of the load data; The coefficient of variation acquisition subunit is used to obtain the quotient of the standard deviation and the mean, thereby obtaining the coefficient of variation characterizing the fluctuation amplitude; The second acquisition subunit is used to acquire the maximum load change of adjacent sampling points in the time series. The mutation intensity coefficient acquisition subunit is used to obtain the quotient of the maximum load change and the mean value to obtain the mutation intensity coefficient characterizing the load mutation intensity; The third acquisition subunit is used to acquire the load data value at the current moment; The trend strength coefficient acquisition subunit is used to obtain the absolute difference between the current load data value and the mean, and to obtain the quotient of the absolute difference and the mean to obtain the trend strength coefficient characterizing the trend of change.
[0017] Optionally, the computing unit includes: The buffer coefficient calculation subunit is used to calculate the buffer coefficient based on the volatility characteristics and preset parameters. The preset parameters include a basic buffer coefficient, a maximum buffer coefficient, a volatility weight coefficient, a sudden change weight coefficient, and a trend weight coefficient. The volatility weight coefficient is used to control the influence of the variation coefficient on the buffer, the sudden change weight coefficient is used to control the influence of the sudden change intensity coefficient on the buffer, and the trend weight coefficient is used to control the influence of the trend intensity coefficient on the buffer.
[0018] Optionally, the planning unit includes: The fourth acquisition subunit is used to obtain the quotient of the load prediction value and the single replica service capacity in the preset configuration, and obtain the quotient value; The fifth acquisition subunit is used to acquire the sum of the buffer coefficient and 1; The replica quantity acquisition subunit is used to multiply the quotient value by the sum value to obtain the product, and then round the product up to obtain the replica quantity.
[0019] Optionally, the device further includes: The incremental adjustment unit is used to perform replica number adjustment using an incremental strategy; the incremental strategy involves adjusting the replica number multiple times, with the magnitude of each replica number adjustment being less than or equal to a preset portion of the current replica number, and the interval between each replica number adjustment being greater than or equal to a preset interval.
[0020] Optionally, the device further includes: A service status acquisition unit is used to acquire the service status of the target service; the service status includes service response time and CPU / memory utilization. An evaluation unit is used to evaluate the service status based on the preset configuration and provide feedback on the evaluation results to optimize the replica quantity planning.
[0021] Optionally, the device further includes: A service status acquisition unit is used to collect the service status of the target service in real time; the service status includes service response time and CPU / memory utilization. The re-trigger unit is used to re-trigger container replica planning when the service status deviates from the preset requirements.
[0022] Optionally, the device further includes: The upper limit constraint unit is used to constrain the calculated buffer coefficient with upper limit constraint conditions and update the buffer coefficient; the upper limit constraint conditions are preset values or calculated based on historical data.
[0023] Optionally, the device further includes: The quantity constraint unit is used to constrain the obtained number of replicas by using the minimum number of replicas, the maximum number of replicas, and the resource quota in the preset configuration as constraints, and to update the number of replicas.
[0024] Optionally, the acquisition unit includes: The priority setting subunit is used to set different priorities for each type of load data to obtain high-priority type load data and low-priority type load data; The high-priority subunit is used to obtain the fluctuation characteristics of the high-priority load data within the preset time period when the high-priority load data is valid. The low-priority subunit is used to obtain the fluctuation characteristics of the low-priority load data within the preset time period when the high-priority load data is invalid.
[0025] This application discloses a method and apparatus for container replica planning. It continuously collects load data of the target service, including concurrency, task queue length, and queries per second. It obtains the fluctuation characteristics of this load data within a preset time period, including fluctuation amplitude, load surge intensity, and the trend of load data relative to a historical baseline. Based on the fluctuation characteristics, a buffer coefficient is calculated, which can adaptively and precisely adjust the buffer ratio according to the actual load data fluctuation. For example, the buffer ratio is reduced for low-fluctuation services and increased for high-fluctuation services, thus pre-planning an appropriate number of replicas based on the buffer coefficient. Simultaneously, it can automatically adjust under both normal load data fluctuations and abnormal traffic surges, demonstrating strong adaptability. Based on the buffer coefficient, the pre-acquired load forecast value, and the preset configuration of the target service, the number of replicas is obtained. This enables dynamic container replica planning, adaptively and precisely controlling the number of container replicas, effectively avoiding resource waste or shortages caused by insufficient or excessive replicas, improving resource utilization efficiency while enhancing service quality. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0027] Figure 1 This is a flowchart illustrating a method for planning container replicas disclosed in an embodiment of this application; Figure 2 This is a flowchart illustrating another method for planning container replicas disclosed in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a container copy planning device disclosed in an embodiment of this application. Detailed Implementation
[0028] 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, and 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] Example 1: This application discloses a method for container replica planning.
[0030] For details, please refer to Figure 1 The container replica planning method disclosed in this embodiment includes the following steps: Step 101: Continuously collect load data of the target service.
[0031] In the method of this embodiment, the types of load data include concurrency (the number of tasks processed simultaneously), task queue length (the number of backlogged tasks to be processed), and queries per second (QPS). Among them, concurrency directly reflects the actual workload of the system, task queue length is suitable for batch / asynchronous processing scenarios, and QPS is suitable for stateless request processing scenarios.
[0032] As a feasible solution, the load data can be collected in real time or at a preset frequency (e.g., once every 5 minutes). The collected load data needs to be saved for at least a preset time period (e.g., 7 days) for subsequent fluctuation analysis and replication planning.
[0033] In the method of this embodiment, the load data may also exist in other types. Here, only concurrency, task queue length and QPS are used as examples. In actual operation, the type of load data is not specifically limited, as long as the method of step 101 can be completed.
[0034] Step 102: Obtain the fluctuation characteristics of the load data within a preset time period.
[0035] In the method of this embodiment, when calculating fluctuation characteristics, one of the three types of load data (concurrency, task queue length, and QPS) proposed in step 101 can be selected for calculation, or multiple types of load data can be considered for a more comprehensive calculation. Specifically, different priorities can be set for each type of load data to obtain high-priority type load data and low-priority type load data. For example, concurrency can be set to the highest priority (first priority), task queue length can be set to the medium priority (second priority), and QPS can be set to the lowest priority (third priority).
[0036] When high-priority load data is valid, the fluctuation characteristics of that high-priority load data within a preset time period are obtained. When high-priority load data is invalid, the fluctuation characteristics of the next lower priority load data within the preset time period are obtained. For example, when the concurrency is valid, the concurrency is used to calculate the fluctuation characteristics. When the concurrency cannot be obtained, or the obtained concurrency is abnormal (such as a short-term jump), the task queue length is obtained, and the fluctuation characteristics are calculated based on the task queue length. When the task queue length is also unobtainable or abnormal, the QPS is obtained, and the fluctuation characteristics are calculated based on the QPS. If the QPS is also unobtainable or abnormal at this point, an invalid load data message can be returned, and the process can be temporarily suspended until valid load data can be obtained.
[0037] In the method of this embodiment, the priority settings can be adjusted according to actual needs. When selecting one type of load data for fluctuation characteristic calculation, different priorities can be set for each type of load data, ultimately selecting one type of load data. Correspondingly, when selecting multiple types of load data for fluctuation characteristic calculation, all types of load data are set to the same priority. Here, only the method with concurrency as the highest priority is illustrated. In actual operation, the specific priority of the load data is not limited; it is sufficient to be able to distinguish different priorities.
[0038] In the method of this embodiment, the fluctuation characteristics include fluctuation amplitude, load mutation intensity, and the trend of load data relative to the historical baseline. As an feasible approach, the fluctuation amplitude can be characterized by the coefficient of variation, the load mutation intensity by the mutation intensity coefficient, and the trend by the trend intensity coefficient.
[0039] In this embodiment, a larger coefficient of variation indicates more severe load fluctuations, requiring a higher buffer ratio to cope with the uncertainty reflected by these fluctuations. Specifically, the coefficient of variation can be obtained by first calculating the standard deviation and mean of the time series load data. Then, the quotient of the standard deviation and the mean is calculated to obtain the coefficient of variation. The formula can be as follows: CV = σ / μ (1) In the formula, CV is the coefficient of variation, σ is the standard deviation, and μ is the mean.
[0040] In this embodiment, a larger mutation intensity coefficient indicates that the load may have experienced a short-term, drastic fluctuation, requiring additional buffer space. Specifically, the mutation intensity coefficient can be obtained by first acquiring the maximum load change among adjacent sampling points in the time series, and then calculating the quotient of the maximum load change and the mean to obtain the mutation intensity coefficient. The formula is as follows: BI=max(|Δload|) / μ (2) In the formula, BI is the mutation intensity coefficient, and max(|Δload|) is the maximum load change.
[0041] In this embodiment, a larger trend strength coefficient indicates that the current load data deviates further from the historical baseline, and the impact of trend changes needs to be considered. Specifically, the trend strength coefficient can be obtained by first acquiring the current load data value, then acquiring the absolute difference between the current load data value and the mean, and finally obtaining the quotient of the absolute difference and the mean to obtain the trend strength coefficient. The formula can be as follows: TR=|current_load-μ| / μ (3) In the formula, TR is the trend strength coefficient, and current_load is the load data value at the current moment.
[0042] In the method of this embodiment, fluctuation features may also include other types of features and coefficients. Here, only CV, BI and TR are introduced as examples. In actual operation, the number and specific content of fluctuation features are not limited, as long as they can reflect the fluctuation status of the load data.
[0043] Step 103: Calculate the buffer coefficient based on the fluctuation characteristics.
[0044] In the method of this embodiment, a buffer coefficient can be calculated based on volatility characteristics and preset parameters. The preset parameters include a base buffer coefficient, a maximum buffer coefficient, a volatility weighting coefficient, a sudden change weighting coefficient, and a trend weighting coefficient. Specifically, the volatility weighting coefficient is used to control the influence of the coefficient of variation on the buffer, the sudden change weighting coefficient is used to control the influence of the sudden change intensity coefficient on the buffer, and the trend weighting coefficient is used to control the influence of the trend intensity coefficient on the buffer.
[0045] In the method of this embodiment, calculating the buffer coefficient based on fluctuation characteristics and preset parameters can quantify and map the load fluctuation characteristics into a buffer ratio, enabling the buffering strategy to adaptively adjust according to the actual load pattern of the service. This allows for higher buffering for services with high volatility and lower buffering for services with low volatility. The specific formula is as follows: α_calculated=α_base×(1+β_volatility×CV+β_burst×BI+β_trend×TR) (4) In the formula, α_calculated is the calculated buffer coefficient, α_base is the basic buffer coefficient (which can be set to 0.2) to ensure the availability of basic services, β_volatility is the volatility weight coefficient (which can be set to 0.3), β_burst is the burst weight coefficient (which can be set to 0.4), and β_trend is the trend weight coefficient (which can be set to 0.2).
[0046] Among them, β_volatility, β_burst, and β_trend are preset fixed parameters determined based on statistical analysis of a large amount of production environment data, used to control the intensity of the impact of various fluctuation characteristics on the buffering strategy. In actual operation, the values of the above preset parameters can be adjusted according to needs for different industries or service types. For example, real-time transaction services can set a higher β_burst to cope with sudden traffic surges, batch processing services can set a higher β_trend to adapt to load trend changes, and offline analysis services can set a higher β_volatility to cope with periodic fluctuations. Therefore, the method of this embodiment does not limit the number or specific values of the above preset parameters, as long as they can control the impact of each fluctuation characteristic.
[0047] In this embodiment, as an feasible solution, to avoid excessively high buffer ratios and resource waste in extremely volatile scenarios, an upper limit constraint can be applied to the calculated buffer coefficient to update it to a lower value. The upper limit constraint can be a preset value derived from historical operational experience or service level agreement requirements, or it can be obtained through regression analysis of historical data, combined with considerations such as business importance and cost. The specific value of the upper limit constraint is not limited here; it only needs to serve a constraining purpose. Specifically, the formula for constraining the calculated buffer coefficient can be as follows: α=min(α_calculated, α_max) (5) In the formula, α is the updated buffer coefficient, and α_max is the value of the upper limit constraint, which can be set to 0.5.
[0048] Step 104: Based on the buffer coefficient, the pre-acquired load prediction value, and the preset configuration of the target service, obtain the number of replicas.
[0049] In the method of this embodiment, the load prediction value comes from an external prediction system (such as a time series model, event modulation prediction system, etc.). It takes the form of a predicted value of the load data over a future period. Taking concurrency as an example, with a collection time interval of 5 minutes, the values of 6 data points are predicted within the next 30 minutes. The load prediction value is the predicted value of the 6 data points within the next 30 minutes, along with the upper and lower limits of the predicted value and the confidence level.
[0050] In the method of this embodiment, the preset configuration of the target service includes single replica service capacity, startup time, minimum number of replicas, maximum number of replicas, and resource quota. The minimum number of replicas allows some replicas (e.g., 2) to be kept available even when the load is zero, thus avoiding cold starts and ensuring that there are always available replicas to handle sudden tasks. The maximum number of replicas prevents unlimited expansion from causing uncontrolled costs or exhausting cluster resources, avoiding resource shortages and single services crowding out resources. Resource quotas prevent a single service from consuming excessive computing resources and affecting other services in a multi-tenant environment.
[0051] In this embodiment, the method for calculating the number of replicas based on the buffer coefficient, load prediction value, and preset configuration can be specifically as follows: First, obtain the quotient of the load prediction value and the service capacity of a single replica. Simultaneously, obtain the sum of the buffer coefficient and 1. Multiply the quotient value and the sum to obtain the product, and then round the product up to obtain the number of replicas. The formula can be as follows: Replicas=ceil(PredictedLoad / ServiceCapacity×(1+α)) (6) In the formula, Replicas is the number of replicas, PredictedLoad is the load prediction value, ServiceCapacity is the service capacity of a single replica, and ceil is the rounding up function.
[0052] In this embodiment, as an feasible approach, the number of replicas is updated by using the minimum number of replicas, the maximum number of replicas, and the resource quota in the preset configuration as constraints. For example, the calculated number of replicas is increased from 1 to 2 based on the minimum number of replicas, and the calculated number of replicas is limited from 25 to 20 based on the maximum number of replicas. As another example, if the resource quota indicates that a single replica requires 2 cores of computing resources, and the cluster only has 30 cores of computing resources remaining, then the calculated number of replicas is limited to a maximum of 15.
[0053] In the method of this embodiment, as an feasible solution, to avoid drastic changes in the number of replicas affecting system stability, a gradual strategy can be used to adjust the number of replicas after updating the number of replicas. The gradual strategy involves adjusting the number of replicas multiple times, with each adjustment being less than or equal to a preset portion of the current number of replicas (e.g., 30%), and the interval between each adjustment being greater than or equal to a preset interval (e.g., 2 minutes).
[0054] In the method of this embodiment, as an feasible solution, after adjusting the number of replicas, the current service status of the target service can be obtained to evaluate whether the current replica plan is reasonable. The service status includes service response time and CPU or memory utilization. Subsequently, the service status is evaluated based on a preset configuration, and the evaluation results are fed back to optimize the replica number plan.
[0055] In the method of this embodiment, as an feasible solution, after adjusting the number of replicas, the service status of the target service can be collected in real time, and if the service status deviates from the preset requirements, the container replica planning can be triggered again to re-plan and adjust the number of replicas.
[0056] The method described in this embodiment achieves precise adjustment of the buffer ratio based on actual load characteristics through a dynamic buffering strategy, avoiding excessive resource reservation caused by traditional fixed buffering strategies and improving resource utilization efficiency. It can reduce the buffer ratio for low-fluctuation services and increase the buffer ratio for high-fluctuation services, achieving refined management of resource allocation and significantly reducing resource costs while ensuring service quality. Simultaneously, the replica planning algorithm can plan ahead and automatically adjust the appropriate number of replicas based on load prediction results and the dynamic buffering strategy, maintaining service stability under both normal load fluctuations and abnormal traffic surges, effectively avoiding service quality issues caused by insufficient or excessive replicas, and enhancing service quality. Finally, a gradual adjustment strategy further improves system stability, avoiding the impact of frequent replica changes on services. Furthermore, it can continuously optimize the replica planning process based on actual operating results without frequent manual intervention.
[0057] Example 2: This application discloses another method for container replication planning; please refer to [link to example]. Figure 2 The method described in this embodiment takes the video transcoding service of an online video platform as an example. It is necessary to plan the number of copies of the transcoding container according to the number of uploaded videos and transcoding requirements.
[0058] Step 201: Collect the concurrency and QPS of the target service at a frequency of 5 minutes / time.
[0059] In the method of this embodiment, the priority of concurrency is high, and the priority of QPS is low.
[0060] Step 202: Determine if the concurrency is valid. If yes, proceed to step 203. If no, proceed to step 204.
[0061] Step 203: Use concurrency as load data. Proceed to step 205.
[0062] Step 204: Use QPS as load data. Proceed to Step 205.
[0063] Step 205: Obtain the fluctuation characteristics of the load data over the past 7 days.
[0064] In this embodiment, a preset time period of 7 days is used, and approximately 2016 sampling points of data can be collected. If the concurrency is used as the load data, the mean is 950, the standard deviation is 427, the peak value is 1520, the trough value is 475, the maximum single load increment is 380, and the load data value at the current moment is 1140.
[0065] Based on the above data, the coefficient of variation in the fluctuation characteristics is calculated to be 427 / 950=0.45, the mutation intensity coefficient is 380 / 950=0.4, and the trend intensity coefficient is |1140-950| / 950=0.2.
[0066] Step 206: Calculate the buffer coefficient based on the fluctuation characteristics and preset parameters.
[0067] In the method of this embodiment, the base buffer coefficient is 0.2, the volatility weight coefficient is 0.3, the suddenness weight coefficient is 0.4, and the trend weight coefficient is 0.2. The calculated buffer coefficient is 0.267.
[0068] Step 207: Constrain the calculated buffer coefficient with the upper limit constraint conditions.
[0069] In the method of this embodiment, the upper limit constraint is set to 0.5, and the buffer coefficient of 0.267 does not trigger the upper limit constraint.
[0070] Step 208: Obtain the load forecast value for the evening peak period, as well as the preset configuration of the target service.
[0071] In the method of this embodiment, the load prediction value is 1200, the preset configuration is a maximum number of replicas of 20, a single replica service capacity of 100, and a startup time of 45 seconds.
[0072] Step 209: Obtain the number of replicas based on the buffer coefficient, load forecast value, and the single replica service capacity in the preset configuration.
[0073] In the method of this embodiment, the number of copies is calculated to be 16.
[0074] Step 210: Constrain the number of replicas using the minimum number of replicas, maximum number of replicas, and resource quota in the preset configuration as constraints.
[0075] In the method of this embodiment, the maximum number of replicas is 20, and the number of replicas has not reached the upper limit.
[0076] Step 211: Gradually adjust the number of copies.
[0077] Step 212: Collect the service status of the target service.
[0078] Step 213: Determine if the service status deviates from the preset requirements. If yes, return to step 201. If no, proceed to step 214.
[0079] Step 214: Evaluate the service status based on the preset configuration and provide feedback on the evaluation results to optimize the replica count planning. Return to step 201.
[0080] Based on the container replica planning method disclosed in the above embodiments, this embodiment correspondingly discloses a container replica planning apparatus. Please refer to... Figure 3 The device for planning container replicas includes: a collection unit 301, an acquisition unit 302, a calculation unit 303, and a planning unit 304; The acquisition unit 301 is used to continuously acquire load data of the target service; the types of load data include concurrency, task queue length, and queries per second. The acquisition unit 302 is used to acquire the fluctuation characteristics of the load data within a preset time period; the fluctuation characteristics include fluctuation amplitude, load change intensity, and the change trend of the load data relative to the historical baseline; The calculation unit 303 is used to calculate the buffer coefficient based on the fluctuation characteristics; The planning unit 304 is used to obtain the number of replicas based on the buffer coefficient, the pre-acquired load prediction value, and the preset configuration of the target service.
[0081] Optionally, the acquisition unit 302 includes: The first acquisition subunit is used to acquire the standard deviation and mean of the time series of the load data; The coefficient of variation acquisition subunit is used to obtain the quotient of the standard deviation and the mean, thereby obtaining the coefficient of variation characterizing the fluctuation amplitude; The second acquisition subunit is used to acquire the maximum load change of adjacent sampling points in the time series. The mutation intensity coefficient acquisition subunit is used to obtain the quotient of the maximum load change and the mean value to obtain the mutation intensity coefficient characterizing the load mutation intensity; The third acquisition subunit is used to acquire the load data value at the current moment; The trend strength coefficient acquisition subunit is used to obtain the absolute difference between the current load data value and the mean, and to obtain the quotient of the absolute difference and the mean to obtain the trend strength coefficient characterizing the trend of change.
[0082] Optionally, the computing unit 303 includes: The buffer coefficient calculation subunit is used to calculate the buffer coefficient based on the volatility characteristics and preset parameters. The preset parameters include a basic buffer coefficient, a maximum buffer coefficient, a volatility weight coefficient, a sudden change weight coefficient, and a trend weight coefficient. The volatility weight coefficient is used to control the influence of the variation coefficient on the buffer, the sudden change weight coefficient is used to control the influence of the sudden change intensity coefficient on the buffer, and the trend weight coefficient is used to control the influence of the trend intensity coefficient on the buffer.
[0083] Optionally, the planning unit 304 includes: The fourth acquisition subunit is used to obtain the quotient of the load prediction value and the single replica service capacity in the preset configuration, and obtain the quotient value; The fifth acquisition subunit is used to acquire the sum of the buffer coefficient and 1; The replica quantity acquisition subunit is used to multiply the quotient value by the sum value to obtain the product, and then round the product up to obtain the replica quantity.
[0084] Optionally, the device further includes: The incremental adjustment unit is used to perform replica number adjustment using an incremental strategy; the incremental strategy involves adjusting the replica number multiple times, with the magnitude of each replica number adjustment being less than or equal to a preset portion of the current replica number, and the interval between each replica number adjustment being greater than or equal to a preset interval.
[0085] Optionally, the device further includes: A service status acquisition unit is used to acquire the service status of the target service; the service status includes service response time and CPU / memory utilization. An evaluation unit is used to evaluate the service status based on the preset configuration and provide feedback on the evaluation results to optimize the replica quantity planning.
[0086] Optionally, the device further includes: A service status acquisition unit is used to collect the service status of the target service in real time; the service status includes service response time and CPU / memory utilization. The re-trigger unit is used to re-trigger container replica planning when the service status deviates from the preset requirements.
[0087] Optionally, the device further includes: The upper limit constraint unit is used to constrain the calculated buffer coefficient with upper limit constraint conditions and update the buffer coefficient; the upper limit constraint conditions are preset values or calculated based on historical data.
[0088] Optionally, the device further includes: The quantity constraint unit is used to constrain the obtained number of replicas by using the minimum number of replicas, the maximum number of replicas, and the resource quota in the preset configuration as constraints, and to update the number of replicas.
[0089] Optionally, the acquisition unit 302 includes: The priority setting subunit is used to set different priorities for each type of load data to obtain high-priority type load data and low-priority type load data; The high-priority subunit is used to obtain the fluctuation characteristics of the high-priority load data within the preset time period when the high-priority load data is valid. The low-priority subunit is used to obtain the fluctuation characteristics of the low-priority load data within the preset time period when the high-priority load data is invalid.
[0090] The embodiments in this specification are described in a progressive manner. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant details can be found in the method section.
[0091] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0092] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0093] The features described in the embodiments of this specification can be substituted for or combined with each other, so that those skilled in the art can implement or use this application.
[0094] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for container replica planning, characterized in that, include: Continuously collect load data of the target service; the types of load data include concurrency, task queue length, and queries per second; The fluctuation characteristics of the load data within a preset time period are obtained; the fluctuation characteristics include the fluctuation amplitude, the intensity of load mutation, and the trend of the load data relative to the historical baseline. Calculate the buffer coefficient based on the fluctuation characteristics; The number of replicas is obtained based on the buffer coefficient, the pre-obtained load prediction value, and the preset configuration of the target service.
2. The method according to claim 1, characterized in that, The step of acquiring the fluctuation characteristics of the load data within a preset time period includes: For the time series of the load data, obtain the standard deviation and mean; The coefficient of variation, which characterizes the fluctuation range, is obtained by dividing the standard deviation by the mean. Obtain the maximum load change among adjacent sampling points in the time series; The quotient of the maximum load change and the mean value is used to obtain the mutation intensity coefficient, which characterizes the intensity of the load mutation. Get the load data value at the current moment; Obtain the absolute difference between the current load data value and the mean, and obtain the quotient of the absolute difference and the mean to obtain the trend strength coefficient characterizing the change trend.
3. The method according to claim 2, characterized in that, The calculation of the buffer coefficient based on the fluctuation characteristics includes: The buffer coefficient is calculated based on the fluctuation characteristics and preset parameters; the preset parameters include a basic buffer coefficient, a maximum buffer coefficient, a volatility weight coefficient, a sudden change weight coefficient, and a trend weight coefficient; the volatility weight coefficient is used to control the influence of the variation coefficient on the buffer, the sudden change weight coefficient is used to control the influence of the sudden change intensity coefficient on the buffer, and the trend weight coefficient is used to control the influence of the trend intensity coefficient on the buffer.
4. The method according to claim 1, characterized in that, The process of obtaining the number of replicas based on the buffer coefficient, the pre-obtained load prediction value, and the preset configuration of the target service includes: Obtain the quotient between the predicted load value and the single replica service capacity in the preset configuration to get the quotient value; Obtain the sum of the buffer coefficient and 1; Multiply the quotient by the sum to obtain the product, and round the product up to obtain the number of copies.
5. The method according to any one of claims 1-4, characterized in that, After obtaining the number of replicas, the method further includes: A gradual strategy is adopted to adjust the number of replicas; the gradual strategy involves adjusting the number of replicas multiple times, with the magnitude of each adjustment being less than or equal to a preset portion of the current number of replicas, and the interval between each adjustment being greater than or equal to a preset interval.
6. The method according to claim 5, characterized in that, After implementing a gradual strategy to adjust the number of replicas, the method further includes: Obtain the service status of the target service; the service status includes service response time and CPU / memory utilization. The service status is evaluated based on the preset configuration, and the evaluation results are fed back to optimize the replication quantity planning.
7. The method according to claim 5, characterized in that, After implementing a gradual strategy to adjust the number of replicas, the method further includes: The service status of the target service is collected in real time; the service status includes service response time and CPU / memory utilization. If the service status deviates from the preset requirements, container replica planning will be triggered again.
8. The method according to any one of claims 1-4, 6, and 7, characterized in that, After calculating the buffer coefficient based on the fluctuation characteristics, the method further includes: The calculated buffer coefficient is constrained by an upper limit constraint, and the buffer coefficient is updated; the upper limit constraint is a preset value or is calculated based on historical data.
9. The method according to any one of claims 1-4, 6, and 7, characterized in that, After obtaining the number of replicas, the method further includes: The obtained number of replicas is constrained by the minimum number of replicas, the maximum number of replicas, and the resource quota in the preset configuration, and the number of replicas is updated.
10. The method according to any one of claims 1-4, 6, and 7, characterized in that, The step of acquiring the fluctuation characteristics of the load data within a preset time period includes: Different priorities are set for each type of load data to obtain high-priority type load data and low-priority type load data; If the high-priority load data is valid, obtain the fluctuation characteristics of the high-priority load data within the preset time period; If the high-priority load data is invalid, obtain the fluctuation characteristics of the low-priority load data within the preset time period.
11. An apparatus for planning container replicas, characterized in that, include: The system comprises a data acquisition unit, a computation unit, and a planning unit. The collection unit is used to continuously collect load data of the target service; the types of load data include concurrency, task queue length, and queries per second. The acquisition unit is used to acquire the fluctuation characteristics of the load data within a preset time period; the fluctuation characteristics include fluctuation amplitude, load change intensity, and the change trend of the load data relative to the historical baseline; The calculation unit is used to calculate the buffer coefficient based on the fluctuation characteristics; The planning unit is used to obtain the number of replicas based on the buffer coefficient, the pre-acquired load forecast value, and the preset configuration of the target service.