Resource allocation method and device, equipment, storage medium and program product
Dynamically adjusting the hardware resource allocation of microservices through the deep reinforcement learning model solves the problems of hardware resource waste and service quality under the microservices framework, and improves economy and adaptability.
Patent Information
- Application Number
- CN202410666991.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-10
AI Technical Summary
Each microservice under the microservices framework is usually configured with a large number of computing resources, resulting in a waste of server hardware resources. Moreover, the existing resource allocation strategies based on machine learning and manual design cannot effectively predict and prevent quality of service (QoS) violations, and are difficult to adapt to microservices. Scenarios where the number of services is variable.
By obtaining the current and historical resource-related operating data of multiple microservices in the microservices framework, build and train deep reinforcement learning models, generate predictive allocation action strategies, and dynamically adjust the hardware resource allocation of microservices to adapt to workload changes and ensure service quality.
It effectively avoids the waste of hardware resources, improves the economy of the microservice framework, and can adapt to the dynamic characteristics of changes in the number of microservices to ensure service quality.
Smart Images

Figure CN118626253A
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology application technology, and in particular to a resource allocation method, device, equipment, storage medium and program product. Background Art
[0002] In the related art, the microservice framework realizes cloud services by running multiple loosely coupled microservices concurrently. In order to avoid the change of workload when the number of service requests increases rapidly, resulting in substandard service quality (QoS), each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources. Summary of the invention
[0003] The main purpose of this application is to provide a resource allocation method, device, equipment, storage medium and program product, aiming to solve the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources.
[0004] To achieve the above objectives, the present application proposes a resource allocation method, comprising:
[0005] Obtaining current resource-related operation data of multiple microservices in a microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data, and service request workload data;
[0006] Input the current resource-related operation data into the pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices;
[0007] Dynamically allocate resources to multiple microservices based on the predicted allocation action strategy.
[0008] In one embodiment, before the step of inputting the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation to multiple microservices, the method further includes:
[0009] Get historical resource-related operation data of multiple microservices;
[0010] Determine the state space and action space of the deep reinforcement learning model based on historical resource-related operation data;
[0011] Build and train deep reinforcement learning models based on preset reward functions, state spaces, and action spaces.
[0012] In one embodiment, the steps of constructing and training a deep reinforcement learning model according to a preset reward function, state space, and action space include:
[0013] Construct the objective function based on the preset reward function and the expected entropy of the action allocation strategy;
[0014] Construct an initial deep reinforcement learning model based on the preset reward function, state space, and action space;
[0015] According to the state space and the action space, with the goal of maximizing the objective function, the model parameters of the initial deep reinforcement learning model are updated to obtain the deep reinforcement learning model.
[0016] In one embodiment, before the step of constructing and training a deep reinforcement learning model according to a preset reward function, state space, and action space, the method further includes:
[0017] A preset reward function is determined based on the end-to-end delay of multiple microservices and a preset delay threshold.
[0018] In one embodiment, the historical resource-related operating data includes historical resource-related operating data within a plurality of historical time steps;
[0019] Based on historical resource-related operation data, the steps to determine the state space and action space of the deep reinforcement learning model include:
[0020] For the historical resource-related operation data in each historical time step, determine the state characteristics of each microservice in the historical time step according to the historical resource-related operation data; wherein the state characteristics include at least one of a delay characteristic and a request service characteristic;
[0021] For each microservice, connect the state features within multiple historical time steps to obtain the state vector of the microservice;
[0022] According to all state vectors, the state space is obtained;
[0023] For each historical time step, an action vector is generated based on the state characteristics of each microservice within the historical time step;
[0024] According to all action vectors, the action space is obtained.
[0025] In one embodiment, the step of dynamically allocating resources to multiple microservices according to the prediction allocation action strategy includes:
[0026] Determine the resource adjustment strategy for each microservice based on the current resource allocation status and predicted allocation action strategy;
[0027] Dynamically allocate resources to multiple microservices based on all resource adjustment policies.
[0028] In addition, to achieve the above purpose, the present application also proposes a resource allocation device, the resource allocation device comprising:
[0029] An acquisition module is used to acquire current resource-related operation data of multiple microservices in a microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data, and service request workload data;
[0030] The strategy generation module is used to input the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices;
[0031] The resource allocation module is used to dynamically allocate resources to multiple microservices based on the predicted allocation action strategy.
[0032] In addition, to achieve the above objectives, the present application also proposes a resource allocation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the resource allocation method as described above.
[0033] In addition, to achieve the above objectives, the present application also proposes a storage medium, which is a computer-readable storage medium. A computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the resource allocation method as described above are implemented.
[0034] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the resource allocation method as described above are implemented.
[0035] One or more technical solutions proposed in this application have at least the following technical effects:
[0036] The present application provides a resource allocation method, apparatus, device, storage medium and program product to obtain current resource-related operation data of multiple microservices in a microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data and service request workload data; all current resource-related operation data are input into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices; and dynamic resource allocation is performed on multiple microservices according to the predictive allocation action strategy.
[0037] Therefore, this application uses a deep reinforcement learning model to generate a predictive allocation action strategy based on the current resource-related operating data, and dynamically allocates resources to multiple microservices. In the process of concurrent operation of multiple microservices, the actual hardware resource requirements of multiple microservices are dynamically determined according to the actual operation conditions of multiple microservices, and hardware resources are allocated to each microservice, so that the computing resources of each microservice change with the changes in workload. Under the premise of ensuring QoS, it will not cause waste of hardware resources of the servers where multiple microservices are located. It solves the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources, and improves the economy of the microservice framework. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0040] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the resource allocation method of the present application;
[0041] Figure 2 A schematic diagram of a flow chart provided for Embodiment 2 of the resource allocation method of the present application;
[0042] Figure 3 This is a schematic diagram of the module structure of the resource allocation device according to an embodiment of the present application;
[0043] Figure 4 A schematic diagram of the device structure of the hardware operating environment involved in the resource allocation method in the embodiment of the present application.
[0044] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0046] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0047] The main solution of the embodiment of the present application is: obtaining current resource-related operating data of multiple microservices in a microservice framework; wherein the resource-related operating data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data and service request workload data; inputting all current resource-related operating data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices; and dynamically allocating resources to multiple microservices according to the predictive allocation action strategy.
[0048] In related technologies, with the advancement of the "cloud native transformation" strategy, many business support system architectures have gradually migrated from monolithic frameworks to microservice frameworks. In a microservice framework, hundreds of loosely coupled microservices usually run concurrently. However, cloud services have strict quality of service (QoS) requirements, for example, allowing a maximum end-to-end latency of 99 percentile.
[0049] Therefore, it is very challenging to meet strict QoS in a microservice framework. The main reasons include: the workload of microservices is constantly fluctuating. As the number of service requests and the type of service requests change, the fluctuation of the workload of microservices will increase the delay of the queue and affect the service quality; service requests must interact with multiple microservices (sometimes sequentially) to be satisfied, resulting in increased latency, which will affect the service quality; the update, addition and deletion of microservices during the entire execution process increases the uncertainty of resource requirements and also affects the service quality. Therefore, in order to avoid the rapid increase in the number of service requests, which leads to QoS failure, each microservice in the microservice framework is usually configured with more computing resources, resulting in a waste of server hardware resources.
[0050] Currently, resource allocation methods include machine learning (ML)-based and manually designed resource allocation strategies to adjust the central processing unit (CPU), memory, cache, input / output (I / O) channels, network links and other resources of each microservice in the microservice framework.
[0051] However, methods based on machine learning and manual design of resource allocation strategies still have limitations:
[0052] First, resource allocation strategies based on machine learning and manual design cannot predict and prevent impending QoS violations. If resources are not allocated properly, it may be difficult to recover, which will have a long-term impact on tail latency.
[0053] Secondly, machine learning algorithms cannot match the dynamic characteristics of microservices themselves. When there are major updates to microservices, manually designed machine learning algorithms require manual adjustment of model parameters. Parameterized machine learning algorithms have a built-in stationary assumption and all model parameters need to be retrained from scratch, making machine learning algorithms unable to adapt to microservice frameworks with a variable number of microservices.
[0054] The present application provides a solution. During the concurrent operation of multiple microservices, the actual hardware resource requirements of multiple microservices are dynamically determined according to the actual operation conditions of multiple microservices, and hardware resources are allocated to each microservice, so that the computing resources of each microservice change with the changes in workload. Under the premise of ensuring QoS, the hardware resources of the server where multiple microservices are located will not be wasted. The technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of hardware resources on the server, is solved, and the economic efficiency of the microservice framework is improved. In addition, the deep reinforcement learning model of the present application is also updated according to the historical resource-related operation data, and can adapt to the microservice framework with a variable number of microservices.
[0055] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a resource allocation device, etc. The following takes the resource allocation device as an example to illustrate this embodiment and the following embodiments.
[0056] Based on this, the embodiment of the present application provides a resource allocation method, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the resource allocation method of the present application.
[0057] In this embodiment, the resource allocation method includes steps S100 to S300:
[0058] Step S100, obtaining current resource-related operation data of multiple microservices in the microservice framework.
[0059] Among them, resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data and service request workload data.
[0060] It should be noted that multiple microservices may include all microservices involved in completing the service request at the current moment in the microservice framework. When multiple microservices are running, it is necessary to allocate hardware resources of the server where each microservice is located to support the operation of the microservice. Usually, hardware resources may include resources such as CPU, memory, cache, I / O channels and network links. The source-related operation data may be related operation characteristic data that affects the utilization of hardware resources and microservice performance (for example, including the delay characteristics of microservices).
[0061] Step S200, input the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices.
[0062] It should be noted that the deep reinforcement learning model can be constructed and trained by selecting a reinforcement learning algorithm according to actual usage requirements. The prediction allocation action strategy may include resource allocation actions for hardware service resources of multiple microservices, wherein the allocation action may be a hardware service resource allocation percentage for the corresponding microservice.
[0063] Step S300: Dynamically allocate resources to multiple microservices according to the predicted allocation action strategy.
[0064] It should be noted that, at different times, a prediction allocation action strategy is generated according to the corresponding current resource-related operation data, so that hardware service resources can be allocated to each microservice according to the actual needs of each microservice at different times.
[0065] In a feasible implementation, step S300 may include steps A310 to A320:
[0066] Step A310, determining the resource adjustment strategy of each microservice according to the current resource allocation state and the predicted allocation action strategy.
[0067] Step A320: Dynamically allocate resources to multiple microservices according to all resource adjustment strategies.
[0068] It is understandable that the resource allocation device can collect resource-related operation data using the industry standard AutoScale algorithm through the Linux cgroups API, but does not perform resource allocation updates. After the reinforcement learning model generates a predicted allocation action strategy based on the current resource-related operation data, the classifier network can be set after the reinforcement learning model, and the AutoScale algorithm is used to determine the resource adjustment strategy from the preset resource allocation adjustment strategy set according to the current resource allocation state and the predicted allocation action strategy, and dynamically allocate resources to each microservice. When used specifically, the preset resource allocation adjustment strategy in the preset resource allocation adjustment strategy set can be set according to actual usage requirements. Preferably, the preset resource allocation adjustment strategy in the preset resource allocation adjustment strategy set may include reducing the hardware service resource allocation percentage by 1%, reducing the hardware service resource allocation percentage by 5%, reducing the hardware service resource allocation percentage by 10%, retaining the hardware service resource allocation percentage, increasing the hardware service resource allocation percentage by 1%, increasing the hardware service resource allocation percentage by 5%, and increasing the hardware service resource allocation percentage by 10%.
[0069] The above is only a feasible implementation of step S300 provided in this embodiment, and this embodiment does not specifically limit the specific implementation of step S300.
[0070] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 Before step S200, the resource allocation method may further include steps S400 to S600:
[0071] Step S400, obtaining historical resource-related operation data of multiple microservices.
[0072] Step S500, determining the state space and action space of the deep reinforcement learning model based on historical resource-related operation data.
[0073] It should be noted that this embodiment converts the resource allocation problem of microservices into a Markov decision process, and uses the historical resource-related operation data of multiple microservices to build and train a deep reinforcement learning model to learn resource allocation actions.
[0074] The Markov decision process for resource allocation is defined as a tuple (S, A, p, r). Among them, S is the state space of the deep reinforcement learning model, A is the action space of the deep reinforcement learning model, p is the unknown state transition probability, and p:S×S×A→[0,∞) means that given the current state s t ∈S and the current action a t ∈A in the next state s t+1∈S probability density. r is the reward function, r:S×A→[r min ,r max ],r min is the minimum reward value, r max is the maximum reward value.
[0075] When building and training a deep reinforcement learning model, it is first necessary to determine the state space and action space of the deep reinforcement learning model. The implementation method of this embodiment for determining the state space and action space of the deep reinforcement learning model based on historical resource-related operation data is as follows.
[0076] In a feasible implementation manner, the historical resource-related operation data includes historical resource-related operation data within a plurality of historical time steps, and step S500 may include A510 to A550:
[0077] A510, for the historical resource-related operation data in each historical time step, determine the state characteristics of each microservice in the historical time step according to the historical resource-related operation data.
[0078] The state characteristic includes at least one of a delay characteristic and a request service characteristic.
[0079] It should be noted that, for historical resource-related operating data within a historical time step, the state characteristics of each microservice within the historical time step can be determined by analyzing the historical resource-related operating data.
[0080] A520, for each microservice, connect the state features within multiple historical time steps to obtain a state vector of the microservice.
[0081] A530, obtains the state space according to all state vectors.
[0082] It should be noted that for the microservice set M, the state space of the deep reinforcement learning model consists of the state vectors corresponding to each microservice m∈M. If each state vector has n state features, in order to calculate the state space, for each microservice, the state features within K historical time steps before the current moment can be connected to form a two-dimensional state vector s∈R M ×Kn , the state space constructed according to all state vectors can provide the deep reinforcement learning model with workload change information within the last K historical time steps.
[0083] A540, for each historical time step, generates an action vector according to the state characteristics of each microservice within the historical time step.
[0084] A550, obtains the action space based on all action vectors.
[0085] It should be noted that within t time steps, the action vector (i.e., the allocation action strategy) can be defined as a t ∈R M , The resource allocation strategy of a microservice is defined as u (i) is the upper limit of the hardware resources of the defined i-th microservice. The upper limit of the hardware resources of the microservice is manually defined in advance according to the actual usage requirements.
[0086] In the specific implementation, for each historical time step, the respective action scalars are generated according to the state characteristics of each microservice within the historical time step, and then the action scalars of multiple microservices within the historical time step are connected to a vector of length M to form an action vector.
[0087] Therefore, in this embodiment, when the number of microservices changes, the length of the state vector processed by the deep reinforcement learning model is fixed, so that the deep reinforcement learning model can adapt to the microservice framework with a variable number of microservices.
[0088] Step S600, constructing and training a deep reinforcement learning model according to a preset reward function, state space, and action space.
[0089] It should be noted that the preset reward function is preset according to actual usage.
[0090] In a feasible implementation, before step S600, the resource allocation method may further include: determining a preset reward function according to the end-to-end delays of the plurality of microservices and a preset delay threshold.
[0091] In this embodiment, the preset reward function is determined according to the end-to-end delay of multiple microservices and the preset delay threshold using the following formula 1; formula 1 is:
[0092]
[0093] r t is the reward at time step t, L t is the end-to-end delay in time step t, L QoS is the preset delay threshold, α is an adjustable hyperparameter, and a t-1 is the action vector within the t-1 time step, and u is the hardware resource upper limit vector of multiple microservices.
[0094] Among them, α represents the importance of meeting QoS requirements and is the positive weight of the positive incentive brought by saving hardware resources. A larger α will lead to the choice of saving more hardware resources and tolerate occasional QoS failures. On the contrary, a smaller α will make the return of saving hardware resources less, resulting in the choice of allocating higher hardware resources to avoid QoS failures. In the actual training process of the deep reinforcement learning model, the hyperparameter α is randomly searched and selected in [0.1, 1.0, 10.0].
[0095] It should be noted that the type of end-to-end delay can be determined according to actual usage requirements. Preferably, the end-to-end delay is a 99th percentile delay.
[0096] As can be seen from Formula 1, the reward at time step t is an explicit function of the action vector at time step t-1. When the 99th percentile delay L t Exceed QoS requirement L QoS When the delay is L, the reward is -1, which is the worst reward, which encourages the deep reinforcement learning model to meet the QoS requirements; t When QoS is met, the deep reinforcement learning model allocates less total hardware resources to multiple microservices, and the reward is close to the latency. Therefore, the deep reinforcement learning model is incentivized to meet QoS requirements while allocating as little total hardware resources as possible.
[0097] In a feasible implementation, step S600 may include steps A610 to A630:
[0098] Step A610, constructing an objective function according to a preset reward function and the expected entropy of the assigned action strategy.
[0099] In this embodiment, Formula 2 is used to construct the objective function according to the preset reward function and the expected entropy of the action allocation strategy; Formula 2 is:
[0100]
[0101] Among them, J is the objective function, E is the expectation, and p π To assign action strategy π to s t and a t distribution, β is a hyperparameter, and H(·) is the expected entropy.
[0102] Step A620, constructing an initial deep reinforcement learning model according to the preset reward function, state space and action space.
[0103] Step A630, based on the state space and the action space, with the goal of maximizing the objective function, update the model parameters of the initial deep reinforcement learning model to obtain the deep reinforcement learning model.
[0104] In this embodiment, the construction and training of a deep reinforcement learning model using a soft action-critic (SAC) algorithm is described.
[0105] The deep reinforcement learning model includes a policy network and a value network. Both the policy network and the value network can be fully connected networks. The policy network can include two fully connected layers, and the value network can include five fully connected layers. Each fully connected layer of the value network can include 256 hidden units.
[0106] The deep reinforcement learning model construction and training process can be as follows: construct an initial deep reinforcement learning model according to the state space and SAC algorithm, calculate the action vector according to the state space through the initial policy network of the initial deep reinforcement learning model, the policy network processes the M×n state matrix in each historical time step, generates an action scalar for each state vector of length n, and then connects the action scalars of multiple microservices in the historical time step to a vector of length M to form an action vector. Then, through the initial value network of the initial deep reinforcement learning model, calculate the action value of the action scalar of each microservice in the action vector, and according to the average action value of all action scalars in the action vector. Finally, with the goal of maximizing the objective function, update the model parameters of the initial deep reinforcement learning model to obtain the deep reinforcement learning model.
[0107] It should be noted that for each action scalar, a fully connected layer of the initial policy network generates a normal distribution mean scalar, and another fully connected layer generates a normal distribution standard deviation scalar, which is parameterized to obtain a normal distribution within a preset range and exponentiated to ensure that it is positive. During the construction and training of the deep reinforcement learning model, the action scalar of each microservice is sampled from the normal distribution, and during the use of the deep reinforcement learning model, the mean scalar is used to sample the action scalar.
[0108] In addition, it should be noted that after the policy network generates action scalars for multiple microservices, the multiple action scalars are connected into a vector and normalized by the sigmoid function to obtain the action vector.
[0109] This embodiment provides a resource allocation method. During the concurrent operation of multiple microservices, the actual hardware resource requirements of multiple microservices are dynamically determined according to the actual operation conditions of the multiple microservices, and hardware resources are allocated to each microservice, so that the computing resources of each microservice change with the changes in workload. Under the premise of ensuring QoS, it will not cause waste of hardware resources of the server where multiple microservices are located. It solves the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of hardware resources of the server, and improves the economy of the microservice framework. In addition, the deep reinforcement learning model of this application is also updated according to historical resource-related operation data, and can adapt to microservice frameworks with variable numbers of microservices.
[0110] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the resource allocation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0111] This application also provides a resource allocation device, please refer to Figure 3 , the resource allocation device may include:
[0112] The acquisition module 10 is used to obtain the current resource-related operation data of multiple microservices in the microservice framework; wherein the resource-related operation data includes at least one of the communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data and service request workload data;
[0113] A strategy generation module 20 is used to input the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a prediction allocation action strategy for hardware service resource allocation for multiple microservices;
[0114] The resource allocation module 30 is used to dynamically allocate resources to multiple microservices according to the predicted allocation action strategy.
[0115] The resource allocation device provided by the present application adopts the resource allocation method in the above embodiment, which can solve the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources. Compared with the relevant technology, the beneficial effects of the resource allocation device provided by the present application are the same as the beneficial effects of the resource allocation method provided by the above embodiment, and other technical features in the resource allocation device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0116] The present application provides a resource allocation device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein 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 so that the at least one processor can execute the resource allocation method in the above-mentioned embodiment 1.
[0117] Reference below Figure 4 , which shows a schematic diagram of the structure of a resource allocation device suitable for implementing the embodiment of the present application. The resource allocation device in the embodiment of the present application may include but is not limited to mobile terminals such as laptop computers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), etc., and fixed terminals such as desktop computers, etc. Figure 4 The resource allocation device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0118] like Figure 4 As shown, the resource allocation device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the xxx device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the resource allocation device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a resource allocation device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0119] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0120] The resource allocation device provided by the present application adopts the resource allocation method in the above embodiment, which can solve the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources. Compared with the related art, the beneficial effects of the resource allocation device provided by the present application are the same as the beneficial effects of the resource allocation method provided by the above embodiment, and the other technical features in the resource allocation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0121] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0122] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0123] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the resource allocation method in the above-mentioned embodiment.
[0124] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0125] The computer-readable storage medium may be included in the resource allocation device; or may exist independently without being assembled into the resource allocation device.
[0126] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the resource allocation device, the resource allocation device: obtains current resource-related operation data of multiple microservices in the microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data and service request workload data; inputs the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for hardware service resource allocation for multiple microservices; and dynamically allocates resources to multiple microservices according to the predictive allocation action strategy.
[0127] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0129] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0130] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned resource allocation method, and can solve the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of hardware resources of the server. Compared with the related art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the resource allocation method provided by the above-mentioned embodiment, and will not be repeated here.
[0131] The present application also provides a computer program product, including a computer program, which implements the steps of the resource allocation method as described above when executed by a processor.
[0132] The computer program product provided by the present application can solve the technical problem that each microservice under the microservice framework is usually configured with more computing resources, resulting in a large waste of server hardware resources. Compared with the related art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the resource allocation method provided in the above embodiment, and will not be repeated here.
[0133] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A resource allocation method, characterized in that: The method comprises: Obtaining current resource-related operation data of multiple microservices in a microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data, and service request workload data; Inputting the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a prediction allocation action strategy for allocating hardware service resources to the multiple microservices; Dynamically allocate resources to the plurality of microservices according to the predicted allocation action strategy.
2. The method according to claim 1, characterized in that Before the step of inputting the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a predictive allocation action strategy for allocating hardware service resources to the multiple microservices, the method further includes: Obtaining historical resource-related operation data of the multiple microservices; Determining the state space and action space of the deep reinforcement learning model according to the historical resource-related operation data; The deep reinforcement learning model is constructed and trained according to a preset reward function, the state space and the action space.
3. The method according to claim 2, characterized in that Before the step of constructing and training the deep reinforcement learning model according to the preset reward function, the state space and the action space, the method further includes: Constructing an objective function according to the preset reward function and the expected entropy of the allocation action strategy; The step of constructing and training the deep reinforcement learning model according to the preset reward function, the state space and the action space comprises: Constructing an initial deep reinforcement learning model according to the preset reward function, the state space, and the action space; According to the state space and the action space, with the goal of maximizing the objective function, the model parameters of the initial deep reinforcement learning model are updated to obtain the deep reinforcement learning model.
4. The method according to claim 2, characterized in that Before the step of constructing and training the deep reinforcement learning model according to the preset reward function, the state space and the action space, the method further includes: The preset reward function is determined according to the end-to-end delays of the multiple microservices and a preset delay threshold.
5. The method according to claim 2, characterized in that The historical resource-related operation data includes historical resource-related operation data within a plurality of historical time steps; The step of determining the state space and action space of the deep reinforcement learning model according to the historical resource-related operation data includes: For the historical resource-related operation data in each of the historical time steps, determine the state characteristics of each of the microservices in the historical time step according to the historical resource-related operation data; wherein the state characteristics include at least one of a delay characteristic and a request service characteristic; For each of the microservices, connecting the state features within a plurality of the historical time steps to obtain a state vector of the microservice; According to all the state vectors, the state space is obtained; For each of the historical time steps, generating an action vector according to the state characteristics of each of the microservices in the historical time step; The action space is obtained according to all the action vectors.
6. The method according to any one of claims 1 to 5, characterized in that: The step of dynamically allocating resources to the plurality of microservices according to the predicted allocation action strategy comprises: Determine a resource adjustment strategy for each of the microservices according to the current resource allocation state and the predicted allocation action strategy; Dynamically allocate resources to the multiple microservices according to all the resource adjustment strategies.
7. A resource allocation device, characterized in that: The device comprises: An acquisition module is used to acquire current resource-related operation data of multiple microservices in a microservice framework; wherein the resource-related operation data includes at least one of communication data between microservices, CPU on-chip memory utilization, CPU off-chip memory utilization, CPU utilization, CPU allocation information, IO device access data, delay distribution data, and service request workload data; A strategy generation module, configured to input the current resource-related operation data into a pre-built and trained deep reinforcement learning model to generate a prediction allocation action strategy for allocating hardware service resources to the multiple microservices; A resource allocation module is used to dynamically allocate resources to the plurality of microservices according to the predicted allocation action strategy.
8. A resource allocation device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the resource allocation method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the resource allocation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the resource allocation method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Resource management method and device, storage medium and program product
CN120085939A
Multi-application resource allocation method and device
CN120429125A
