Resource allocation method, device and equipment for container
By using prediction tasks and target models to process container-related data in cloud product systems, the problem of low resource allocation flexibility in the prior art is solved, and more flexible container resource allocation is achieved.
Patent Information
- Application Number
- CN202311502007.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-10
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, when allocating container resources, cloud product systems have low flexibility in resource allocation due to fixed preset rules.
By obtaining prediction tasks, obtaining container-related data, and processing these data through the target model, we can determine the reserved resources of the target user or the cache time of the target container.
Improve the flexibility of container resource allocation, so that resource allocation can respond to user needs more dynamically.
Smart Images

Figure CN119987984A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the computer field, and in particular to a container resource allocation method, device and equipment. Background Art
[0002] In a cloud product system, when a cloud service provider provides cloud products (e.g., elastic container instances) to users, it can predict the container resources required by users to use the cloud products, so as to flexibly call container resources and provide cloud product services to users.
[0003] In the related art, the container resources required by the target user can be determined based on preset rules, and the container resources can be allocated to the target user, or the cache duration of the target container can be determined. However, in the above methods, the preset rules are usually fixed, resulting in low flexibility in allocating container resources. Summary of the invention
[0004] Multiple aspects of the present application provide a method, apparatus, and device for allocating container resources to improve the flexibility of allocating container resources.
[0005] In a first aspect, an embodiment of the present application provides a resource allocation method for a container, comprising:
[0006] Obtaining a prediction task, where the prediction task is used to determine the amount of reserved resources for a target user or to determine a cache duration for a target container;
[0007] According to the prediction task, container-related data is obtained in a preset storage space, where the container-related data is obtained by processing the operation log and resource usage information of the container in the server;
[0008] Determine a target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task, where the prediction result is the reserved resource amount of the target user or the cache duration of the target container.
[0009] In a possible implementation, obtaining container-related data in a preset storage space according to the prediction task includes:
[0010] If the prediction task is used to determine the reserved resource amount of the target user, acquiring the container-related data in the preset storage space according to the identifier of the target user;
[0011] If the prediction task is used to determine the cache duration of the target container, an identifier of a first user corresponding to the target container is determined, and the container-related data is acquired in the preset storage space according to the identifier of the target container and the identifier of the first user.
[0012] In a possible implementation, acquiring the container-related data in the preset storage space according to the identifier of the target user includes:
[0013] According to the identifier of the target user, user data of the target user is acquired in the preset storage space, the user data including: at least one operation moment of the target user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0014] Determine at least one historical container used by the target user in a historical period, and obtain container data of each historical container, wherein the container data includes: resource usage information, event information, and container status of the historical container at each time in the historical period, wherein the event information includes a generation time and an event type;
[0015] Acquire the system data in the preset storage space, where the system data includes the total number of containers deployed by the server in the historical period and total resource usage information;
[0016] The container-related data includes user data of the target user, container data of each historical container, and the system data.
[0017] In a possible implementation, acquiring the container-related data in the preset storage space according to the identifier of the target container and the identifier of the first user includes:
[0018] According to the identifier of the first user, user data of the first user is acquired in the preset storage space, the user data including: at least one operation moment of the first user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0019] According to the identifier of the target container, obtaining container data of the target container in the preset storage space, the container data including: resource usage information, event information and container status of the target container at each time in the historical period, the event information including operation time and operation type;
[0020] The container-related data includes user data of the first user and container data of the target container.
[0021] In a possible implementation, the prediction task is used to determine the reserved resource amount of the target user; and the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, including:
[0022] Determining the last update time of the target model;
[0023] If the time difference between the last update time and the current time is less than or equal to the first preset time length, the container-related data is processed by the target model to obtain the prediction result;
[0024] If the time difference between the last update time and the current time is greater than the first preset time length, first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data to obtain an updated target model, and the container-related data is processed by the updated target model to obtain the prediction result;
[0025] The first historical data includes user data of multiple users, container data of multiple containers, and system data corresponding to the server, and the prediction result is the reserved resource amount of the target user.
[0026] In a possible implementation, the prediction task is used to determine the cache duration of the target container; and processing the container-related data by the target model to obtain a prediction result corresponding to the prediction task includes:
[0027] Determining the last update time of the target model;
[0028] If the time difference between the last update time and the current time is less than or equal to a second preset time length, and the offline performance of the target model is greater than or equal to a preset performance, the container-related data is processed by the target model to obtain the prediction result;
[0029] If the time difference between the last update moment and the current moment is greater than the second preset duration, or the offline performance is less than the preset performance, the target model is updated until the time difference between the last update moment and the current moment is less than the second preset duration, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed by the updated target model to obtain the prediction result;
[0030] The prediction result is the cache duration of the target container.
[0031] In a possible implementation manner, after the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, the method further includes:
[0032] Determine a result type of the prediction result, wherein the result type is prediction success or prediction failure;
[0033] The sleep duration and task concurrency of executing the prediction task are determined according to the result type.
[0034] In a possible implementation, determining the sleep duration and task concurrency of executing the prediction task according to the result type includes:
[0035] If the result type is the prediction success, determining the sleep duration to be the first duration, and determining the task concurrency to be the first concurrency;
[0036] If the result type is the prediction failure, determining the sleep duration to be the second duration, and determining the task concurrency to be the second concurrency;
[0037] Among them, the first duration is shorter than the second duration, and the first concurrency is larger than the second concurrency.
[0038] In a possible implementation, the method further includes:
[0039] Obtaining the operation log and resource usage information of the container in the server;
[0040] According to the operation log, multiple containers existing in the server are determined, and a user corresponding to each container is determined;
[0041] Determine, according to the operation log and the resource usage information, container data of each container, user data of each user, and system data, wherein the system data includes a total number of containers deployed by the server during the historical period and total resource usage information;
[0042] The container data corresponding to each container, the user data of each user and the system data are stored in the preset storage space.
[0043] In a possible implementation manner, after the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, the method further includes:
[0044] If the prediction result is the reserved resource amount of the target user, obtaining a preset resource amount threshold, and determining whether the reserved resource amount is less than or equal to the preset resource amount threshold, and if not, sending a prompt message to a preset device, wherein the prompt message is used to indicate that there is an error in the prediction result;
[0045] If the preset result is the cache duration of the target container, a cache duration threshold is obtained, and it is determined whether the cache duration is less than or equal to the cache duration threshold; if not, the prompt information is sent to the preset device.
[0046] In a second aspect, an embodiment of the present application provides a resource allocation device for a container, the resource allocation device for a container comprising: a first acquisition module, a second acquisition module and a processing module, wherein:
[0047] The first acquisition module is used to acquire a prediction task, where the prediction task is used to determine the reserved resource amount of the target user or the cache duration of the target container;
[0048] The second acquisition module is used to acquire container-related data in a preset storage space according to the prediction task, where the container-related data is obtained by processing the operation log and resource usage information of the container in the server;
[0049] The processing module is used to determine the target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task, where the prediction result is the reserved resource amount of the target user or the cache duration of the target container.
[0050] In a possible implementation manner, the second acquisition module is specifically configured to:
[0051] If the prediction task is used to determine the reserved resource amount of the target user, acquiring the container-related data in the preset storage space according to the identifier of the target user;
[0052] If the prediction task is used to determine the cache duration of the target container, an identifier of a first user corresponding to the target container is determined, and the container-related data is acquired in the preset storage space according to the identifier of the target container and the identifier of the first user.
[0053] In a possible implementation manner, the second acquisition module is specifically configured to:
[0054] According to the identifier of the target user, user data of the target user is acquired in the preset storage space, the user data including: at least one operation moment of the target user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0055] Determine at least one historical container used by the target user in a historical period, and obtain container data of each historical container, wherein the container data includes: resource usage information, event information, and container status of the historical container at each time in the historical period, wherein the event information includes a generation time and an event type;
[0056] Acquire the system data in the preset storage space, where the system data includes the total number of containers deployed by the server in the historical period and total resource usage information;
[0057] The container-related data includes user data of the target user, container data of each historical container, and the system data.
[0058] In a possible implementation manner, the second acquisition module is specifically configured to:
[0059] According to the identifier of the first user, user data of the first user is acquired in the preset storage space, the user data including: at least one operation moment of the first user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0060] According to the identifier of the target container, obtaining container data of the target container in the preset storage space, the container data including: resource usage information, event information and container status of the target container at each time in the historical period, the event information including operation time and operation type;
[0061] The container-related data includes user data of the first user and container data of the target container.
[0062] In a possible implementation manner, the prediction task is used to determine the reserved resource amount of the target user; and the processing module is specifically used to:
[0063] Determining the last update time of the target model;
[0064] If the time difference between the last update time and the current time is less than or equal to a first preset time length, the container-related data is processed by the target model to obtain the prediction result;
[0065] If the time difference between the last update time and the current time is greater than the first preset time length, first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data to obtain an updated target model, and the container-related data is processed by the updated target model to obtain the prediction result;
[0066] The first historical data includes user data of multiple users, container data of multiple containers, and system data corresponding to the server, and the prediction result is the reserved resource amount of the target user.
[0067] In a possible implementation, the prediction task is used to determine the cache duration of the target container; and the processing module is specifically used to:
[0068] Determining the last update time of the target model;
[0069] If the time difference between the last update time and the current time is less than or equal to a second preset time length, and the offline performance of the target model is greater than or equal to a preset performance, the container-related data is processed by the target model to obtain the prediction result;
[0070] If the time difference between the last update moment and the current moment is greater than the second preset duration, or the offline performance is less than the preset performance, the target model is updated until the time difference between the last update moment and the current moment is less than the second preset duration, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed by the updated target model to obtain the prediction result;
[0071] The prediction result is the cache duration of the target container.
[0072] In a possible implementation, after the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, the resource allocation device for the container further includes: a first determination module, the first determination module being used to:
[0073] Determine a result type of the prediction result, wherein the result type is prediction success or prediction failure;
[0074] The sleep duration and task concurrency of executing the prediction task are determined according to the result type.
[0075] In a possible implementation manner, the first determining module is specifically configured to:
[0076] If the result type is the prediction success, determining the sleep duration to be the first duration, and determining the task concurrency to be the first concurrency;
[0077] If the result type is the prediction failure, determining the sleep duration to be the second duration, and determining the task concurrency to be the second concurrency;
[0078] Among them, the first duration is shorter than the second duration, and the first concurrency is larger than the second concurrency.
[0079] In a possible implementation manner, the container resource allocation device further includes: a third acquisition module, a second determination module and a storage module, wherein:
[0080] The third acquisition module is used to obtain the operation log and resource usage information of the container in the server;
[0081] The second determination module is used to determine, according to the operation log, multiple containers existing in the server, and determine the user corresponding to each container;
[0082] The second determination module is further used to determine, according to the operation log and the resource usage information, container data of each container, user data of each user, and system data, wherein the system data includes the total number of containers deployed by the server during the historical period and total resource usage information;
[0083] The storage module is used to store the container data corresponding to each container, the user data of each user and the system data in the preset storage space.
[0084] In a possible implementation, after the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, the resource allocation device for the container further includes a judgment module, and the judgment module is used to:
[0085] If the prediction result is the reserved resource amount of the target user, obtaining a preset resource amount threshold, and determining whether the reserved resource amount is less than or equal to the preset resource amount threshold, and if not, sending a prompt message to a preset device, wherein the prompt message is used to indicate that there is an error in the prediction result;
[0086] If the preset result is the cache duration of the target container, a cache duration threshold is obtained, and it is determined whether the cache duration is less than or equal to the cache duration threshold; if not, the prompt information is sent to the preset device.
[0087] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor;
[0088] The memory stores computer-executable instructions;
[0089] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method described in any one of the first aspects.
[0090] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in any one of the first aspects.
[0091] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the method shown in any one of the first aspects when executed by a processor.
[0092] The embodiment of the present application provides a method, device and equipment for allocating resources of a container, wherein the electronic device can obtain a prediction task, and according to the prediction task, obtain container-related data in a preset storage space, and then determine the target model corresponding to the prediction task, and process the container-related data through the target model to obtain the prediction result corresponding to the prediction task. Since the electronic device can determine the target model according to the prediction task, and predict the reserved resource amount of the target user or the cache duration of the target container through the target model, the flexibility of allocating container resources is improved compared to determining the reserved resource amount or cache duration based on fixed preset rules. BRIEF DESCRIPTION OF THE DRAWINGS
[0093] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0094] Figure 1 A schematic diagram of a scenario provided for an exemplary embodiment of the present application;
[0095] Figure 2 A schematic diagram of a flow chart of a method for allocating resources of a container provided by an exemplary embodiment of the present application;
[0096] Figure 3 A flowchart of another method for allocating resources of a container provided by an exemplary embodiment of the present application;
[0097] Figure 4 A schematic flow chart of another method for allocating resources of a container provided by an exemplary embodiment of the present application;
[0098] Figure 5 A schematic diagram of the system architecture of a cloud product system provided for an exemplary embodiment of the present application;
[0099] Figure 6 A schematic diagram of the structure of a resource allocation device for a container provided in an embodiment of the present application;
[0100] Figure 7 A schematic diagram of the structure of another resource allocation device for a container provided in an embodiment of the present application;
[0101] Figure 8 A schematic structural diagram of an electronic device is provided according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0102] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0103] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0104] Figure 1 A schematic diagram of a scenario provided for an exemplary embodiment of the present application. Figure 1 If the prediction task is to determine the reserved resource amount of user 1, the container-related data corresponding to the prediction task can be obtained in the preset storage space, and the target model can be determined as model 1 among multiple preset models according to the prediction task, and then the container-related data can be processed by model 1 to predict the reserved resource amount corresponding to user 1. For example, the predicted resource amount can be 50 dual-core processors and 500G memory.
[0105] If the prediction task is to determine the cache duration of container 1, the container-related data corresponding to the prediction task can be obtained in the preset storage space, and the target model can be determined as model 2 from multiple preset models according to the prediction task, and then the container-related data can be processed by model 2 to predict the cache duration of container 1. Assuming the cache duration is 72 hours, container 1 can be retained for 72 hours before being cleared.
[0106] In the related art, the container resources required by the target user can be determined based on preset rules, and the container resources can be allocated to the target user, or the cache duration of the target container can be determined. However, in the above methods, the preset rules are usually fixed, resulting in low flexibility in allocating container resources.
[0107] In an embodiment of the present application, the electronic device can obtain container-related data in a preset storage space according to the prediction task, and determine the target model corresponding to the prediction task, and then process the container-related data through the target model to obtain the prediction result corresponding to the prediction task. The prediction result can be the reserved resource amount of the target user or the cache duration of the target container. Since the electronic device can determine the target model according to the prediction task and predict the reserved resource amount of the target user through the target model, the flexibility of allocating container resources is improved compared to allocating operating resources to the target user based on fixed preset rules.
[0108] The technical solutions shown in the present application are described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.
[0109] Figure 2 A flowchart of a method for allocating resources for a container provided by an exemplary embodiment of the present application. Figure 2 , the method may include:
[0110] S201: Obtain prediction tasks.
[0111] The execution subject of the embodiment of the present application may be an electronic device, or a resource allocation device of a container set in the electronic device. The resource allocation device of the container may be implemented by software, or by a combination of software and hardware. The resource allocation device of the container may be a processor in the electronic device. For ease of understanding, the following description is made by taking the execution subject as an electronic device as an example.
[0112] The prediction task can be used to determine the amount of reserved resources for the target user or the cache duration of the target container.
[0113] The reserved resources refer to the resources required to run the container. For example, the reserved resources can be 50 2-core processors and 500G memory.
[0114] The cache duration refers to the length of time that the cloud product system retains the target container after the user logs out of the target container.
[0115] The electronic device may obtain a prediction task. For example, prediction task 1 may be determining the amount of reserved resources for user 1 ; prediction task 2 may be determining the cache duration of container 1 .
[0116] S202: According to the prediction task, obtain container-related data in a preset storage space.
[0117] The preset storage space may be a storage space in the electronic device or a storage system of an external device. The preset storage space may store container-related data.
[0118] The container-related data may be obtained by processing the operation log and resource usage information of the container in the server. The container-related data may include user data, container data, and system data.
[0119] In an optional embodiment, the container-related data may be obtained in a preset storage space according to the prediction task in the following manner: if the prediction task is used to determine the reserved resource amount of the target user, the container-related data is obtained in the preset storage space according to the identifier of the target user; if the prediction task is used to determine the cache duration of the target container, the identifier of the first user corresponding to the target container is determined, and the container-related data is obtained in the preset storage space according to the identifier of the target container and the identifier of the first user.
[0120] For example, if prediction task 1 is to determine the amount of reserved resources for user 1, container-related data 1 corresponding to user 1 can be obtained in a preset storage space according to the identifier of user 1; if prediction task 2 is to determine the cache duration of container 1, container-related data 2 can be obtained in a preset storage space according to the identifier of container 1 and the identifier of user 2 who uses container 1. Container-related data 2 may include container data corresponding to container 1 and user data corresponding to user 2.
[0121] It should be noted that before obtaining container-related data in the preset storage space, the electronic device can obtain the operation log and resource usage information of the container in the server; determine the multiple containers existing in the server according to the operation log, and determine the user corresponding to each container; determine the container data of each container, the user data of each user, and the system data according to the operation log and the resource usage information; and store the container data corresponding to each container, the user data of each user, and the system data in the preset storage space.
[0122] The system data may include the total number of containers deployed by the server in a historical period and total resource usage information. Optionally, there may be at least one server.
[0123] For example, if there are 5 servers that deploy containers in the cloud product system, and the 5 servers include 50 containers, the electronic device can obtain the operation logs and resource usage information of the 5 servers. The electronic device can determine that there are 50 containers in the 5 servers based on the operation logs, and determine the users corresponding to each container. If there are 10 users corresponding to the 50 containers, the container data of the 50 containers, the user data of the 10 users, and the system data can be determined respectively based on the operation logs and resource usage information. The electronic device can store the container data of the 50 containers, the user data of the 10 users, and the system data in the preset storage space.
[0124] S203: Determine a target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task.
[0125] There can be corresponding target models for different types of prediction tasks. For example, if the prediction task is used to determine the amount of reserved resources for the target user, the target model corresponding to the prediction task can be a Bidirectional Encoder Representations from Transformer (Bert) model; if the prediction task is used to determine the cache duration of the target container, the target model corresponding to the prediction task can be an eXtreme Gradient Boosting (XGBoost) model.
[0126] The prediction result can be the amount of reserved resources for the target user or the cache duration of the target container.
[0127] For example, if prediction task 1 is to determine the reserved resource amount of user 1, the container-related data is container-related data 1 corresponding to user 1, and the corresponding target model is the Bert model, the container-related data 1 can be processed by the Bert model to obtain prediction result 1 corresponding to prediction task 1. Prediction result 1 can be the reserved resource amount for user 1, including 50 2-core processors and 500G memory.
[0128] For example, if prediction task 2 is to determine the cache duration of container 1, container-related data 2 includes container data corresponding to container 1 and user data corresponding to user 2, and the corresponding target model is an XGBoost model, then the container-related data 2 can be processed by the XGBoost model to obtain prediction result 2 corresponding to prediction task 2, and prediction result 2 can be that the cache duration of container 1 is 72 hours.
[0129] In an embodiment of the present application, the electronic device can obtain a prediction task, and according to the prediction task, obtain container-related data in a preset storage space, and then determine the target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task. Since the electronic device can determine the target model according to the prediction task, and predict the reserved resource amount of the target user or the cache duration of the target container through the target model, the flexibility of allocating container resources is improved compared to determining the reserved resource amount or cache duration based on fixed preset rules.
[0130] Below, in Figure 2 Based on the embodiment shown, combined Figure 3 The process of determining the amount of reserved resources for target users by the prediction task is described in detail; combined with Figure 4 The process used by the prediction task to determine the cache duration of the target container is described in detail.
[0131] Figure 3 A flowchart of another method for allocating resources of a container provided by an exemplary embodiment of the present application. Figure 3 , the method may include:
[0132] S301: Obtain prediction tasks.
[0133] For example, the electronic device may obtain prediction task 1, and prediction task 1 may be used to determine the reserved resource amount of user 1.
[0134] S302: Acquire user data of the target user in a preset storage space according to the identifier of the target user.
[0135] The user data may include: at least one operation moment of the target user on the container within a historical period, and a first operation event corresponding to each operation moment, the first operation event includes an operation type and container information of the operated container, and the operation type includes a create container type and a cancel container type.
[0136] The historical period can be set manually, for example, the historical period can be 6 months before the current moment.
[0137] For example, if the target user is user 1 and the identifier of user 1 is 001, user data 1 of user 1 can be obtained in the preset storage space according to the identifier 001. If the historical period is 2023.3.1-2023.9.30, user data 1 can be as shown in Table 1:
[0138] Table 1
[0139]
[0140] Optionally, the user data may also include data such as the user's region and industry.
[0141] S303: Determine at least one historical container used by the target user in a historical period, and obtain container data of each historical container.
[0142] The container data may include: resource usage information, event information and container status of the historical container at each time in the historical period, and the event information may include the generation time and event type.
[0143] The resource usage information may include the CPU usage rate and the memory usage rate.
[0144] The container status can include open, closed, abnormal, etc.
[0145] The event information may include the time when the event occurs in the target container and the event type. The event type may include closing or opening a container, insufficient memory, unavailable service, and other types.
[0146] For example, if the historical period is from March 1, 2023 to September 30, 2023, and user 1 has used 5 historical containers in the historical period, then the container data of the 5 historical containers can be obtained, as shown in Table 2:
[0147] Table 2
[0148]
[0149]
[0150] S304: Obtain system data in a preset storage space.
[0151] System data refers to the total number of containers deployed on servers in the cloud product system during a historical period and total resource usage information.
[0152] For example, if there are 5 servers in the cloud product system, and if the historical period is 2023.3.1-2023.9.30, the system data may include the total container data and total resource usage of the 5 servers deployed during the historical period, as shown in Table 3:
[0153] Table 3
[0154] Historical Moments Total container data Total CPU utilization Total memory utilization 2023.3.1 9:00 50 80% 70% 2023.3.5 18:52 52 82% 73% 2023.3.7 11:20 49 78% 69% …… …… …… …… 2023.9.30 18:20 65 85% 79%
[0155] S305: Determine that the container-related data includes user data of the target user, container data of each historical container, and system data.
[0156] For example, the electronic device may determine that the container-related data 1 includes user data 1 of user 1 as shown in Table 1, container data of five historical containers as shown in Table 2, and system data as shown in Table 3.
[0157] S306: Determine the target model corresponding to the prediction task.
[0158] Since the prediction task is used to determine the amount of reserved resources for the target user, it can be determined that the corresponding target model is the Bert model.
[0159] S307: Determine the last update time of the target model.
[0160] For example, if the target model is a Bert model, the electronic device can determine the last update time corresponding to the target model, assuming that the last update time is 2023.10.1 0:00.
[0161] S308: If the time difference between the last update time and the current time is less than or equal to the first preset time length, the container-related data is processed through the target model to obtain a prediction result.
[0162] The first preset duration may be manually set. For example, the first preset duration may be 24 hours.
[0163] The prediction result can be the amount of resources reserved for the target user.
[0164] For example, if the last update time of the Bert model is 2023.10.1 0:00, and the current time is 2023.10.1 0:30, if the first preset duration is 24h, since the time difference between the last update time and the current time is less than 24h, the container-related data 1 can be processed by the Bert model to obtain prediction result 1. Assume that the prediction result 1 is that the reserved resources of user 1 on 23.10.1 include 5 dual-core processors and 10G memory.
[0165] S309. If the time difference between the last update time and the current time is greater than a first preset duration, the first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data to obtain an updated target model, and the container-related data is processed by the updated target model to obtain a prediction result.
[0166] The first historical data may include user data of multiple users, container data of multiple containers, and system data corresponding to the server.
[0167] For example, if the current time is 2023.10.1 15:30, if the last update time of the Bert model is 2023.9.300:00, if the first preset time is 24h, since the time difference between the last update time and the current time is greater than 24h, the first historical data between 2023.9.30 0:00 and 2023.10.1 0:30 can be determined, and the Bert model can be updated according to the first historical data to obtain an updated Bert model. The container-related data 1 can be processed by the updated Bert model to obtain prediction result 1, assuming that the prediction result 1 is that the reserved resources of user 1 on 23.10.1 include 5 2-core processors and 10G memory.
[0168] Optionally, a fixed time period every day may be set to batch predict the reserved resource amounts of multiple target users through the target model. For example, the fixed time may be 0:30 every day.
[0169] S310: Obtain a preset resource amount threshold, and determine whether the reserved resource amount is less than or equal to the preset resource amount threshold.
[0170] Optionally, for any type of reserved resource, the reserved resource may have a corresponding preset resource quantity threshold.
[0171] For any type of reserved resources, the electronic device can determine whether the reserved resource amount is less than or equal to a preset resource amount threshold. If yes, resources can be reserved for the target user according to the reserved resource amount; if no, S310 can be executed.
[0172] For example, if prediction result 1 is: the reserved resources of user 1 at 23.10.1 include 5 2-core processors and 10G memory, if the preset resource threshold corresponding to the reserved processor is 20-core processors (10 2-core processors), it can be determined that the number of reserved processors is less than the corresponding preset resource threshold, and 5 2-core processors can be reserved for user 1 based on the reserved number of processors; if the preset resource threshold corresponding to the reserved memory is 8G, it can be determined that the reserved memory is greater than the corresponding preset resource threshold, and S310 can be executed.
[0173] S311: If not, send a prompt message to the preset device.
[0174] The preset device can be a staff member's computer.
[0175] Prompt information can be used to indicate that there are errors in the prediction results, making it easier for staff to intervene to check or troubleshoot the problem.
[0176] For example, if the reserved memory amount in prediction result 1 is greater than the corresponding preset resource amount threshold, prompt information 1 can be sent to the preset device, and prompt information 1 can be: the reserved memory amount for user 1 exceeds the preset resource amount threshold.
[0177] S312: Determine the result type of the prediction result.
[0178] The result type is prediction success or prediction failure.
[0179] Optionally, the electronic device may also determine the result type of the prediction result according to whether the prediction result is obtained through the target model. If the prediction result is obtained through the target model, the result type of the prediction result may be determined to be a successful prediction; if the prediction result is not obtained through the target model, the result type of the prediction result may be determined to be a failed prediction.
[0180] The reason for prediction failure may be that there are too many current prediction tasks and the target model cannot make predictions in time.
[0181] S313: Determine the sleep duration and task concurrency of executing the prediction task according to the result type.
[0182] In an optional embodiment, the sleep duration and task concurrency of executing the prediction task can be determined according to the result type in the following manner: if the result type is a successful prediction, the sleep duration is determined to be a first duration, and the task concurrency is determined to be a first concurrency; if the result type is a failed prediction, the sleep duration is determined to be a second duration, and the task concurrency is determined to be a second concurrency.
[0183] The sleep duration refers to the length of time that the target model suspends processing prediction tasks.
[0184] The first duration may be smaller than the second duration. For example, the first duration may be 1 second, and the second duration may be 1 minute.
[0185] The first concurrency may be greater than the current concurrency. For example, the first concurrency may be a value that is doubled from the current concurrency.
[0186] The second concurrency may be less than the current concurrency. For example, the second concurrency may be half the current concurrency. The first concurrency is greater than the second concurrency. For example, if the current concurrency is 200, the first concurrency may be 400 and the second concurrency may be 100.
[0187] When the result type is prediction success, it means that the current concurrency of the prediction task is within the processing capacity of the target model, and the target model can execute the prediction task in time to obtain a prediction result of successful prediction. The target model can be put into sleep for a shorter period of time (i.e., the first period of time) and the task concurrency can be increased to the first concurrency to improve the processing efficiency of the target model; when the result type is prediction failure, it means that the current concurrency may have exceeded the upper limit of the processing capacity of the target model, and the target model can no longer execute the prediction task in time, resulting in prediction failure. Therefore, the target model can be put into sleep for a longer period of time (i.e., the second period of time) and the task concurrency can be reduced to the second concurrency so that the target model can process the prediction task in time.
[0188] For example, if the current concurrency is 200, if the result type is prediction success, the sleep time can be determined to be 1 second, the target model can sleep for 1 second, and the task concurrency can be determined to be the first concurrency of 400; if the result type is prediction failure, the sleep time can be determined to be 1 minute, the target model can sleep for 1 minute, and the task concurrency can be determined to be the second concurrency of 100.
[0189] Optionally, workers can define their own upper and lower limits on concurrency.
[0190] In an embodiment of the present application, the electronic device can obtain a prediction task, and according to the identifier of the target user, obtain the user data of the target user in the preset storage space; can determine multiple historical containers used by the target user in the historical period, and obtain the container data of each historical container; can obtain system data in the preset storage space. The electronic device can determine that the container-related data includes the user data of the target user, the container data of each historical container, and the system data. The electronic device can determine the target model corresponding to the prediction task, and determine the last update time of the target model. If the time difference between the last update time and the current time is less than or equal to the first preset duration, the container-related data can be processed by the target model to obtain a prediction result. If the time difference between the last update time and the current time is greater than the first preset duration, the first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data, and the updated target model is obtained, and the container-related data is processed by the updated target model to obtain a prediction result. The electronic device can obtain a preset resource amount threshold, and determine whether the reserved resource amount is less than or equal to the preset resource amount threshold; if not, a prompt message can be sent to the preset device. The electronic device can also determine the result type of the prediction result, and determine the sleep duration and task concurrency of executing the prediction task according to the result type. Since the electronic device can determine the target model according to the prediction task and predict the reserved resource amount of the target user through the target model, the flexibility of allocating container resources is improved compared to allocating container resources to the target user based on fixed preset rules.
[0191] Figure 4 A flowchart of another method for allocating resources of a container provided by an exemplary embodiment of the present application. Figure 4 , the method may include:
[0192] S401: Obtain prediction tasks.
[0193] The prediction task can be used to determine the cache duration of the target container.
[0194] For example, the electronic device may obtain prediction task 2, and prediction task 2 may be used to determine the cache duration of container 1.
[0195] S402: Determine an identifier of a first user corresponding to the target container.
[0196] For any container, the container has a corresponding user.
[0197] For example, if the target container is container 1 and the corresponding first user is user 1, the identifier of user 1 can be determined. Assume that the identifier of user 1 is 001.
[0198] S403: Acquire user data of the first user in a preset storage space according to the identifier of the first user.
[0199] The user data includes: multiple operation moments of the first user on the container within a historical period, and the first operation event corresponding to each operation moment, the first operation event includes the operation type and container information of the operated container, and the operation type includes the creation container type and the cancellation container type.
[0200] For example, if the identifier of the first user is 001, user data 1 of user 1 may be obtained in the preset storage space according to the identifier 001. If the historical period is 2023.3.1-2023.9.30, user data 1 may be as shown in Table 1.
[0201] S404: Acquire container data of the target container in a preset storage space according to the identifier of the target container.
[0202] The container data may include: resource usage information, event information, and container status of the target container at each time in the historical period, and the event information includes the operation time and operation type.
[0203] For example, if the target container is container 1, and the identifier of container 1 is A001, the container data of container 1 can be obtained in the preset storage space according to the identifier A001. Assume that the container data of container 1 can be as shown in Table 4:
[0204] Table 4
[0205]
[0206]
[0207] S405: Determine that the container-related data includes user data of the first user and container data of the target container.
[0208] For example, the electronic device may determine that the container-related data 2 includes the user data 1 as shown in Table 1 and the container data of the container 1 as shown in Table 4.
[0209] S406: Determine the target model corresponding to the prediction task.
[0210] Since the prediction task is used to determine the cache duration of the target container, it can be determined that the corresponding target model is the XGBoost model.
[0211] S407: Determine the last update time of the target model.
[0212] For example, if the target model is an XGBoost model, the electronic device may determine the last update time corresponding to the target model, assuming that the last update time is 2023.9.25 0:00.
[0213] S408. If the time difference between the last update time and the current time is less than or equal to the second preset time length, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed through the target model to obtain a prediction result.
[0214] The second preset duration may be manually set. For example, the second preset duration may be 7 days (ie, 168 hours).
[0215] The prediction result may be the cache duration of the target container.
[0216] Optionally, the offline performance may refer to the performance of the target model in predicting the cache duration of the target container in an offline state.
[0217] Optionally, the offline performance and the preset performance may be characterized by prediction accuracy. For example, the prediction accuracy of the preset performance may be 80%, and the prediction accuracy of the offline performance may be 85%.
[0218] For example, if the last update time of the XGBoost model is 2023.9.25 0:00, the current time is 2023.10.115:30, if the second preset duration is 7 days, if the prediction accuracy of the preset performance is 80%, and the prediction accuracy of the offline performance is 85%, then since the time difference between the last update time and the current time of the XGBoost model is less than 7 days, and the offline performance of the XGBoost model is greater than the preset performance, the container-related data 2 can be processed by the XGBoost model to obtain prediction result 2, assuming that the prediction result 2 is that the cache duration of container 1 is 72 hours.
[0219] S409. If the time difference between the last update moment and the current moment is greater than a second preset duration, or the offline performance is less than the preset performance, the target model is updated until the time difference between the last update moment and the current moment is less than the second preset duration, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed by the updated target model to obtain a prediction result.
[0220] Optionally, second historical data between the last update time of the target model and the current time may be obtained in a preset storage space, and the target model may be updated according to the second historical data.
[0221] The second historical data may include user data of multiple users and container data of multiple containers.
[0222] For example, if the last update time of the XGBoost model is 2023.9.20 0:00, the current time is 2023.10.1 15:30, if the second preset duration is 7 days, if the prediction accuracy of the preset performance is 80%, and the prediction accuracy of the offline performance is 85%, then since the time difference between the last update time of the XGBoost model and the current time is greater than 7 days, the second historical data between 2023.9.20 0:00-2023.10.1 15:30 can be obtained, and the XGBoost model is updated by the second historical data to obtain an updated XGBoost model, then the last update time is changed to 2023.10.1 15:30. Assuming that the prediction accuracy of the offline performance of the updated XGBoost model is 86%, the container-related data 2 can be processed by the updated XGBoost model to obtain prediction result 2, assuming that the cache duration of prediction result 2 for container 1 is 72 hours.
[0223] The target model can be used to predict the cache duration of the target container, and the target container can be retained according to the cache duration. When the user uses the target container again within the cache duration, the target container can be quickly started, thereby improving the timeliness of starting the target container.
[0224] S410: Obtain a cache duration threshold, and determine whether the cache duration is less than or equal to the cache duration threshold.
[0225] The cache time threshold can be preset manually.
[0226] Optionally, the electronic device may obtain a cache duration threshold and determine whether the cache duration is less than or equal to the cache duration threshold. If so, the target container may be retained according to the cache duration; if not, step S411 may be executed.
[0227] For example, if the cache duration threshold is 120 hours, and if the cache duration of container 1 in prediction result 2 is 72 hours, it can be determined that the cache duration is less than the cache duration threshold, and container 1 can be retained for 72 hours; if the cache duration of container 1 in prediction result 2 is 130 hours, it can be determined that the cache duration is greater than the cache duration threshold, and S411 is executed.
[0228] S411: If not, send a prompt message to the preset device.
[0229] The preset device can be a staff member's computer.
[0230] Prompt information can be used to indicate that there are errors in the prediction results, making it easier for staff to intervene to check or troubleshoot the problem.
[0231] For example, if the cache duration of container 1 in prediction result 2 is greater than the cache duration threshold, prompt information 2 may be sent to the preset device, and prompt information 2 may be: the cache duration of container 1 exceeds the cache duration threshold.
[0232] S412: Determine the result type of the prediction result.
[0233] S413: Determine the sleep duration and task concurrency of executing the prediction task according to the result type.
[0234] It should be noted that the execution process of steps S412 to S413 can refer to steps S312 to S313, and will not be repeated here.
[0235] In an embodiment of the present application, the electronic device can obtain a prediction task and determine the identifier of the first user corresponding to the target container. The electronic device can obtain the user data of the first user in the preset storage space according to the identifier of the first user; and obtain the container data of the target container in the preset storage space according to the identifier of the target container, and then determine that the container-related data includes the user data of the first user and the container data of the target container. The electronic device can determine the target model corresponding to the prediction task and determine the last update time of the target model. If the time difference between the last update time and the current time is less than or equal to the second preset time, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed by the target model to obtain a prediction result. If the time difference between the last update time and the current time is greater than the second preset time, or the offline performance is less than the preset performance, the target model is updated until the offline performance of the target model is greater than or equal to the preset performance, and the container-related data is processed by the updated target model to obtain a prediction result. The electronic device can also obtain a cache time threshold and determine whether the cache time is less than or equal to the cache time threshold. If not, a prompt message is sent to the preset device. The electronic device can also determine the result type of the prediction result, and determine the sleep duration and task concurrency of executing the prediction task based on the result type. Since the electronic device can predict the cache duration of the target container through the target model, there is no need to determine the cache duration based on fixed preset rules, thereby improving the flexibility of allocating container resources.
[0236] Any of the above embodiments is executed in the cloud product system. Figure 5 , the system architecture of the cloud product system described in the above embodiments is explained.
[0237] Figure 5 A schematic diagram of the system architecture of the cloud product system provided for the exemplary embodiment of this application. Figure 5,The cloud product system can include big data service components, machine learning components, system monitoring components, container management and control components, data collection components, prediction service components, system monitoring and alarm components.
[0238] (1) The data collection component can use the Simple Log Service (SLS), periodic table synchronization and message queue to obtain the container's operation log and resource usage information from the container management component, and can determine multiple user data, multiple container data, and multiple system data based on the operation log and resource usage information.
[0239] Optionally, third-party data may also be collected through the data collection component. For example, the third-party data may be data provided by a user.
[0240] Optionally, the data collection component may also support obtaining and determining user data, container data, and system data through other open source components.
[0241] After the multiple user data, the multiple container data, and the multiple system data are determined by the data acquisition component, the multiple user data, the multiple container data, and the multiple system data can be synchronized to the big data service component.
[0242] (2) Big data service components may include data synchronization, data cleaning, visualization analysis, and data storage. Through data synchronization, multiple user data, multiple container data, and multiple system data can be obtained.
[0243] It should be noted that data synchronization can support synchronization from multiple data sources. For example, multiple data sources may include log service SLS, message queue Kafka, persistent storage relational database, and memory storage remote dictionary service database.
[0244] In big data services, the three types of data can be cleaned and then visualized. In the process of visualization analysis, in order to help staff better understand the changes in the current data distribution, multiple user data, multiple container data, and multiple system data can be traced and clustered to determine the user data corresponding to each user, the container data corresponding to each container, and the system data, which can help staff understand the connection between data tables and dirty data in business tables. Through visualization analysis, analysis results such as the operation status of the container can be determined.
[0245] After visual analysis of the above three types of data, the processed three types of data and the analysis results can be stored.
[0246] (3) In the machine learning component, multiple preset models may be included. For example, the machine learning component may include a Bert model and an Xgboost model.
[0247] For any preset model, the machine learning component can perform feature mining based on the three types of data processed in the big data service component, train the preset model, determine the hyperparameters of the preset model, and verify the preset model to obtain a trained preset model.
[0248] For example, for the Bert model, you can obtain user data, container data, and system data in the historical period, pre-train the Bert model, and train the Bert model with daily incremental data. The Bert model can be used to predict the amount of reserved resources for the target user at the target time.
[0249] For the Xgboost model, user data and container data of the historical period can be obtained to train the Xgboost model, and the Xgboost model can be updated according to the user data and container data within the second preset time period, and the offline performance of the Xgboost model can be verified. The cache duration of the target container can be predicted through the Xgboost model.
[0250] Optionally, the machine learning component can send multiple trained preset models to the prediction service component.
[0251] (4) In the prediction service component, two prediction methods can be included, namely streaming data prediction and offline batch prediction.
[0252] Optionally, streaming data prediction can be performed using an Xgboost model to obtain prediction results; offline batch prediction can be performed using a Bert model to obtain prediction results.
[0253] It should be noted that when performing offline batch prediction, prediction can be made based on user data, container data, and system data processed in the big data service component.
[0254] Optionally, you can set any preset model to perform streaming data prediction or offline batch prediction based on actual needs.
[0255] Optionally, in order to reduce resource waste, prediction services can be centrally deployed according to regions, and prediction services in other regions can be supported through agents, reducing the cost of multi-region deployment to a single region, which can effectively save computing resources and reduce operation and maintenance costs.
[0256] (5) In the container management and control component, it can include container business, business profiling, container resource reservation, container resource cache and business tracking. Multiple containers are run in the container business. The multiple containers are provided for users.
[0257] In business profiling, container resource reservation and container resource caching are involved. For container resource reservation, the container control component can reserve resources for each user based on the prediction results obtained by offline batch prediction through the Bert model in the prediction service component. For container resource caching, the container control component can obtain processed user data, container data, and system data from the big data service component, and can perform feature splicing on the three types of data. After obtaining the feature data, it actively calls the streaming data prediction in the prediction service to process the feature data through the Xgboost model to obtain the prediction results.
[0258] Optionally, after obtaining the feature data, the container management and control component may synchronize the feature data to a distributed storage system.
[0259] Optionally, the distributed storage system may include three forms, namely, Java Virtual Machine (JVM) memory, relational database and distributed key / value storage system.
[0260] If the feature data is synchronized to a distributed key / value storage system, the feature synchronization task can be broken down into different subtasks based on consistent hashing technology and evenly distributed to all storage servers, avoiding excessive pressure on a single storage server and speeding up the synchronization of feature data.
[0261] (6) In the system monitoring and alarm components, it can include management and control operation monitoring, system service monitoring and model effect monitoring.
[0262] For control and operation monitoring, you can monitor the network resources and computing resources of the control machine. The control machine refers to the machine that manages the container.
[0263] For system service monitoring, you can monitor the production time, data volume, and production time of offline tables in big data services.
[0264] For model effect monitoring, since user data, container data, and system data change frequently, model performance needs to be monitored to ensure the accuracy of model predictions.
[0265] When it is determined that the reserved resources in the prediction result are greater than the preset resource threshold, or the cache duration of the target container is greater than the cache duration threshold, a prompt message can be sent to the preset device to issue a system alarm to remind the staff that the prediction result is wrong. Through the system alarm, the prediction service can be prevented from deteriorating, and the staff can troubleshoot the system failure in time.
[0266] (7) In the effect monitoring component, the effect of the cloud product system operation can be pushed regularly in the form of daily reports and dashboards, and visual display is supported. For example, information such as the model prediction accuracy and the utilization rate of various resources in the cloud product system can be displayed.
[0267] In an embodiment of the present application, the cloud product system includes components such as data collection, big data services, machine learning, prediction services, management and control design, effect display, system monitoring and alarm, which can effectively reduce the cost of using container resources and improve the flexibility of allocating container resources; and the cloud product system supports offline batch data prediction and online streaming prediction scenarios, and has strong scalability.
[0268] Figure 6 This is a schematic diagram of the structure of a container resource allocation device provided in an embodiment of the present application. Figure 6 The container resource allocation device 10 comprises: a first acquisition module 11, a second acquisition module 12 and a processing module 13, wherein:
[0269] The first acquisition module 11 is used to acquire a prediction task, where the prediction task is used to determine the reserved resource amount of the target user or the cache duration of the target container;
[0270] The second acquisition module 12 is used to acquire container-related data in a preset storage space according to the prediction task, where the container-related data is obtained by processing the operation log and resource usage information of the container in the server;
[0271] The processing module 13 is used to determine the target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task, where the prediction result is the reserved resource amount of the target user or the cache duration of the target container.
[0272] The resource allocation device for a container provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be described in detail here.
[0273] In a possible implementation manner, the second acquisition module 12 is specifically configured to:
[0274] If the prediction task is used to determine the reserved resource amount of the target user, acquiring the container-related data in the preset storage space according to the identifier of the target user;
[0275] If the prediction task is used to determine the cache duration of the target container, an identifier of a first user corresponding to the target container is determined, and the container-related data is acquired in the preset storage space according to the identifier of the target container and the identifier of the first user.
[0276] In a possible implementation manner, the second acquisition module 12 is specifically configured to:
[0277] According to the identifier of the target user, user data of the target user is acquired in the preset storage space, the user data including: at least one operation moment of the target user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0278] Determine at least one historical container used by the target user in a historical period, and obtain container data of each historical container, wherein the container data includes: resource usage information, event information, and container status of the historical container at each time in the historical period, wherein the event information includes a generation time and an event type;
[0279] Acquire the system data in the preset storage space, where the system data includes the total number of containers deployed by the server in the historical period and total resource usage information;
[0280] The container-related data includes user data of the target user, container data of each historical container, and the system data.
[0281] In a possible implementation manner, the second acquisition module 12 is specifically configured to:
[0282] According to the identifier of the first user, user data of the first user is acquired in the preset storage space, the user data including: at least one operation moment of the first user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type;
[0283] According to the identifier of the target container, obtaining container data of the target container in the preset storage space, the container data including: resource usage information, event information and container status of the target container at each time in the historical period, the event information including operation time and operation type;
[0284] The container-related data includes user data of the first user and container data of the target container.
[0285] In a possible implementation manner, the prediction task is used to determine the reserved resource amount of the target user; the processing module 13 is specifically used to:
[0286] Determining the last update time of the target model;
[0287] If the time difference between the last update time and the current time is less than or equal to the first preset time length, the container-related data is processed by the target model to obtain the prediction result;
[0288] If the time difference between the last update time and the current time is greater than the first preset time length, first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data to obtain an updated target model, and the container-related data is processed by the updated target model to obtain the prediction result;
[0289] The first historical data includes user data of multiple users, container data of multiple containers, and system data corresponding to the server, and the prediction result is the reserved resource amount of the target user.
[0290] In a possible implementation, the prediction task is used to determine the cache duration of the target container; and the processing module 13 is specifically used to:
[0291] Determining the last update time of the target model;
[0292] If the time difference between the last update time and the current time is less than or equal to a second preset time length, and the offline performance of the target model is greater than or equal to a preset performance, the container-related data is processed by the target model to obtain the prediction result;
[0293] If the time difference between the last update time and the current time is greater than the second preset time, or the offline performance is less than the preset performance, the target model is updated until the offline performance of the target model is greater than or equal to the preset performance, and the container-related data is processed by the updated target model to obtain the prediction result;
[0294] The prediction result is the cache duration of the target container.
[0295] The resource allocation device for a container provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be described in detail here.
[0296] Figure 7This is a schematic diagram of the structure of another container resource allocation device provided in an embodiment of the present application. Figure 7 ,exist Figure 6 Based on the embodiment shown, the container resource allocation device 10 further includes a first determining module 14,
[0297] The first determination module 14 is used to determine the result type of the prediction result, and the result type is prediction success or prediction failure;
[0298] The first determination module 14 is used to determine the sleep duration and task concurrency of executing the prediction task according to the result type.
[0299] The resource allocation device for a container provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be described in detail here.
[0300] In a possible implementation manner, the first determining module 14 is specifically configured to:
[0301] If the result type is the prediction success, determining the sleep duration to be the first duration, and determining the task concurrency to be the first concurrency;
[0302] If the result type is the prediction failure, determining the sleep duration to be the second duration, and determining the task concurrency to be the second concurrency;
[0303] Among them, the first duration is shorter than the second duration, and the first concurrency is larger than the second concurrency.
[0304] In a possible implementation manner, the container resource allocation device 10 further includes: a third acquisition module 15, a second determination module 16 and a storage module 17, wherein:
[0305] The third acquisition module 15 is used to obtain the operation log and resource usage information of the container in the server;
[0306] The second determination module 16 is used to determine, according to the operation log, multiple containers existing in the server and determine the user corresponding to each container;
[0307] The second determination module 16 is further used to determine, according to the operation log and the resource usage information, container data of each container, user data of each user, and system data, wherein the system data includes the total number of containers deployed by the server during the historical period and total resource usage information;
[0308] The storage module 17 is used to store the container data corresponding to each container, the user data of each user and the system data in the preset storage space.
[0309] In a possible implementation, after the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, the container resource allocation device 10 further includes a judgment module 18, and the judgment module 18 is used to:
[0310] If the prediction result is the reserved resource amount of the target user, obtaining a preset resource amount threshold, and determining whether the reserved resource amount is less than or equal to the preset resource amount threshold, and if not, sending a prompt message to a preset device, wherein the prompt message is used to indicate that there is an error in the prediction result;
[0311] If the preset result is the cache duration of the target container, a cache duration threshold is obtained, and it is determined whether the cache duration is less than or equal to the cache duration threshold; if not, the prompt information is sent to the preset device.
[0312] The resource allocation device for a container provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be described in detail here.
[0313] The exemplary embodiment of the present application provides a structural diagram of an electronic device, see Figure 8 The electronic device 20 may include a processor 21 and a memory 22. Exemplarily, the processor 21 and the memory 22 are interconnected via a bus 23.
[0314] The memory 22 stores computer-executable instructions;
[0315] The processor 21 executes the computer-executable instructions stored in the memory 22, so that the processor 21 executes the method shown in the above method embodiment.
[0316] Accordingly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method described in the above method embodiment.
[0317] Accordingly, an embodiment of the present application may also provide a computer program product, including a computer program, which, when executed by a processor, can implement the method shown in the above method embodiment.
[0318] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0319] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0320] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0321] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0322] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0323] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0324] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0325] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0326] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A container resource allocation method, characterized in that: include: Obtaining a prediction task, where the prediction task is used to determine the amount of reserved resources for a target user or to determine a cache duration for a target container; According to the prediction task, container-related data is obtained in a preset storage space, where the container-related data is obtained by processing the operation log and resource usage information of the container in the server; Determine a target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task, where the prediction result is the reserved resource amount of the target user or the cache duration of the target container.
2. The method according to claim 1, characterized in that: According to the prediction task, container-related data is obtained in a preset storage space, including: If the prediction task is used to determine the reserved resource amount of the target user, acquiring the container-related data in the preset storage space according to the identifier of the target user; If the prediction task is used to determine the cache duration of the target container, an identifier of a first user corresponding to the target container is determined, and the container-related data is acquired in the preset storage space according to the identifier of the target container and the identifier of the first user.
3. The method according to claim 2, characterized in that Acquiring the container-related data in the preset storage space according to the identifier of the target user includes: According to the identifier of the target user, user data of the target user is acquired in the preset storage space, the user data including: at least one operation moment of the target user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type; Determine at least one historical container used by the target user in a historical period, and obtain container data of each historical container, wherein the container data includes: resource usage information, event information, and container status of the historical container at each time in the historical period, wherein the event information includes a generation time and an event type; Acquire system data in the preset storage space, wherein the system data includes the total number of containers deployed by the server during the historical period and total resource usage information; The container-related data includes user data of the target user, container data of each historical container, and the system data.
4. The method according to claim 2, characterized in that: Acquiring the container-related data in the preset storage space according to the identifier of the target container and the identifier of the first user includes: According to the identifier of the first user, user data of the first user is acquired in the preset storage space, the user data including: at least one operation moment of the first user on a container within a historical period, and a first operation event corresponding to each operation moment, the first operation event including an operation type and container information of the operated container, the operation type including a create container type and a cancel container type; According to the identifier of the target container, obtaining container data of the target container in the preset storage space, the container data including: resource usage information, event information and container status of the target container at each time in the historical period, the event information including operation time and operation type; The container-related data includes user data of the first user and container data of the target container.
5. The method according to any one of claims 1 to 4, characterized in that: The prediction task is used to determine the reserved resource amount of the target user; the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, including: Determining the last update time of the target model; If the time difference between the last update time and the current time is less than or equal to the first preset time length, the container-related data is processed by the target model to obtain the prediction result; If the time difference between the last update time and the current time is greater than the first preset time length, first historical data between the last update time and the current time is obtained in the preset storage space, the target model is updated according to the first historical data to obtain an updated target model, and the container-related data is processed by the updated target model to obtain the prediction result; The first historical data includes user data of multiple users, container data of multiple containers, and system data corresponding to the server, and the prediction result is the reserved resource amount of the target user.
6. The method according to any one of claims 1 to 4, characterized in that: The prediction task is used to determine the cache duration of the target container; the container-related data is processed by the target model to obtain a prediction result corresponding to the prediction task, including: Determining the last update time of the target model; If the time difference between the last update time and the current time is less than or equal to a second preset time length, and the offline performance of the target model is greater than or equal to a preset performance, the container-related data is processed by the target model to obtain the prediction result; If the time difference between the last update moment and the current moment is greater than the second preset duration, or the offline performance is less than the preset performance, the target model is updated until the time difference between the last update moment and the current moment is less than the second preset duration, and the offline performance of the target model is greater than or equal to the preset performance, the container-related data is processed by the updated target model to obtain the prediction result; The prediction result is the cache duration of the target container.
7. The method according to any one of claims 1 to 6, characterized in that: After the target model is used to process the container-related data to obtain a prediction result corresponding to the prediction task, the method further includes: Determine a result type of the prediction result, wherein the result type is prediction success or prediction failure; The sleep duration and task concurrency of executing the prediction task are determined according to the result type.
8. The method according to claim 7, characterized in that According to the result type, determine the sleep duration and task concurrency of executing the prediction task, including: If the result type is the prediction success, determining the sleep duration to be the first duration, and determining the task concurrency to be the first concurrency; If the result type is the prediction failure, determining the sleep duration to be the second duration, and determining the task concurrency to be the second concurrency; Among them, the first duration is shorter than the second duration, and the first concurrency is larger than the second concurrency.
9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Obtaining the operation log and resource usage information of the container in the server; According to the operation log, multiple containers existing in the server are determined, and a user corresponding to each container is determined; Determine, according to the operation log and the resource usage information, container data of each container, user data of each user, and system data, wherein the system data includes a total number of containers deployed by the server during the historical period and total resource usage information; The container data corresponding to each container, the user data of each user and the system data are stored in the preset storage space.
10. The method according to any one of claims 1 to 9, characterized in that: After the target model is used to process the container-related data to obtain a prediction result corresponding to the prediction task, the method further includes: If the prediction result is the reserved resource amount of the target user, obtaining a preset resource amount threshold, and determining whether the reserved resource amount is less than or equal to the preset resource amount threshold, and if not, sending a prompt message to a preset device, wherein the prompt message is used to indicate that the prediction result is wrong; If the preset result is the cache duration of the target container, a cache duration threshold is obtained, and it is determined whether the cache duration is less than or equal to the cache duration threshold; if not, the prompt information is sent to the preset device.
11. A container resource allocation device, characterized in that: include: A first acquisition module, a second acquisition module and a processing module, wherein: The first acquisition module is used to acquire a prediction task, where the prediction task is used to determine the reserved resource amount of the target user or the cache duration of the target container; The second acquisition module is used to acquire container-related data in a preset storage space according to the prediction task, where the container-related data is obtained by processing the operation log and resource usage information of the container in the server; The processing module is used to determine the target model corresponding to the prediction task, and process the container-related data through the target model to obtain a prediction result corresponding to the prediction task, where the prediction result is the reserved resource amount of the target user or the cache duration of the target container.
12. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the electronic device to perform the method described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method according to any one of claims 1 to 10 is implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Cited By
Data persistence arrangement method, device and equipment of Redis database on cloud, medium and product
CN122489663A