Container resource deployment method and device based on deep reinforcement learning, and electronic equipment
Automatically adjusting container resources through the deep reinforcement learning model solves the problem of relying on human experience for container resource configuration adjustment in cloud platforms, and achieves efficient and accurate resource management.
Patent Information
- Application Number
- CN202410830670.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-27
AI Technical Summary
In the cloud platform, container resource configuration adjustment relies on human experience, resulting in low efficiency. Resource allocation cannot be adjusted in real time according to actual conditions, resulting in insufficient resource allocation.
A method based on deep reinforcement learning is used to obtain the state feature set of the container object and input it into the deep reinforcement learning model to make decisions, automatically adjust container resources, and achieve dynamic resource adjustment.
It improves the efficiency and accuracy of container resource adjustment, and can automatically adjust resources according to the status change trend of the container, reducing human intervention and improving resource utilization efficiency.
Smart Images

Figure CN118708348A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, financial technology or other related technical fields, and specifically, to a container resource deployment method and device based on deep reinforcement learning, and an electronic device. Background Art
[0002] With the rapid advent of the Internet of Everything era and the rapid development of wireless networks, intelligent facilities have been widely popularized. The amount of data in the new Internet era has exploded and reached the ZB level. The traditional system architecture can no longer support the transmission, storage and calculation of the rapidly generated massive data. Cloud computing has emerged as the times require. Cloud computing provides scalable, on-demand self-service, and widely accessible computing resources and services.
[0003] Platform as a Service is a cloud computing service that provides users with management services for basic environments such as networks, servers, operating systems, and storage. Users only need to consider the logical control and policy orchestration of upper-level applications. The orchestration policy allocates appropriate resources to the container and determines the amount of resources available to the application.
[0004] In the related art, when performing container resource orchestration, container operation resources are manually preset in advance and remain basically unchanged during the application life cycle. However, during its life cycle, the resource requirements of applications will change due to various factors. Therefore, when the number of containers and applications increases, there are several problems with manually preset resources: First, adjusting container operation resources is heavily dependent on the experience of the executor, and it is difficult to minimize the difference between allocated resources and actual operating resources; second, adjusting the optimal orchestration strategy for applications according to specific scenarios is labor-intensive and manpower-consuming; third, it is impossible to adjust resource allocation according to real-time conditions, and the adjustment efficiency and accuracy are low.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present invention provide a container resource deployment method and device based on deep reinforcement learning, and an electronic device, so as to at least solve the technical problem in the related art that when adjusting the resource configuration of the container in the cloud platform, it is often based on human experience and the adjustment efficiency is low.
[0007] According to one aspect of an embodiment of the present invention, a container resource deployment method based on deep reinforcement learning is provided, comprising: obtaining a state feature set of a container object in a current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target moment in the current state, and the second data set is a data set within a target time period in the current state; inputting the state features in the state feature set into a deep reinforcement learning model one by one, making decisions based on an intelligent agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision model pre-constructed based on a deep reinforcement learning algorithm; and deploying the decision actions to the container object.
[0008] Optionally, the first data set in the current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
[0009] Optionally, the second data set in the current state includes at least one of the following: historical allocation data of central processing unit resources in the current state, and historical occupancy data of central processing unit resources in the current state.
[0010] Optionally, before obtaining the state feature set of the container object in the current state, it also includes: configuring a resource adjustment strategy for the container object based on the state features of the container object, wherein the resource adjustment strategy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources, memory resources; fine-grained division of the resource adjustment strategy to obtain N discrete actions, wherein N is a positive integer; defining the action space of the agent based on the N discrete actions, wherein the action space is used to configure decision actions for the container object.
[0011] Optionally, before obtaining the state feature set of the container object in the current state, it also includes: determining a reward function of the reinforcement learning model based on the state features of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
[0012] Optionally, after the decision action is deployed to the container object, it also includes: calculating the target resource data of the container object after the decision action is deployed to the container object; obtaining the resource threshold of the container object and the resource occupancy data of the container object in the current state, and accumulating the resource threshold and the resource occupancy data to obtain the resource data threshold; when the target resource data is less than the resource data threshold, setting the current container operation status label of the container object to the target value, and returning the operation status label to the intelligent agent.
[0013] Optionally, the deep reinforcement learning model is trained by the following steps: step one, initializing the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters at least include: Q network parameters, training data batch number, M is a positive integer, and the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; step two, obtaining an initial state feature set of the container object, constructing a state transition sequence based on the initial state feature set, and storing the state transition sequence in an experience replay pool; step three, selecting the state transition sequences indicated by the number of training data batches from the experience replay pool to obtain a sample set; step four, storing the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; step five, calculate the gradient value based on the Q value and the target Q value; step six, update the Q network parameters based on the gradient value; repeat the above steps three to six, iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, end the iterative training, and obtain the trained deep reinforcement learning model, wherein K is a positive integer greater than or equal to 2.
[0014] According to another aspect of an embodiment of the present invention, a container resource deployment device based on deep reinforcement learning is also provided, including: an acquisition unit, used to obtain a state feature set of a container object in a current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target moment in the current state, and the second data set is a data set within a target time period in the current state; a decision unit, used to input the state features in the state feature set into a deep reinforcement learning model one by one, and make decisions based on an intelligent agent of the deep reinforcement learning model to obtain a decision action, wherein the deep reinforcement learning model is a decision model pre-constructed based on a deep reinforcement learning algorithm; a deployment unit, used to deploy the decision action to the container object.
[0015] Optionally, the first data set in the current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
[0016] Optionally, the second data set in the current state includes at least one of the following: historical allocation data of central processing unit resources in the current state, and historical occupancy data of central processing unit resources in the current state.
[0017] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first configuration module, used to configure a resource adjustment strategy for the container object based on the state characteristics of the container object, wherein the resource adjustment strategy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources, memory resources; a first division module, used to perform fine-grained division of the resource adjustment strategy to obtain N discrete actions, wherein N is a positive integer; a first definition module, used to define the action space of the agent based on the N discrete actions, wherein the action space is used to configure decision actions for the container object.
[0018] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first determination module, used to determine a reward function of the reinforcement learning model based on state characteristics of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
[0019] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first calculation module, used to calculate the target resource data of the container object after the decision action is deployed to the container object; a first acquisition module, used to obtain the resource threshold of the container object and the resource occupancy data of the container object in the current state, and accumulate the resource threshold and the resource occupancy data to obtain the resource data threshold; a first return module, used to set the current container operation status label of the container object to the target value when the target resource data is less than the resource data threshold, and return the operation status label to the intelligent agent.
[0020] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first initialization module, used in step one, to initialize the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters include at least: Q network parameters, training data batch number, M is a positive integer, the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; a first construction module, used in step two, to obtain the initial state feature set of the container object, to construct a state transition sequence based on the initial state feature set, and to store the state transition sequence in an experience replay pool; a first selection module, used in step three, to select the state transition sequence indicated by the number of training data batches from the experience replay pool to obtain a sample set; a first output module, used in step four, to output the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; a second calculation module, used in step five, to calculate the gradient value based on the Q value and the target Q value; a first updating module, used in step six, to update the Q network parameters based on the gradient value; a first iteration module, used to repeat the above steps three to six, iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, end the iterative training, and obtain the trained deep reinforcement learning model, wherein K is a positive integer greater than or equal to 2.
[0021] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned container resource deployment methods based on deep reinforcement learning.
[0022] According to another aspect of an embodiment of the present invention, a computer program product is further provided, wherein the computer program product includes a computer program, wherein when the computer program is executed by a processor, any one of the above-mentioned container resource deployment methods based on deep reinforcement learning is implemented.
[0023] In the application, the following steps are taken: first, a state feature set of the container object in the current state is obtained, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target moment in the current state, and the second data set is a data set within a target time period in the current state, and then the state features in the state feature set are input into the deep reinforcement learning model one by one, and an intelligent agent based on the deep reinforcement learning model makes a decision to obtain a decision action, wherein the deep reinforcement learning model is a decision model pre-constructed based on a deep reinforcement learning algorithm, and finally the decision action is deployed to the container object.
[0024] In the application, the deep reinforcement learning algorithm is combined with container resource orchestration. The state characteristics of the container object under the target state are analyzed through the pre-built deep reinforcement learning model, and the decision action is output. The allocated resources of the container object are adjusted through the decision action, so as to realize automatic dynamic adjustment and improve the efficiency of resource adjustment. At the same time, the state characteristics under the target state take into account the historical state information of the container object, so that the deep reinforcement learning model can make full use of the state change trend of the container to make decisions, obtain decision actions to adjust the allocated resources of the container object, so as to cope with the fluctuation of container resources and improve the accuracy of resource adjustment. This solves the technical problem in related technologies that when adjusting the resource configuration of containers in the cloud platform, it often relies on human experience and has low adjustment efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 is a flowchart of an optional container resource deployment method based on deep reinforcement learning according to an embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of an optional iterative training based on a deep reinforcement learning model according to an embodiment of the present invention;
[0028] Figure 3 is a structural diagram of an optional container resource deployment solution based on deep reinforcement learning according to an embodiment of the present invention;
[0029] Figure 4 is a schematic diagram of an optional container resource deployment device based on deep reinforcement learning according to an embodiment of the present invention;
[0030] Figure 5 It is a hardware structure block diagram of an electronic device (or mobile device) according to a container resource deployment method based on deep reinforcement learning according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] To facilitate those skilled in the art to understand the present invention, some terms or nouns involved in the embodiments of the present invention are explained below:
[0034] Docker, container, transplants the application and its operating environment into a movable container.
[0035] Pod, an object that manages containers, a collection of one or more containers.
[0036] It should be noted that the container resource deployment method based on deep reinforcement learning and the device thereof in the present application can be used in the field of artificial intelligence when container resources are deployed based on a deep reinforcement learning algorithm, and can also be used in any field other than the field of artificial intelligence when container resources are deployed based on a deep reinforcement learning algorithm. The present application does not limit the application field of the container resource deployment method based on deep reinforcement learning and the device thereof.
[0037] It should be noted that the relevant 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 information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant regions, take necessary confidentiality measures, do not violate public order and good customs, and provide corresponding operation entrances for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0038] It should be noted that in this application, when collecting and analyzing customer information, corresponding operation entrances are provided for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered.
[0039] The following embodiments of the present invention can be applied to various systems / applications / devices for container resource deployment based on deep reinforcement learning. The present invention integrates deep reinforcement learning algorithms with resource orchestration, and realizes intelligent dynamic adjustment of resource allocation based on deep reinforcement learning algorithms, thereby improving the efficiency of resource orchestration and adjustment. At the same time, the historical state information of container objects is introduced into the decision algorithm, so that the decision model can make full use of the state change trend to cope with the fluctuation of container resources, thereby improving the accuracy of container resource adjustment.
[0040] The present invention is described in detail below in conjunction with various embodiments.
[0041] Embodiment 1
[0042] According to an embodiment of the present invention, an embodiment of a container resource deployment method based on deep reinforcement learning is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.
[0043] Figure 1 is a flowchart of an optional container resource deployment method based on deep reinforcement learning according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0044] Step S101, obtaining a state feature set of the container object in the current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target time in the current state, and the second data set is a data set within a target time period in the current state;
[0045] Step S102, inputting the state features in the state feature set into the deep reinforcement learning model one by one, and making decisions based on the intelligent agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision model pre-constructed based on the deep reinforcement learning algorithm;
[0046] Step S103: deploy the decision action to the container object.
[0047] Through the above steps, first obtain the state feature set of the container object in the current state, wherein the state feature set includes the first data set and the second data set in the current state, the first data set is the data set corresponding to the target moment in the current state, and the second data set is the data set within the target time period in the current state, and then input the state features in the state feature set into the deep reinforcement learning model one by one, and make decisions based on the intelligent agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision model pre-constructed based on the deep reinforcement learning algorithm, and finally the decision action is deployed to the container object.
[0048] In this embodiment, a deep reinforcement learning algorithm is combined with container resource orchestration. The state characteristics of the container object in the target state are analyzed through a pre-built deep reinforcement learning model, and a decision action is output. The allocated resources of the container object are adjusted through the decision action, thereby realizing automatic dynamic adjustment and improving resource adjustment efficiency. At the same time, the state characteristics under the target state take into account the historical state information of the container object, so that the deep reinforcement learning model can make full use of the state change trend of the container to make decisions, obtain decision actions to adjust the allocated resources of the container object, so as to cope with the fluctuation of container resources and improve the accuracy of resource adjustment. This solves the technical problem in related technologies that when adjusting the resource configuration of containers in the cloud platform, it often relies on human experience and has low adjustment efficiency.
[0049] The embodiment of the present invention is described in detail below in combination with the above steps.
[0050] It should be noted that container technology is an important technology of cloud computing technology. Container technology allows developers to package applications and all the content required for application operation (code, runtime, library, environment variables and configuration files) and deploy them in the form of containers on the cloud computing platform. Container technology can ensure application isolation and provide portability. Through container cluster management, it can provide a series of functions such as deployment and operation, resource scheduling and dynamic scaling for containerized applications. The resources occupied during the application life cycle are uniformly scheduled and controlled by the container cluster. Generally, they can be controlled by setting two parameters, guaranteed supply and limited usage, in the application resource orchestration strategy. The supply is the resource required by the system when the container is started, and the limited usage is the upper limit of the resources that can be used when the container is running. During the operation of the container, due to the growth of business, resources exceeding the supply can be used, but only the resources defined by the limited usage can be used at most. When the supply in the resource orchestration strategy is less than the limited usage, when the cluster resources are insufficient, this container may be terminated by the cluster; when the supply in the resource orchestration strategy is equal to the limited usage, the container will be terminated only when the container uses resources exceeding the resource threshold.
[0051] It should be noted that since manual adjustment of container resource orchestration is cumbersome, inefficient and strongly dependent on domain knowledge, this embodiment uses deep reinforcement learning to dynamically generate decision actions and then adjust the resources of container objects, which can improve the resource utilization efficiency of nodes and the efficiency of container resource adjustment.
[0052] It should be noted that the deep reinforcement learning algorithm makes decisions through intelligent agents and outputs decision actions. The decision actions need to be configured in advance based on user needs.
[0053] It should be noted that the container object in the embodiment of the present invention can be a commonly used container (such as Docker), or an object for managing containers (such as Pod), etc.
[0054] Optionally, before obtaining the state feature set of the container object in the current state, it also includes: configuring a resource adjustment strategy for the container object based on the state features of the container object, wherein the resource adjustment strategy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources, memory resources; fine-grained division of the resource adjustment strategy to obtain N discrete actions, wherein N is a positive integer; defining the action space of the intelligent agent based on the N discrete actions, wherein the action space is used to configure decision actions for the container object.
[0055] It should be noted that when configuring decision actions, it is necessary to combine with the actual operating environment and configure the actions according to the actual needs of the user. The purpose of this embodiment is to make decisions through the status characteristics of the container object and obtain decision actions. The status characteristics indicate the actual situation of the container object resource usage, and the final decision action needs to adjust the resources of the container object to solve the problems of excess container object resources or insufficient container resources.
[0056] When configuring a decision action, first configure a resource adjustment strategy for the container object according to the state characteristics of the container object to be monitored. The state characteristics of the container object include: the number of requests, the number of responses, the total length of the request message, the total length of the response message, the container survival status, the internal application response time, the CPU allocation and CPU occupancy status and their corresponding historical information, the memory allocation and memory occupancy and their historical information. For the CPU allocation and CPU occupancy status and their corresponding historical information, the memory allocation and memory occupancy and their historical information examples are as follows: CPU allocation at the target time, CPU occupancy at the target time, CPU allocation 1 second before the target time, CPU occupancy 1 second before the target time, target CPU allocation 10 seconds before the target time, CPU usage 10 seconds before the target time, memory allocation at the target time, memory usage at the target time, memory allocation 1 second before the target time, memory usage 1 second before the target time, memory allocation 10 seconds before the target time, memory usage 10 seconds before the target time. Based on the above-mentioned state characteristics to be monitored, determine the resources that can be adjusted, and then configure the resource adjustment strategy. For the above-mentioned state characteristics, the resources that can be adjusted include CPU (i.e. central processing unit) resources and memory resources, and the resource adjustment strategy can include: increasing CPU resources, reducing CPU resources, and keeping CPU resources unchanged; increasing memory resources, reducing memory resources, and keeping memory resources unchanged.
[0057] After obtaining the resource adjustment strategy, it is also necessary to divide it into fine-grained divisions to obtain finer-grained discrete adjustment actions, and then use the discrete actions obtained after division as the action space of deep reinforcement learning. For example, the increase and decrease of CPU resources can be divided into five granularities, namely: 0.00001CPU, 0.0001CPU, 0.001CPU, 0.01CPU, 0.1CPU; the increase and decrease of memory resources can also be divided into five granularities, namely: 0.01M, 0.1M, 1M, 10M, 100M. Therefore, the action space (i.e., decision action) can be defined as the above 22 discrete actions.
[0058] It should be noted that after configuring the decision action for the deep reinforcement learning model, you also need to configure the reward function. In the deep reinforcement learning algorithm, the reward function plays a vital role. It defines the immediate reward that the agent of the deep reinforcement learning model receives when performing an action. The reward function provides a standard for the agent to evaluate the quality of its behavior and is the core mechanism for guiding the agent to learn strategies.
[0059] Optionally, before obtaining the state feature set of the container object in the current state, the method further includes: determining a reward function of the reinforcement learning model based on the state features of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
[0060] In an embodiment of the present invention, the reward function is determined based on the state characteristics of the container object to be monitored, and is divided into four parts, namely, a first reward function based on CPU resources, a second reward function based on memory resources, a third reward function based on the survival status of the container, and a fourth reward function determined based on the response time of the application in the container. The first reward function, the second reward function, the third reward function and the fourth reward function are linearly added to obtain the final intelligent agent reward function.
[0061] Specifically, the first reward function r1 based on CPU resources is expressed as:
[0062]
[0063] Among them, r1 is the first reward function, cpu real The actual CPU resource usage of the container object, cpu allocate The CPU resources allocated to the container object.
[0064] The second reward function r2 based on memory resources is expressed as:
[0065]
[0066] Among them, r2 is the second reward function, M real is the actual memory resource usage of the container object, M allocate Memory resources allocated for container objects.
[0067] In order to ensure that the container has enough resources to survive, the agent is constrained according to the survival status of the container. The third reward function r3 based on the survival status of the container is expressed as:
[0068]
[0069] Among them, r3 is the third reward function, container object survival means that the container object is in a normal working state, and others mean that the container object is terminated and is in an abnormal working state.
[0070] It should be noted that in terms of response time, since too little resource allocation will affect the normal operation of applications in the container, the deployed applications can be constrained to provide a unified health check interface to feedback the response time to the system for the model to evaluate the smoothness of the application running in the container. The fourth reward function r4 determined based on the response time of the application in the container is expressed as:
[0071]
[0072] Among them, r4 is the fourth reward function, t i It is expressed as the response time of the i-th application in the container, n is the number of applications in the container, and when the response time is greater than 20 seconds, it is calculated as 20 seconds to prevent the penalty for timeout applications from being too high. The agent's reward for each round consists of the above four parts, that is, the total reward function r = r1 + r2 + r3 + r4.
[0073] Optionally, the deep reinforcement learning model is trained by the following steps: step 1, initializing the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters at least include: Q network parameters, the number of training data batches, M is a positive integer, and the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; step 2, obtaining an initial state feature set of the container object, constructing a state transition sequence based on the initial state feature set, and storing the state transition sequence in an experience replay pool; step 3, selecting a state transition sequence indicated by the number of training data batches from the experience replay pool to obtain a sample set; step 4, storing the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; step five, calculate the gradient value based on the Q value and the target Q value; step six, update the Q network parameters based on the gradient value; repeat the above steps three to six, iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, end the iterative training, and obtain a trained deep reinforcement learning model, wherein K is a positive integer greater than or equal to 2.
[0074] It should be noted that the deep reinforcement learning model makes decisions through intelligent agents and outputs decision actions, which are obtained through continuous training through the reward mechanism. Figure 2 is a schematic diagram of an optional iterative training based on a deep reinforcement learning model according to an embodiment of the present invention, such as Figure 2 As shown in the figure, the deep reinforcement learning model constructs two deep neural networks, namely the Q network and the target Q network. The Q value represents the value of each action, and the target Q value represents the optimal Q value of the next state after the reward discount factor and reward scaling, that is, The state features of two adjacent states are input into the Q network and the target Q network respectively, and the Q value and the target Q value are output. The action value function Q and the target action value function are fitted through two deep neural networks. Iteratively minimize the difference between the outputs of the two neural networks (Q value and target Q value), so that the Q value is gradually updated to the target Q value, and the container state data of the next moment is continuously output through the Q network, the reward function is calculated, and the obtained container state data is recorded in the experience replay pool. The experience replay pool provides sample data for the deep neural network, and the Q value is updated cyclically, thereby completing the iteration of the deep reinforcement learning model.
[0075] Specifically, when training the deep reinforcement learning model, various parameters of the deep reinforcement learning model are first initialized to obtain an initialized model parameter set, including: initializing the capacity of the experience replay pool to N, starting the training number n, and recording multiple data in the experience replay pool. Each data record records the state information, action, and reward (state transition sequence) from the previous state to the next state of the container object. The state transition of the agent will be randomly recorded in the experience replay pool as an iterative data source.
[0076] Randomly initialize Q network parameters θ and randomly initialize target Q network parameters Greedy strategy ε, reward discount factor γ, learning rate α, network parameters represent the weights of each neuron in the deep neural network. For the reward discount factor γ, in order to maximize the cumulative reward obtained by the agent, the reward obtained by the agent in each round will take into account the rewards obtained in the future. The closer the reward is to the current one, the greater the impact on the current reward. After each state transfer is completed, the reward obtained by the current behavior will be multiplied by the reward discount factor to correct the target Q value. The learning rate is the step size for updating the weight in each iteration.
[0077] Initialize the number of rounds M and the number of cycles in each round T, and the number of training batches batch.
[0078] Get the initial value S0 of the container resource status, that is, the current number of requests, number of responses, request message length, response message length, current survival status, response time CPU allocation, CPU usage, memory allocation, memory usage and other status characteristics;
[0079] After initializing the model parameters, you can select a random action according to the ε-greedy strategy or output the action a with the maximum action value through the initialized deep reinforcement learning model. t ; Execute the action a obtained abovet Adjust the resources of the container object and obtain the reward r t and state S t+1 ; S t ,a t r t ,S t+1 As a sequence, it is added to the experience replay pool D. If the replay pool is full, an existing sequence is randomly replaced.
[0080] When training a deep reinforcement learning model, a batch of state transition sequences is randomly selected from the experience replay pool to obtain a training sample set;
[0081] For each sequence in the batch, t Input Q network and get the corresponding action a t The output Q value q = Q(S t ,a t ), S t+1 Input the target Q network and obtain the maximum target Q value, that is At the same time, based on the Q network output reward value, the target Q value is corrected by the output reward value and reward discount factor γ, and the result is Then the gradient value is calculated based on the Q value and the corrected target Q value, that is, J = (qq * ) 2 , minimize the difference between the Q value and the target Q value through the gradient descent algorithm, and back-propagate to update the Q network parameters, so as to perform iterative training based on the above steps until the gradient values obtained after K consecutive iterative training are the same, indicating that the difference between the Q value and the target Q value no longer decreases, then stop the iterative training.
[0082] After the training is completed, the current state St is input into the Q network to obtain the output a of the Q network t As a decision action of the agent.
[0083] After each fixed number of cycles C, the Q network parameters need to be copied to the target Q network to correct the target Q network.
[0084] Step S101, obtaining a state feature set of a container object in a current state.
[0085] It should be noted that the above-mentioned state feature set includes a first data set and a second data set in the current state. The first data set is the data set corresponding to the target moment in the current state, and the second data set is the data set within the target time period in the current state. This embodiment reflects the state change trend of the container within the target time period through the historical state information under a certain state, so that the deep reinforcement learning model can make full use of the state change trend to make more accurate decisions, thereby improving the accuracy of resource adjustment.
[0086] Optionally, the first data set in the current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
[0087] It should be noted that the first data set in the current state may include: the number of requests, the number of responses, the total length of request messages, the total length of response messages in the container at the target time in the current state, the container object running status label, the response time of the application inside the container object, etc.
[0088] Optionally, the second data set in the current state includes at least one of the following: historical allocation data of the central processing unit resources in the current state, and historical occupancy data of the central processing unit resources in the current state.
[0089] It should be noted that the second data set in the current state may include: historical allocation data of CPU resources in the current state, historical occupancy data of CPU resources in the current state, historical allocation data of memory resources in the current state, and historical occupancy data of memory resources in the current state, etc. For example, the historical allocation data of CPU resources in the current state may be the allocation data of CPU resources at the target moment, the allocation data of CPU resources 1 second before the target moment, the allocation data of CPU resources 10 seconds before the target moment, etc.
[0090] Step S102, input the state features in the state feature set into the deep reinforcement learning model one by one, and make decisions based on the intelligent agent of the deep reinforcement learning model to obtain decision actions.
[0091] It should be noted that the above-mentioned deep reinforcement learning model is a decision model pre-built based on the deep reinforcement learning algorithm. After obtaining the state feature set as the input information of the model, each state feature is input into the deep reinforcement learning model one by one. The deep reinforcement learning model has been trained in advance and can directly output decision actions based on the state features, such as increasing 0.1 CPU or reducing 0.01M memory as the decision action to be executed.
[0092] Step S103: deploy the decision action to the container object.
[0093] It should be noted that the decision actions output by the deep reinforcement learning model are deployed to the container object, and the resources of the container object are adjusted so that the container can meet business needs and is always in a normal working state. The container object is continuously monitored and the container object resources can be adjusted in real time.
[0094] Optionally, after the decision action is deployed to the container object, it also includes: calculating the target resource data of the container object after the decision action is deployed to the container object; obtaining the resource threshold of the container object and the resource occupancy data of the container object in the current state, and accumulating the resource threshold and the resource occupancy data to obtain the resource data threshold; when the target resource data is less than the resource data threshold, setting the current container operation status label of the container object to the target value, and returning the operation status label to the intelligent agent.
[0095] It should be noted that before deployment, security thresholds are configured for the resources of the container object to improve robustness. Here is an example of 0.05CPU and 10M as the security thresholds for the central processing unit and memory. After the decision action is deployed to the container object, if the resources deployed this time are less than the sum of the actual running resources and the security threshold, the action at the time of this deployment is assigned to the variable corresponding to the state feature set, and the survival status is set to 0 and returned to the agent to make a new decision.
[0096] Another optional specific implementation is described in detail below.
[0097] Figure 3 is a structural diagram of an optional container resource deployment solution based on deep reinforcement learning according to an embodiment of the present invention, such as Figure 3 As shown in the figure, the container resource deployment solution monitors the container objects to obtain the real-time status characteristics of the container objects, including the CPU resource status characteristics, memory status characteristics, response speed characteristics, etc. in the target state, and inputs the status characteristics into the deep reinforcement learning model. The intelligent agent makes decisions and outputs corresponding decision actions. The output decision actions are deployed to the container objects through the resource orchestration configuration model, and the resources of the container objects are adjusted so that the container objects can meet business needs.
[0098] In an embodiment of the present invention, a deep reinforcement learning algorithm is integrated with resource orchestration, and intelligent dynamic adjustment of resource allocation is implemented based on the deep reinforcement learning algorithm to improve the efficiency of resource orchestration and adjustment. At the same time, the historical state information of the container object is introduced into the decision-making algorithm, so that the decision model can make full use of the state change trend to cope with the fluctuation of container resources, thereby improving the accuracy of container resource adjustment.
[0099] The following is a detailed description in conjunction with another embodiment.
[0100] Embodiment 2
[0101] A container resource deployment device based on deep reinforcement learning provided in this embodiment includes multiple implementation units, each implementation unit corresponds to each implementation step in the above-mentioned embodiment 1. Its specific implementation methods and beneficial effects can refer to the above-mentioned method embodiments and will not be repeated here.
[0102] Figure 4 is a schematic diagram of an optional container resource deployment device based on deep reinforcement learning according to an embodiment of the present invention, such as Figure 4 As shown, the container resource deployment device based on deep reinforcement learning may include: an acquisition unit 41, a decision unit 42, and a deployment unit 43, wherein:
[0103] An acquisition unit 41 is used to acquire a state feature set of the container object in the current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target time in the current state, and the second data set is a data set within a target time period in the current state;
[0104] A decision unit 42, used to input the state features in the state feature set into the deep reinforcement learning model one by one, and make a decision based on the intelligent agent of the deep reinforcement learning model to obtain a decision action, wherein the deep reinforcement learning model is a decision model pre-constructed based on the deep reinforcement learning algorithm;
[0105] The deployment unit 43 is used to deploy the decision action to the container object.
[0106] The above-mentioned container resource deployment device based on deep reinforcement learning obtains the state feature set of the container object in the current state through the acquisition unit 41, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is the data set corresponding to the target moment in the current state, and the second data set is the data set within the target time period in the current state; the state features in the state feature set are input into the deep reinforcement learning model one by one through the decision unit 42, and the intelligent agent based on the deep reinforcement learning model makes a decision to obtain a decision action, wherein the deep reinforcement learning model is a decision model pre-constructed based on the deep reinforcement learning algorithm; the decision action is deployed to the container object through the deployment unit 43.
[0107] In this embodiment, a deep reinforcement learning algorithm is combined with container resource orchestration. The state characteristics of the container object in the target state are analyzed through a pre-built deep reinforcement learning model, and a decision action is output. The allocated resources of the container object are adjusted through the decision action, thereby realizing automatic dynamic adjustment and improving resource adjustment efficiency. At the same time, the state characteristics under the target state take into account the historical state information of the container object, so that the deep reinforcement learning model can make full use of the state change trend of the container to make decisions, obtain decision actions to adjust the allocated resources of the container object, so as to cope with the fluctuation of container resources and improve the accuracy of resource adjustment. This solves the technical problem in related technologies that when adjusting the resource configuration of containers in the cloud platform, it often relies on human experience and has low adjustment efficiency.
[0108] Optionally, the first data set in the current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
[0109] Optionally, the second data set in the current state includes at least one of the following: historical allocation data of the central processing unit resources in the current state, and historical occupancy data of the central processing unit resources in the current state.
[0110] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first configuration module, used to configure a resource adjustment strategy for the container object based on the state characteristics of the container object, wherein the resource adjustment strategy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources, memory resources; a first division module, used to perform fine-grained division of the resource adjustment strategy to obtain N discrete actions, wherein N is a positive integer; a first definition module, used to define the action space of the intelligent agent based on the N discrete actions, wherein the action space is used to configure decision actions for the container object.
[0111] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first determination module, used to determine a reward function of the reinforcement learning model based on state characteristics of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
[0112] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first calculation module, used to calculate the target resource data of the container object after the decision action is deployed to the container object; a first acquisition module, used to obtain the resource threshold of the container object and the resource occupancy data of the container object in the current state, and accumulate the resource threshold and the resource occupancy data to obtain the resource data threshold; a first return module, used to set the current container operation status label of the container object to the target value when the target resource data is less than the resource data threshold, and return the operation status label to the intelligent agent.
[0113] Optionally, the container resource deployment device based on deep reinforcement learning also includes: a first initialization module, used for step one, to initialize the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters include at least: Q network parameters, the number of training data batches, M is a positive integer, the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; a first construction module, used for step two, to obtain an initial state feature set of the container object, to construct a state transition sequence based on the initial state feature set, and to store the state transition sequence in an experience replay pool; a first selection module, used for step three, to select a number of state transition sequences indicated by the number of training data batches from the experience replay pool to obtain a sample set; a first output module, used for step four, to output the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; a second calculation module, used in step five, calculates the gradient value based on the Q value and the target Q value; a first update module, used in step six, updates the Q network parameters based on the gradient value; a first iteration module, used to repeat the above steps three to six, iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, terminate the iterative training, and obtain a trained deep reinforcement learning model, wherein K is a positive integer greater than or equal to 2.
[0114] The above-mentioned container resource deployment device based on deep reinforcement learning may also include a processor and a memory. The above-mentioned acquisition unit 41, decision unit 42, deployment unit 43, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0115] The above processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and container resources can be deployed by adjusting kernel parameters.
[0116] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0117] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned container resource deployment methods based on deep reinforcement learning.
[0118] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned container resource deployment methods based on deep reinforcement learning.
[0119] According to another aspect of an embodiment of the present invention, a computer program product is further provided, the computer program product comprising a computer program, wherein when the computer program is executed by a processor, any one of the above-mentioned container resource deployment methods based on deep reinforcement learning is implemented.
[0120] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: obtaining a state feature set of a container object in a current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target moment in the current state, and the second data set is a data set within a target time period in the current state; inputting the state features in the state feature set into a deep reinforcement learning model one by one, making decisions based on an intelligent agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision model pre-constructed based on a deep reinforcement learning algorithm; and deploying the decision actions to the container object.
[0121] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing a program that is initialized with the following method steps: a first data set in a current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
[0122] The present application also provides a computer program product, which, when executed on a data processing device, is also suitable for executing an initialization program having the following method steps: a second data set in a current state includes at least one of the following: historical allocation data of central processing unit resources in the current state, and historical occupancy data of central processing unit resources in the current state.
[0123] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: before obtaining a set of state features of a container object in a current state, it also includes: configuring a resource adjustment strategy for the container object based on the state features of the container object, wherein the resource adjustment strategy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources, memory resources; fine-grained division of the resource adjustment strategy to obtain N discrete actions, wherein N is a positive integer; defining an action space of an intelligent agent based on the N discrete actions, wherein the action space is used to configure a decision action for the container object.
[0124] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: before obtaining a set of state features of a container object in a current state, it also includes: determining a reward function of a reinforcement learning model based on the state features of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
[0125] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: after deploying a decision action to a container object, it also includes: calculating the target resource data of the container object after the decision action is deployed to the container object; obtaining the resource threshold of the container object and the resource occupancy data of the container object in the current state, and accumulating the resource threshold and the resource occupancy data to obtain a resource data threshold; when the target resource data is less than the resource data threshold, setting the current container operation status label of the container object to the target value, and returning the operation status label to the intelligent agent.
[0126] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: a deep reinforcement learning model is trained by the following steps: step one, initializing the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters at least include: Q network parameters, the number of training data batches, M is a positive integer, and the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; step two, obtaining an initial state feature set of the container object, constructing a state transition sequence based on the initial state feature set, and storing the state transition sequence in an experience replay pool; step three, selecting a state transition sequence indicated by the number of training data batches from the experience replay pool to obtain a sample set; step four, storing the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; step five, calculate the gradient value based on the Q value and the target Q value; step six, update the Q network parameters based on the gradient value; repeat the above steps three to six, iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, end the iterative training, and obtain a trained deep reinforcement learning model, wherein K is a positive integer greater than or equal to 2.
[0127] Figure 5 is a hardware structure block diagram of an electronic device (or mobile device) according to a container resource deployment method based on deep reinforcement learning according to an embodiment of the present invention. Figure 5 As shown, the electronic device may include one or more ( Figure 5 502a, 502b, ..., 502n are used to illustrate) processor 502 (processor 502 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), memory 504 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 5 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 5 More or fewer components as shown, or with Figure 5Different configurations shown.
[0128] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0129] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0131] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0132] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0133] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0134] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A container resource deployment method based on deep reinforcement learning, characterized in that: include: Obtain a state feature set of the container object in the current state, wherein the state feature set includes a first data set and a second data set in the current state, the first data set is a data set corresponding to a target time in the current state, and the second data set is a data set within a target time period in the current state; Inputting the state features in the state feature set into the deep reinforcement learning model one by one, and making decisions based on the agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision model pre-constructed based on the deep reinforcement learning algorithm; The decision action is deployed to the container object.
2. The deployment method according to claim 1, characterized in that: The first data set in the current state includes at least one of the following: the number of requests in the current state, the number of responses in the current state, the total length of request messages in the current state, the total length of response messages in the current state, the current container running state label, and the application response time inside the container object in the current state.
3. The deployment method according to claim 1, characterized in that: The second data set in the current state includes at least one of the following: historical allocation data of the central processing unit resources in the current state, and historical occupancy data of the central processing unit resources in the current state.
4. The deployment method according to claim 1, characterized in that: Before obtaining the state feature set of the container object in the current state, it also includes: configuring a resource adjustment policy for the container object based on the state characteristics of the container object, wherein the resource adjustment policy is used to adjust the resources allocated to the container object, and the resources allocated to the container object include at least one of the following: central processing unit resources and memory resources; Fine-grained division of the resource adjustment strategy to obtain N discrete actions, where N is a positive integer; An action space of the agent is defined based on the N discrete actions, wherein the action space is used to configure a decision action for the container object.
5. The deployment method according to claim 1, characterized in that: Before obtaining the state feature set of the container object in the current state, it also includes: A reward function of the reinforcement learning model is determined based on the state characteristics of the container object, wherein the reward function is used to iteratively train the reinforcement learning model.
6. The deployment method according to claim 2, characterized in that: After deploying the decision action to the container object, the method further includes: calculating target resource data of the container object after deploying the decision action to the container object; Acquire a resource threshold of the container object and resource occupancy data of the container object in a current state, and accumulate the resource threshold and the resource occupancy data to obtain a resource data threshold; In the case where the target resource data is less than the resource data threshold, the current container operation status tag of the container object is set to a target value, and the operation status tag is returned to the agent.
7. The deployment method according to claim 1, characterized in that: The deep reinforcement learning model is trained by the following steps: Step 1: Initialize the model parameters of the deep reinforcement learning model to obtain an initialized model parameter set, wherein the model parameter set includes M model parameters, and the model parameters at least include: Q network parameters, the number of training data batches, M is a positive integer, and the Q network parameters represent the weights of each neuron in the Q network in the deep reinforcement learning model, and the Q network is constructed based on a deep neural network; Step 2: obtaining an initial state feature set of the container object, constructing a state transition sequence based on the initial state feature set, and storing the state transition sequence in an experience replay pool; Step 3, selecting a state transition sequence of a number indicated by the number of training data batches from the experience replay pool to obtain a sample set; Step 4: convert the state transition sequence S in the sample set t Input into the Q network of the deep reinforcement learning model, output the Q value and the reward value, and input the next state transition sequence corresponding to the state transition sequence in the sample set and the reward value output by the Q network into the target Q network of the deep reinforcement learning model, and output the target Q value, wherein the target Q network is a copy created based on the Q network, and the target Q network parameters of the target Q network are updated based on the updated Q network parameters after a preset number of iterative training; Step 5, calculating a gradient value based on the Q value and the target Q value; Step six, updating the Q network parameters based on the gradient value; Repeat steps 3 to 6 to iteratively train the deep reinforcement learning model until the gradient values obtained after K consecutive iterative trainings are the same, and then terminate the iterative training to obtain the trained deep reinforcement learning model, where K is a positive integer greater than or equal to 2.
8. A container resource deployment device based on deep reinforcement learning, characterized in that: include: An acquisition unit, configured to acquire a state feature set of the container object in a current state, wherein the state feature set includes a first data set and a second data set in the current state, wherein the first data set is a data set corresponding to a target moment in the current state, and the second data set is a data set within a target time period in the current state; A decision-making unit, used to input the state features in the state feature set into a deep reinforcement learning model one by one, and make decisions based on the agent of the deep reinforcement learning model to obtain decision actions, wherein the deep reinforcement learning model is a decision-making model pre-constructed based on a deep reinforcement learning algorithm; A deployment unit is used to deploy the decision action to the container object.
9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the container resource deployment method based on deep reinforcement learning as described in any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product includes a computer program, wherein when the computer program is executed by a processor, the container resource deployment method based on deep reinforcement learning described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Model reasoning container deployment method and device
CN120875033A
Model inference container deployment method and apparatus
CN120875033B
