Method, device, equipment and readable storage medium for determining service container capacity
By using the container load prediction model in the Kubernetes cluster to predict future load information and determine container capacity, the problem of resource adjustment lag when business load changes is solved, and the quality of business service is improved.
Patent Information
- Application Number
- CN202411782311.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-04
AI Technical Summary
In Kubernetes cluster environment, resources cannot be adjusted in time when business load changes, resulting in the impact of business service quality.
By obtaining the load information of the current container platform and inputting the trained container load prediction model, the target load information for the future period is predicted, and the container capacity of the business container is determined based on the load information and load threshold information.
It has achieved the advance understanding of the development trend of business container load, reasonably allocating computing resources, timely adjusting resources to deal with load changes, and improving business service quality.
Smart Images

Figure CN119759551A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing technology, and in particular relates to a method, device, equipment and readable storage medium for determining service container capacity. Background Art
[0002] In the Kubernetes (k8s, container orchestration engine) cluster environment, as business needs and deployment scale continue to increase, it is necessary to solve the problem of supply and demand balance between resources and business load. When the business load changes, the k8s cluster often has to respond by expanding computing resources.
[0003] In related technologies, HPA (Horizontal Pod Autoscaler, resource object) is usually used to automatically horizontally scale (increase or decrease) the number of copies of Pod (computing unit). It can dynamically adjust resource allocation according to the load changes of the application to ensure that the application can run efficiently under different load conditions.
[0004] However, when using HPA to dynamically adjust resource allocation, since load changes occur instantaneously, the adjustment of resource allocation cannot take effect immediately, which leads to certain systemic risks. It may lead to the inability to adjust resources in time when a rapid response to load changes is needed to ensure the normal operation of the business, thus affecting the quality of business services. Summary of the invention
[0005] The present invention provides a method, device, equipment and readable storage medium for determining business container capacity to solve the problem in the related art that when a rapid response to load changes is required to ensure normal business operation, resources cannot be adjusted in time, affecting the business service quality.
[0006] In a first aspect, the present invention provides a method for determining a service container capacity, the method comprising:
[0007] Get the load information corresponding to the business container in the current container platform;
[0008] Input the load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model; the first preset time period is a time period starting from the current time;
[0009] The container capacity of the service container within the first preset time period is determined according to the load information and the load threshold information.
[0010] In a second aspect, the present invention provides a device for determining a service container capacity, the device comprising:
[0011] The first acquisition module is used to obtain the load information corresponding to the business container in the current container platform;
[0012] A prediction module, used to input the load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model; the first preset time period is a time period starting from the current time;
[0013] The first determining module is used to determine the container capacity of the service container within the first preset time period according to the load information and the load threshold information.
[0014] In a third aspect, the present invention provides an electronic device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.
[0015] In a fourth aspect, the present invention provides a readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method described in the first aspect.
[0016] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0017] By obtaining the load information corresponding to the business container in the current container platform; inputting the load information into the trained container load prediction model, obtaining the target load information of the business container in the first preset time period output by the container load prediction model; the first preset time period is a time period starting at the current moment; according to the load information and load threshold information, determining the container capacity of the business container in the first preset time period. In this way, by inputting the load information of the business container in the current container platform into the trained container load prediction model, the target load information in the first preset time period in the future (starting at the current moment) can be obtained, and the development trend of the business container load can be understood in advance, no longer limited to the control of the current situation, and the container capacity of the business container in the future time period can be determined based on the predicted target load information and the determined load threshold information, which is helpful to reasonably allocate computing resources in advance, and can adjust resources in time when it is necessary to respond quickly to load changes to ensure the normal operation of the business, so as to improve the quality of business services. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a flow chart of a method for determining service container capacity provided by an embodiment of the present application;
[0020] Figure 2 is a structural schematic diagram of a memory unit provided in an embodiment of the present application;
[0021] Figure 3 is a block diagram of a device for determining service container capacity provided by an embodiment of the present application;
[0022] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] Before introducing the method, apparatus, device and storage medium for determining the service container capacity provided by the present disclosure, the application scenarios involved in each embodiment of the present disclosure are first introduced. The present disclosure can be applied to the scenario of balancing the supply and demand between resources and service loads, and the method for determining the service container capacity provided by the embodiment of the present disclosure can be applied to electronic devices, wherein the electronic devices may include handheld devices, vehicle-mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem, as well as various forms of user equipment (UE) (e.g., mobile phones), mobile stations (MS) and other devices.
[0025] In the Kubernetes (k8s, container orchestration engine) cluster environment, as business needs and deployment scale continue to increase, it is necessary to solve the problem of supply and demand balance between resources and business load. When the business load changes, the k8s cluster often has to respond by expanding computing resources.
[0026] The most direct way is to add new nodes. However, as the number of machines increases, the cost also increases. In reality, a large number of services have low loads most of the time, resulting in low overall machine utilization. At the same time, in order to cope with the daily random traffic peak, the business will try to increase the number of replicas as much as possible, and it is difficult for the business side to accurately assess the CPU (Central Processing Unit) and other resources actually required by the service, resulting in a large amount of resource waste.
[0027] Therefore, in related technologies, resource allocation can be adjusted dynamically according to application load changes to ensure that applications can run efficiently under different load conditions. HPA tracks and analyzes the load changes of all target Pods to determine whether to adjust the number of copies of the target Pod in a targeted manner, aiming to solve the gap between the huge fluctuations in business service load and the actual use of resources.
[0028] However, the above solution has obvious lags. When the load changes instantaneously, it cannot take effect immediately, which leads to certain systemic risks. It may lead to the inability to adjust resources in time when it is necessary to respond quickly to load changes to ensure the normal operation of the business, affecting the quality of business services. In addition, when container performance jitter occurs, the solution in the existing technology may repeatedly adjust the number of container copies in a short period of time, which seriously affects the performance of the cluster. For example, it will consume too many computing resources for frequent adjustment operations and affect the stability of other normally running containers.
[0029] Therefore, in order to solve the above problems, the present disclosure provides a method, device, equipment and readable storage medium for determining the capacity of a business container, which can obtain the load information corresponding to the business container in the current container platform; input the load information into a trained container load prediction model to obtain the target load information of the business container in the first preset time period output by the container load prediction model; the first preset time period is a time period starting at the current moment; according to the load information and load threshold information, the container capacity of the business container in the first preset time period is determined. In this way, by inputting the load information of the business container in the current container platform into the trained container load prediction model, the target load information in the first preset time period (starting at the current moment) in the future can be obtained, and the development trend of the business container load can be understood in advance, which is no longer limited to the control of the current situation. The container capacity of the business container in the future time period can be determined based on the predicted target load information and the determined load threshold information, which is helpful to reasonably allocate computing resources in advance, and can adjust resources in time when it is necessary to respond quickly to load changes to ensure the normal operation of the business, so as to improve the quality of business services.
[0030] The method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0031] Figure 1 is a flow chart of a method for determining service container capacity provided by an embodiment of the present application, such as Figure 1 As shown, the method may include the following steps.
[0032] In step S101, load information corresponding to a business container in the current container platform is obtained.
[0033] Among them, the container platform can be used to refer to an environment based on Kubernetes. The container platform can provide an operating environment for the business container. The operating environment can calculate resources (CPU, memory, etc.), network resources and storage resource environment. The business container carries various application services.
[0034] The load information may include CPU-related load information and memory-related load information. The CPU-related load information may include CPU usage and CPU load balancing information.
[0035] Specifically, the CPU usage rate can indicate the percentage of CPU resources occupied by the process in the business container per unit time. For example, if the CPU usage rate of a container is 80%, it means that the application in the container is using the CPU extensively to perform various computing tasks, such as data processing, algorithm operations, etc. The CPU load balancing information can indicate the distribution of the load on each CPU core. If the load of the business container is concentrated on one or several cores, while other cores are idle, performance bottlenecks may occur. For example, if a containerized video transcoding application cannot effectively utilize a multi-core CPU, the transcoding speed may be limited. The degree of CPU load balancing of the container can be evaluated by viewing the usage rate and task allocation of each CPU core.
[0036] The memory-related load information may include memory usage and memory swap information; specifically, the memory usage may indicate the proportion of memory resources occupied by applications in the business container. For example, a container is allocated 2GB of memory, and the current memory usage is 70%, that is, 1.4GB of memory has been used. For memory-intensive applications, such as in-memory database containers, memory usage is a key load indicator. If the memory usage is too high, it may cause insufficient memory, causing program crashes or performance degradation. The swap information is used to indicate that when the memory in the container is insufficient, part of the data is swapped to the swap space on the disk, but because the disk read and write speed is much lower than the memory read and write speed, memory swapping will greatly reduce the running speed of the application. Therefore, it is possible to determine whether memory resources are tight by determining the swap information. For example, if a container frequently swaps memory, it may be necessary to increase memory allocation or optimize the memory usage strategy of the application.
[0037] In this step, since many container platforms (such as Kubernetes) have integrated monitoring functions, such as the Metrics Server (resource usage data aggregator) integrated in the Kubernetes platform, the Metrics Server can collect basic indicator information such as CPU and memory related to the container, and provide an interface for external query. In this way, by interacting with the interface of the container platform, the load data corresponding to each business container can be obtained.
[0038] For example, you can use a command line tool or a related client program to request the Metrics Server to obtain load indicator information such as CPU and memory usage of a specified business container according to a specific interface calling specification.
[0039] In another possible implementation, load information can also be collected by integrating a third-party monitoring system with the container platform.
[0040] Optionally, you can deploy the Prometheus (system monitoring and alert toolkit) service in the container environment and configure the corresponding collection rules and monitoring components. The monitoring components can be used to collect various indicator data of the container and the node where it is located, and then use Prometheus to store, aggregate and process the collected data. Finally, you can use the query interface it provides to obtain the load details of the business container, such as querying the average CPU usage of a specific business container under a namespace in the past hour.
[0041] In step S102, the load information is input into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model.
[0042] The first preset time period is a time period starting from the current time.
[0043] In this step, the load information can be input into the trained container load prediction model, which can mine the time series features hidden in the load information, the mutual influence relationship between different indicators, etc., so as to simulate the trend of business container load changes to a certain extent, and can output the predicted values of various load indicators of the business container in the first preset time period after calculation and reasoning. For example, when the container load prediction model learns that the CPU usage of a certain business container will gradually increase from 9 to 11 a.m. every day as the business access volume increases, when the current load information and the corresponding time information are input, the approximate change of CPU usage in the next period of time can be predicted.
[0044] In this way, the predicted target load information is crucial for subsequent resource management decisions. Operations and maintenance personnel can perform container expansion and reduction operations, resource quota adjustments, etc. in advance based on these prediction results to ensure the stable and efficient operation of business services.
[0045] In some embodiments, the load information includes the requested resource amount and memory capacity of the business container at the current moment, wherein the requested resource amount can be used to represent CPU-related load information, and the memory capacity can be used to represent memory-related load information.
[0046] In this embodiment, first, the first load indicator information of the business container is determined according to the requested resource amount, and the second load indicator information of the business container is determined according to the memory capacity; then, when the load indicator information corresponding to the business container is determined according to the first load indicator information and the second load indicator information, the container capacity of the business container within the first preset time period can be determined according to the load indicator information and the load threshold information.
[0047] Optionally, the requested resource amount can be represented by the CPU main frequency f of the container, the number of CPU cores is n, and the performance conversion coefficient in a multi-core environment is t. The CPU performance of container k can be obtained by the following formula:
[0048]
[0049] Among them, C k is the CPU performance C of container k k , is the CPU load of container k at time t, f k is the main frequency performance of container k at time t.
[0050] The memory capacity can be expressed as the container's memory capacity r, and the memory rate coefficient is u. The memory performance of container k can be obtained by the following formula:
[0051] M k =u k r k ;
[0052] Among them, M k is the memory performance of container k, is the memory load of container k at time t, u k is the memory rate coefficient of container k at time t, r k is the memory capacity of container k at time t.
[0053] In summary, it can be concluded that the load index information of container k at time t can be determined by the following formula:
[0054]
[0055] in, is the load index information of container k at time t, α is the CPU impact coefficient, is the CPU load of container k at time t, β is the memory impact coefficient, is the memory load of container k at time t.
[0056] Specifically, α is the CPU impact coefficient, and β is the memory impact coefficient. These two coefficients are used to measure the importance of CPU and memory loads in the overall load index, respectively. Different types of business applications may have different coefficient values. For example, for a compute-intensive business container, the value of α may be relatively large, because the use of CPU resources has a more significant impact on its overall load; while for a memory database business container, the value of β may be larger. Taking into account the load conditions of both CPU and memory (by multiplying the corresponding load values by the impact coefficients and then adding them together), we get It can fully reflect the overall load level of the container at that moment. Then, when the load indicator information is greater than or equal to the load threshold information, the first number of container copies can be used as the container capacity of the business container in the first preset time period; when the load indicator information is less than the load threshold information, the second number of container copies can be used as the container capacity of the business container in the first preset time period.
[0057] The first number is greater than the second number.
[0058] In this step, the load threshold information can be used to measure whether the service container load has reached a level that requires adjustment of the container capacity. When it is greater than or equal to the load threshold information, it means that the current load of the container is high and may not be able to cope well with business needs. In order to ensure the quality of service, it is necessary to increase the number of container copies. Therefore, the first number of container copies will be used as the container capacity of the business container in the first preset time period. The first number is relatively large. By increasing the number of copies, the load is shared and the overall service capacity is improved. For example, during an e-commerce promotion, if the business container load indicator information exceeds the set threshold, container copies can be added to allow multiple copies to jointly handle a large number of user requests.
[0059] On the contrary, when When it is less than the load threshold information, it means that the current load of the container is relatively low, and the existing number of container copies may be sufficient to cope with the business situation. In order to avoid wasting resources, the second number of container copies is used as the container capacity of the business container in the first preset time period. The second number is less than the first number. The number of container copies is appropriately reduced to save resources. For example, during business off-peak hours, the number of copies can be appropriately reduced to reduce resource consumption and improve overall resource utilization.
[0060] By adopting the above technical solution, a method for determining load indicator information based on multiple parameters and adjusting container capacity accordingly can be implemented, which can realize dynamic and reasonable allocation of container resources according to actual business conditions, ensure that business containers can run stably and efficiently under different load scenarios, and optimize resource utilization efficiency at the same time, avoiding excessive or insufficient resource allocation.
[0061] In step S103, the container capacity of the service container within the first preset time period is determined according to the load information and the load threshold information.
[0062] In this step, the load threshold information may first be determined in the following manner:
[0063] S1. Obtain historical load information of the service container within a second preset time period.
[0064] The second preset time period is any time period before the current moment.
[0065] In this step, the steps of obtaining historical load information are consistent with the steps of obtaining load information described above, and the only difference is the timing of obtaining. In other words, the historical load information is also various indicator data that can reflect the operating status of the business container, such as CPU usage, memory usage, number of requests per second, etc., but these data are records from a specific time period in the past, and may be collected through monitoring tools of the container platform (such as MetricsServer in Kubernetes), integrated third-party monitoring systems (such as Prometheus combined with corresponding Exporter), etc. The specific steps will not be repeated here.
[0066] It should be noted that the second preset time period can be defined as any time period before the current moment, and is not limited to the previous adjacent time period. The selection method can be flexible and can be determined according to business characteristics and requirements.
[0067] For example, for an application with obvious periodic business load (such as e-commerce applications, which have different loads on weekdays and weekends, daytime and nighttime), you can select a similar time period corresponding to it in the past week or month as the second preset time period. If you want to analyze the load threshold during the daytime on weekdays, select the time period during the daytime on several past weekdays. The historical load information obtained in this way can better reflect the normal load performance of the business container in the corresponding business scenario, and provide a representative data basis for the subsequent accurate determination of the load threshold information.
[0068] S2. Determine load threshold information corresponding to the service container according to the historical load information.
[0069] In this step, first, the average requested resource amount of the business container in the second preset time period and the average memory capacity of the business container in the second preset time period can be calculated; then, based on the average requested resource amount, the first load threshold information of the business container is determined, and based on the average memory capacity, the second load threshold information of the business container is determined, and based on the first load threshold information and the second load threshold information, the load threshold information corresponding to the business container is determined.
[0070] Specifically, the calculated average requested resource amount can be used as an indicator of the business container's request for various types of resources in the second preset time period, which can reflect the average resource demand of the business container in the past period of time, and reflect the normal business load level from the perspective of resource request. And the calculated average memory capacity can intuitively present the average level of memory resource usage of the container in the past corresponding time period, and characterize the normal load status of the business container from the perspective of memory.
[0071] Optionally, when the first load threshold information is determined based on the calculated average requested resource amount, in one possible implementation, the average requested resource amount can be directly used as the first load threshold information, which is a threshold limit set from the resource request level; in another possible implementation, it can also be obtained by making appropriate adjustments based on the average requested resource amount according to factors such as past experience, business performance requirements, and consideration of resource margin. For example, for an online service business container with high response speed requirements, if the CPU usage corresponding to the average requested resource amount is close to the critical value that affects the service quality, then the first load threshold information can be set slightly lower than the average level close to the critical level to reserve a certain amount of resource redundancy to cope with sudden small peaks and ensure the stability and smoothness of the service.
[0072] And in the case where the second load threshold information is determined based on the calculated average memory capacity, in one possible implementation, the average memory capacity can be directly used as the second load threshold information, so as to set a limit for measuring the load from the perspective of memory resources; in another possible implementation, the specific value can also be determined based on factors such as the impact of memory resources on business operations, the reasonable range of memory occupancy, and the prevention of service failures caused by insufficient memory. For example, for a memory-intensive application container, a suitable second load threshold information should be determined based on its average memory capacity and the reasonable upper limit of memory usage, so as to avoid performance degradation or even program crashes due to memory overload.
[0073] Then, the overall load threshold information can be determined based on the first load threshold information and the second load threshold information, so that the threshold considerations of resource request and memory can be combined to form a comprehensive standard for comprehensively measuring the load of the business container. In one possible implementation, a certain weight can be assigned to the first load threshold information and the second load threshold, respectively, where the weight can be determined according to the degree of business dependence on the CPU and memory; then the final load threshold information is obtained by adding them together, so that this threshold can more accurately determine whether the overall load of the business container has reached the level where the container capacity needs to be adjusted, providing a scientific basis for the subsequent reasonable configuration of the container capacity.
[0074] In this way, we can first obtain representative historical load information, and then determine the load threshold information based on it. Finally, based on the comparison between the current load information and this threshold information, we can accurately determine the appropriate container capacity of the business container in the first preset time period in the future, thereby achieving dynamic optimization of resource allocation and good guarantee of business services.
[0075] By adopting the above technical solution, the load information of the business container in the current container platform can be input into the trained container load prediction model, so as to obtain the target load information within the first preset time period in the future (with the current time as the starting time), so as to realize the early understanding of the development trend of the business container load, and no longer be limited to the control of the current situation. The container capacity of the business container in the future time period can be determined based on the predicted target load information and the determined load threshold information, which is helpful to reasonably allocate computing resources in advance, and can adjust resources in time when it is necessary to respond quickly to load changes to ensure the normal operation of the business, so as to improve the quality of business services.
[0076] Considering that in the scenario of container load information, the load information contains many different types of indicators, such as CPU usage, memory usage, network bandwidth usage, etc. The dimensions (units and value ranges) of these indicators are usually different. For example, CPU usage may be a value between 0-100%, while memory usage may be measured in bytes based on memory size (such as 0-8GB), and network bandwidth usage may be other units such as Mbps. Directly inputting data of different dimensions into the model may cause the model to attach unreasonable importance to different indicators. Because indicators with large numerical ranges may dominate the model training and prediction process, and mask the influence of indicators with small numerical ranges.
[0077] Therefore, in some embodiments, the load information can be first normalized to obtain the normalized load information, and then the normalized load information can be input into a trained container load prediction model to obtain the target load information of the business container within the first preset time period output by the container load prediction model.
[0078] In some embodiments, the container load prediction model may include a memory unit gate input layer, a hidden layer, and an output layer. Therefore, the normalized load information can be input into the trained container load prediction model in the following manner to obtain the target load information of the business container within the first preset time period output by the container load prediction model.
[0079] Optionally, the load information may first be feature encoded through the input layer to obtain a feature vector corresponding to the load information, wherein the feature vector is a feature vector of a preset dimension, and the number of preset dimensions corresponds to the number of units included in the input layer; then the time series relationship in the feature vector may be extracted through the hidden layer to obtain an extracted target feature vector, wherein the time series relationship is used to characterize the association relationship between different times and the corresponding load information; finally, the target feature vector may be linearly transformed through the output layer to obtain the target load information of the business container within the first preset time period.
[0080] For example, the input layer is the entry for the model to receive external data (i.e., normalized load information), such as Figure 2 As shown, a preset number of memory units may be included, for example, 100 memory units may be included, and the preset number of memory units may process the input load information and convert it into a feature vector.
[0081] Specifically, after the normalized load information enters the input layer, the input layer can use the preset number of memory units to perform feature encoding on the load information. The load information may contain data of multiple dimensions, for example, it may include indicator values such as CPU usage and memory usage at different times. The input layer can integrate and encode the data of multiple dimensions into a feature vector of preset dimensions. The number of preset dimensions corresponds to the number of units contained in the input layer; when the input layer contains 100 memory units, the feature vector is also a 100-dimensional feature vector, which can integrate scattered load information into data with specific structure and dimensions, making it easier to extract valuable information therefrom later.
[0082] Then, the hidden layer may also include a preset number of memory units, for example, 100 memory units, and the hidden layer may be used to mine deep information in the input feature vector, for example, the time series relationship therein.
[0083] Specifically, since the container load information changes over time, there is often a correlation between the load indicator values at different time points. For example, the CPU usage of the business container may show a gradual upward trend during the preset time period in the morning of each day. The hidden layer analyzes the feature vectors transmitted from the input layer, extracts the time series relationship that represents the correlation between different times and the corresponding load information, and then obtains the extracted target feature vector. Compared with the feature vector of the input layer, this target feature vector focuses more on reflecting the law and internal connection of the load information changing over time, which can lay the foundation for the output layer to generate accurate prediction results.
[0084] Then, the output layer may include only a single unit, which may be used to process the target feature vector transmitted from the hidden layer to generate a prediction result, that is, target load information of the service container within the first preset time period.
[0085] Specifically, the output layer can perform a linear transformation operation on the target feature vector, that is, it can calculate the target feature vector through a specific weight parameter and convert it into a prediction value that meets actual needs, wherein the weight parameter can be continuously adjusted and optimized during the model training process; for example, predict the specific CPU usage rate, memory usage rate and other target load information of the business container in a certain time period in the future.
[0086] In some embodiments, sample load information corresponding to the business container in the container platform and sample results corresponding to the sample load information may be first obtained; then the sample load information is used as the input of a preset long short-term memory model to obtain an output result of the preset long short-term memory model; and when the root mean square error between the sample result and the output result is greater than a preset error threshold, the model parameters of the preset long short-term memory model are adjusted until the root mean square error between the sample result and the output result is less than or equal to the preset error threshold, and when the root mean square error between the sample result and the output result is less than or equal to the preset error threshold, the preset long short-term memory model is used as the trained container load prediction model.
[0087] By adopting the above technical solution, the model can make full use of the normalized load information through the process of collaboration from the input layer, hidden layer to the output layer, and mine the characteristics and time series relationships therein, and finally output a more accurate prediction result of the future load of the business container, thereby providing strong data support for the container platform to carry out resource allocation in advance, optimize system performance and other operations.
[0088] Figure 3 is a block diagram of a device for determining service container capacity provided by an embodiment of the present application, such as Figure 3 As shown, the device 200 includes:
[0089] The first acquisition module 201 is used to obtain load information corresponding to the business container in the current container platform;
[0090] The prediction module 202 is used to input the load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model; the first preset time period is a time period starting from the current time;
[0091] The first determining module 203 is configured to determine a container capacity of the service container within the first preset time period according to the load information and the load threshold information.
[0092] Optionally, the load information includes the requested resource amount and memory capacity of the business container at the current moment; the first determination module includes:
[0093] A first determination submodule, configured to determine first load indicator information of the service container according to the requested resource amount;
[0094] A second determining submodule, used to determine second load indicator information of the business container according to the memory capacity;
[0095] The third determination submodule is used to determine the container capacity of the business container within the first preset time period according to the load indicator information and the load threshold information, when the load indicator information corresponding to the business container is determined according to the first load indicator information and the second load indicator information.
[0096] Optionally, the third determination submodule is used to, when the load indicator information is greater than or equal to the load threshold information, use a first number of container replicas as the container capacity of the business container within the first preset time period; when the load indicator information is less than the load threshold information, use a second number of container replicas as the container capacity of the business container within the first preset time period; the first number is greater than the second number.
[0097] Optionally, the device further comprises:
[0098] A second acquisition module is used to acquire historical load information of the business container within a second preset time period; the second preset time period is any time period before the current moment;
[0099] The second determining module is used to determine the load threshold information corresponding to the business container according to the historical load information.
[0100] Optionally, the prediction module includes:
[0101] A normalization submodule, used for normalizing the load information to obtain the normalized load information;
[0102] The prediction submodule is used to input the normalized load information into a trained container load prediction model to obtain the target load information of the business container within a first preset time period output by the container load prediction model.
[0103] Optionally, the container load prediction model includes a memory unit gate input layer, a hidden layer, and an output layer; the prediction submodule is used to perform feature encoding on the load information through the input layer to obtain a feature vector corresponding to the load information, where the feature vector is a feature vector of a preset dimension, and the number of preset dimensions corresponds to the number of units included in the input layer; extract a time series relationship in the feature vector through the hidden layer to obtain an extracted target feature vector, where the time series relationship is used to characterize the association relationship between different times and the corresponding load information; and perform a linear transformation on the target feature vector through the output layer to obtain the target load information of the business container within a first preset time period.
[0104] Optionally, the device further comprises:
[0105] A third acquisition module is used to acquire sample load information corresponding to the business container in the container platform, and a sample result corresponding to the sample load information;
[0106] An input module, used to use the sample load information as an input of a preset long short-term memory model to obtain an output result of the preset long short-term memory model;
[0107] A training module is used to adjust the model parameters of the preset long short-term memory model when the root mean square error between the sample result and the output result is greater than a preset error threshold, until the root mean square error between the sample result and the output result is less than or equal to the preset error threshold, and use the preset long short-term memory model as the trained container load prediction model when the root mean square error between the sample result and the output result is less than or equal to the preset error threshold.
[0108] By adopting the above-mentioned device, by inputting the load information of the business container in the current container platform into the trained container load prediction model, the target load information within the first preset time period in the future (with the current time as the starting time) can be obtained, and the development trend of the business container load can be understood in advance. It is no longer limited to the control of the current situation. The container capacity of the business container in the future time period can be determined based on the predicted target load information and the determined load threshold information, which is helpful to reasonably allocate computing resources in advance. When it is necessary to respond quickly to load changes to ensure the normal operation of the business, resources can be adjusted in time to improve the quality of business services.
[0109] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0110] The present invention also provides an electronic device, see Figure 4, including: a processor 301, a memory 302, and a computer program 3021 stored in the memory and executable on the processor, wherein when the processor executes the program, the device for determining the service container capacity of the aforementioned embodiment is implemented.
[0111] The present invention also provides a readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the device for determining the service container capacity of the aforementioned embodiment.
[0112] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0113] It should be noted that the various information and data obtained in the embodiments of the present invention are all obtained with the authorization of the information / data holder.
[0114] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming voice. It should be understood that various programming voices can be utilized to realize the content of the present invention described herein, and the description of the above specific voices is for the purpose of disclosing the best mode of the present invention.
[0115] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0116] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0117] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0118] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0119] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0120] The user information (including but not limited to the user's device information, user personal information, etc.) and related data involved in the present invention are all information authorized by the user or by all parties.
[0121] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0122] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0123] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for determining service container capacity, characterized in that: The method comprises: Get the load information corresponding to the business container in the current container platform; Input the load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model; the first preset time period is a time period starting from the current time; The container capacity of the service container within the first preset time period is determined according to the load information and the load threshold information.
2. The method according to claim 1, characterized in that The load information includes the requested resource amount and memory capacity of the business container at the current moment; The determining, according to the load information and the load threshold information, the container capacity of the service container within the first preset time period includes: Determining first load indicator information of the service container according to the requested resource amount; Determining second load indicator information of the business container according to the memory capacity; When the load indicator information corresponding to the business container is determined according to the first load indicator information and the second load indicator information, the container capacity of the business container within the first preset time period is determined according to the load indicator information and the load threshold information.
3. The method according to claim 2, characterized in that The determining, according to the load indicator information and the load threshold information, the container capacity of the service container within the first preset time period includes: When the load indicator information is greater than or equal to the load threshold information, taking a first number of container replicas as the container capacity of the business container within the first preset time period; When the load indicator information is less than the load threshold information, a second number of container replicas is used as the container capacity of the business container within the first preset time period; the first number is greater than the second number.
4. The method according to claim 1, characterized in that The method further comprises: Acquire historical load information of the business container within a second preset time period; the second preset time period is any time period before the current moment; Determine load threshold information corresponding to the service container according to the historical load information.
5. The method according to any one of claims 1 to 4, characterized in that The step of inputting the load information into a trained container load prediction model to obtain the target load information of the business container within the first preset time period output by the container load prediction model includes: Normalizing the load information to obtain normalized load information; The normalized load information is input into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model.
6. The method according to claim 5, characterized in that The container load prediction model includes a memory unit gate input layer, a hidden layer, and an output layer; The step of inputting the normalized load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model includes: The load information is feature encoded by the input layer to obtain a feature vector corresponding to the load information, wherein the feature vector is a feature vector of a preset dimension, and the number of the preset dimensions corresponds to the number of units included in the input layer; Extracting the time series relationship in the feature vector through the hidden layer to obtain the extracted target feature vector, wherein the time series relationship is used to characterize the correlation relationship between different times and corresponding load information; The target load information of the service container within a first preset time period is obtained by performing a linear transformation on the target feature vector through the output layer.
7. The method according to claim 1, characterized in that The method further comprises: Obtaining sample load information corresponding to a business container in a container platform, and a sample result corresponding to the sample load information; Using the sample load information as an input of a preset long short-term memory model, and obtaining an output result of the preset long short-term memory model; When the root mean square error between the sample result and the output result is greater than a preset error threshold, the model parameters of the preset long short-term memory model are adjusted until the root mean square error between the sample result and the output result is less than or equal to the preset error threshold, and when the root mean square error between the sample result and the output result is less than or equal to the preset error threshold, the preset long short-term memory model is used as the trained container load prediction model.
8. A device for determining service container capacity, characterized in that: The device comprises: The first acquisition module is used to obtain the load information corresponding to the business container in the current container platform; A prediction module, used to input the load information into a trained container load prediction model to obtain target load information of the business container within a first preset time period output by the container load prediction model; the first preset time period is a time period starting from the current time; The first determining module is used to determine the container capacity of the service container within the first preset time period according to the load information and the load threshold information.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.
10. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described in claims 1-7.