Resource dynamic allocation method, device and server
By acquiring current resource utilization and historical information, the resource configuration of virtual desktops is dynamically adjusted, solving the problem of low resource utilization and achieving efficient resource utilization and conservation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEBANK (CHINA)
- Filing Date
- 2021-12-15
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, servers suffer from low resource utilization when deploying virtual desktops. In particular, resources are insufficient when facing heavy users and wasteful when facing light users, resulting in low resource utilization.
By obtaining the current resource utilization rate, and using a resource allocation model, the resource configuration of the virtual desktop, including memory, storage space and CPU resources, is dynamically adjusted according to preset thresholds. The resource allocation model is trained using machine learning algorithms, and the amount of resource adjustment is predicted based on current and historical usage information to achieve dynamic resource allocation.
It improves resource utilization, meets user needs, reduces performance waste, saves costs, and achieves a more balanced resource load in the context of global energy shortages.
Smart Images

Figure CN114168248B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a method, apparatus and server for dynamic resource allocation. Background Technology
[0002] With the development of cloud computing, more and more technologies are being applied in the financial sector, and the traditional financial industry is gradually transforming into financial technology (Fintech). For example, the application of Virtual Desktop Infrastructure (VDI) technology in work and life is becoming more and more widespread.
[0003] Currently, in traditional VDI deployments, servers typically distribute pre-packaged, fixed virtual desktop templates to users. Users can then use these templates to configure virtual machines and virtual desktops on cloud servers. Virtual machines built using these pre-packaged, fixed virtual desktop templates usually have the same resource configuration and performance.
[0004] However, virtual machines configured with fixed virtual desktop templates are prone to resource shortages when facing heavy users, while they can lead to resource waste when facing light users, resulting in low resource utilization of cloud servers. Summary of the Invention
[0005] This application provides a method, apparatus, and server for dynamic resource allocation to solve the problem of low resource utilization in the cloud in existing technologies.
[0006] In a first aspect, this application provides a method for dynamic resource allocation, the method being applied to a server, the server having multiple virtual desktops configured, the method comprising:
[0007] Obtain the resource utilization rate of the server at the current moment, and when the resource utilization rate is less than a first threshold, for each virtual desktop, input the current usage information of the virtual desktop at the current moment and the historical resource adjustment information of the previous moment into the resource allocation model to obtain the resource adjustment amount of the virtual desktop;
[0008] For each virtual desktop, the resources allocated to the virtual desktop are adjusted according to the resource adjustment amount of the virtual desktop.
[0009] Secondly, this application provides a resource dynamic allocation device, which is applied to a server, the server having multiple virtual desktops, and the device includes:
[0010] The acquisition module is used to obtain the resource utilization rate of the server at the current moment.
[0011] The processing module is configured to, when the resource occupancy rate is less than a first threshold, input the current usage information of the virtual desktop at the current moment and the historical resource adjustment information at the previous moment into the resource allocation model for each virtual desktop to obtain the resource adjustment amount of the virtual desktop; and adjust the resources allocated to the virtual desktop according to the resource adjustment amount of the virtual desktop for each virtual desktop.
[0012] Thirdly, this application provides a server, including: a memory and a processor;
[0013] The memory is used to store computer programs; the processor is used to execute the first aspect and any possible resource dynamic allocation method in the design of the first aspect according to the computer programs stored in the memory.
[0014] Fourthly, this application provides a readable storage medium storing a computer program, wherein when at least one processor of a server executes the computer program, the server executes the first aspect and any possible design of the first aspect of the dynamic resource allocation method.
[0015] Fifthly, this application provides a computer program product comprising a computer program that, when at least one processor of a server executes the computer program, enables the server to execute the first aspect and any possible design of the first aspect of the dynamic resource allocation method.
[0016] The resource dynamic allocation method provided in this application obtains the resource occupancy rate at the current moment; obtains a preset first threshold; compares the first threshold with the resource occupancy rate; when the resource occupancy rate is less than the first threshold, inputs the current usage information of each virtual desktop at the current moment and the historical usage information of the previous moment into the resource allocation model to obtain the resource adjustment amount for each virtual desktop; after calculating the resource adjustment amount for each virtual desktop in the server, the method adjusts the resources allocated to the virtual desktop according to the resource adjustment amount, thereby realizing the effect of adjusting the resources of virtual desktops according to the actual usage information at different times, rather than using the same template resource configuration for all virtual desktops, thus improving the utilization rate of various resources in the server. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1This application provides an illustration of a server and a virtual desktop application scenario according to an embodiment of the present application.
[0019] Figure 2 A schematic diagram of the structure of a server and a virtual desktop provided in an embodiment of this application;
[0020] Figure 3 A flowchart illustrating a method for dynamic resource allocation according to an embodiment of this application;
[0021] Figure 4 This is a schematic diagram of the structure of a resource allocation model provided in an embodiment of this application;
[0022] Figure 5 A flowchart illustrating the training process of a resource allocation model provided in one embodiment of this application;
[0023] Figure 6 A flowchart illustrating a method for dynamic resource allocation according to an embodiment of this application;
[0024] Figure 7 A schematic diagram of the structure of a resource dynamic allocation device provided in an embodiment of this application;
[0025] Figure 8 This is a schematic diagram of the hardware structure of a server provided in one embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] The terms "first," "second," "third," "fourth," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be used interchangeably where appropriate. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms, unless the context indicates otherwise.
[0028] It should be further understood that the terms “comprising” or “including” indicate the presence of features, steps, operations, elements, components, items, kinds, and / or groups, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups.
[0029] The terms “or” and “and / or” as used herein are interpreted as inclusive, or mean any one or any combination thereof. Therefore, “A, B, or C” or “A, B, and / or C” means “any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C”. Exceptions to this definition occur only when combinations of elements, functions, steps, or operations are inherently mutually exclusive in some way.
[0030] With the development and advancement of computer technology, terminal devices are increasingly widely used in work and life. Especially in the workplace, the application of various office software on terminal devices has made office work increasingly inseparable from them. In the current office environment, users' offices are typically equipped with desktop computers. Users usually install office software on their office desktop computers, and office data is also stored on this terminal device. However, when users need to travel for business or work from home, they usually need to reinstall office software on other terminal devices or copy office data in advance, which is very inconvenient.
[0031] With the development of cloud computing, the use of VDI technology has greatly improved the above-mentioned problems. Users can deploy a virtual desktop in the cloud using desktop virtualization technology. This virtual desktop is equivalent to a virtual machine running in the cloud. Users can access this virtual desktop remotely. Users can store office data and install office software in this virtual desktop. Furthermore, users only need to install an application on their current terminal device to remotely access the virtual desktop through that application. Whether users are working in the office, at home, or traveling for business, they can carry out normal office work through this virtual desktop, which is very convenient.
[0032] Currently, in traditional VDI deployments, servers typically distribute pre-packaged, fixed virtual desktop templates to users. These templates usually include pre-defined resource configuration parameters. Users can use these templates to configure virtual machines and virtual desktops on cloud servers. However, these fixed templates are often configured with a general, adaptable approach. Therefore, virtual desktops configured using these templates may experience low resource utilization for both heavy and light users. For example, for heavy users, the configured resources may not meet their needs, leading to decreased work efficiency. Conversely, for light users who only use the virtual desktop for daily office work, the actual resource usage may be less than the configured resources, resulting in performance overkill.
[0033] Clearly, existing virtual desktop templates suffer from poor applicability to diverse user needs. However, in existing technologies, once a virtual desktop template is packaged, its preset resource configuration parameters cannot be changed. If a user has specific performance requirements, a new virtual desktop template needs to be packaged according to those requirements. In practice, packaging a personalized virtual desktop template for each user is impractical. Furthermore, if a user's usage habits change due to various objective factors, the resources required will also change. For example, in the first half of the year, a user might need to perform large-scale data processing, requiring significant resources to ensure high virtual desktop performance, while in the second half of the year, the user's main work might be document editing, requiring only a small amount of resources. Therefore, allocating fixed resources to each virtual desktop on a server is clearly unreasonable. To address this, this application proposes a dynamic resource allocation method. This application adds a dynamic adjustment module to the virtual desktop template, allowing the server to dynamically adjust the resources within the virtual desktop after configuring its resources using the template, thus improving the intelligence of virtual desktop resource allocation.
[0034] In this application, the server can obtain the current resource utilization rate. When the resource utilization rate is less than a first threshold, the server can determine that there are still sufficient resources available for allocation to each virtual desktop in subsequent use. For each virtual desktop, the server can input the current resource utilization information of the virtual desktop at the current moment and the historical utilization information of the previous moment into the resource allocation model to obtain the resource adjustment amount for that virtual desktop. The server can adjust the resources allocated to the virtual desktop according to the resource adjustment amount. The resource allocation model can be a model learned using a neural network. Through this method, the server can dynamically adjust the performance resources of each virtual desktop, achieving the goal of both meeting the user's performance requirements for virtual desktops and reducing unnecessary performance waste, greatly improving resource utilization and saving costs. Furthermore, from a broader perspective, given the increasingly tense global energy situation, dynamically adjusting templates to make user resource load more balanced is also a contribution to environmental protection.
[0035] Furthermore, when the resource utilization rate is greater than or equal to a first threshold, the server load is too high. The server can ensure sufficient resource margin for stable operation by reducing the resource allocation for each virtual desktop. For each virtual desktop, the server can determine the resource reduction amount for each virtual desktop based on the current usage information of all virtual desktops at the current moment and the historical usage information within a first preset time period. The server can then reduce the resources allocated to each virtual desktop based on the resource reduction amount.
[0036] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0037] Figure 1 This diagram illustrates an application scenario of a server and virtual desktops according to an embodiment of this application. As shown, the server is located in the cloud. The server may include multiple virtual desktops. Each virtual desktop may correspond to a user account. Users can remotely control the virtual desktops through terminal devices. The server may also include a control module. This control module is used to create, delete, and dynamically configure virtual desktops on the server.
[0038] In one implementation, a user can install an application on a terminal device and log in to their user account through the application's interactive interface, thereby enabling remote control of the virtual desktop corresponding to that user account.
[0039] In one implementation, a user can open multiple interactive interfaces on a terminal device. The user can log in to a user account on each interactive interface to remotely control a virtual desktop.
[0040] In one implementation, a user can log in to a single user account on different terminal devices to remotely control the virtual desktop associated with that account. To ensure the security of the virtual desktop, a user account can only be logged in on one terminal device at a time.
[0041] In one implementation, the cloud may include a server cluster consisting of multiple servers. This server cluster may include a control server. The control server is used to control the creation, deletion, and dynamic configuration of virtual desktops on other servers in the server cluster.
[0042] Figure 2 A schematic diagram of a server and virtual desktop according to an embodiment of this application is shown. As shown, the server may include at least one virtual desktop and a control module.
[0043] The virtual desktop may include a basic module and a scaling module. The basic module contains fixed resources allocated to the virtual desktop. When the virtual desktop only contains the basic resources of the basic module, it will not continue to scale down. The scaling module contains dynamically adjustable resources. These resources can be one or more of memory resources, storage space resources, and CPU resources. The scaling module may also include a data acquisition / monitoring unit and an execution unit.
[0044] The acquisition / monitoring unit collects resource usage information from the virtual desktop. This information may include memory usage, storage space usage, CPU usage, and the number of times memory, storage, and CPU performance exceed their limits, creating bottlenecks. The acquisition / monitoring unit sends this information to the judgment unit of the control module. The execution unit then obtains the resource adjustment amount generated by the judgment unit and adjusts the resources in the expansion module accordingly. This adjustment may involve expanding or shrinking the virtual memory resource, ensuring that the virtual desktop's resources meet the user's personalized needs while avoiding unnecessary resource waste. Each resource adjustment amount indicates an adjustment to a specific resource. When multiple resources in the virtual desktop require dynamic adjustment, the execution unit obtains multiple resource adjustment amounts from the judgment unit. For example, when the resources include memory resources, storage space resources, and CPU resources, the execution unit obtains the resource adjustment amount of the memory resources and adjusts the memory resources in the virtual desktop according to the resource adjustment amount of the memory resources; the execution unit obtains the resource adjustment amount of the storage space resources and adjusts the storage space resources in the virtual desktop according to the resource adjustment amount of the storage space resources; the execution unit obtains the resource adjustment amount of the CPU resources and adjusts the CPU resources in the virtual desktop according to the resource adjustment amount of the CPU resources.
[0045] The control module may include a judgment unit and a training unit. The training unit uses machine learning algorithms to train a resource allocation model. One resource allocation model can correspond to one type of resource. When multiple resources on the server require dynamic adjustment, the training module can train a resource allocation model for each type of resource. The training unit can then send this resource allocation model to the judgment unit. The judgment unit can input usage information collected by the acquisition / monitoring unit into the resource allocation model to predict the resource adjustment amount. For example, when the resources include memory, storage space, and CPU resources, the judgment unit can input the memory resource allocation model to obtain the memory resource adjustment amount; the storage space resource allocation model to obtain the storage space resource adjustment amount; and the CPU resource allocation model to obtain the CPU resource adjustment amount. The judgment unit can then send this resource adjustment amount to the execution unit of the expansion module. The use of this training unit and judgment unit makes the entire expansion / shrinkage process dynamic and intelligent, which greatly improves the timeliness and accuracy compared to the existing manual operation.
[0046] In this application, a server is used as the execution entity to perform the resource dynamic allocation method of the following embodiments. Specifically, the execution entity can be a server hardware device, a software application implementing the following embodiments on the server, a computer-readable storage medium installed with the software application implementing the following embodiments, or code implementing the software application.
[0047] Figure 3 A flowchart illustrating a dynamic resource allocation method according to an embodiment of this application is shown. Figure 1 and Figure 2 Based on the illustrated embodiments, as Figure 3 As shown, with the server as the execution entity, the method in this embodiment may include the following steps:
[0048] S101. Obtain the current resource utilization rate of the server.
[0049] In this embodiment, the server can obtain the current resource utilization rate. This resource utilization rate is the ratio of the sum of resources allocated to each virtual desktop to the server's total resources. That is, once the server allocates a resource to a virtual desktop, it is considered occupied regardless of whether the virtual desktop uses the resource. For example, if the server's total memory resources are 100, and the server includes 3 virtual desktops, and the server allocates 20 memory resources to each of the three virtual desktops, then 60% of the server's memory resources are occupied. The memory resource utilization rate is 60%. For example, when the resources include memory resources, storage space resources, and CPU resources, the server needs to calculate the resource utilization rate for each of the three parameters separately.
[0050] S102. When the resource utilization rate is less than the first threshold, for each virtual desktop, input the current usage information of the virtual desktop at the current moment and the historical usage information of the previous moment into the resource allocation model to obtain the resource adjustment amount of the virtual desktop.
[0051] In this embodiment, the server can obtain a preset first threshold. For each type of resource, the server can preset different first thresholds. The server can compare the first threshold and resource utilization rate of the same resource. For example, when the resource is a memory resource, the server can compare the first threshold and resource utilization rate of the memory resource. Similarly, when the resource includes memory resources, storage space resources, and CPU resources, the server can compare the first threshold and resource utilization rate of the memory resource; compare the first threshold and resource utilization rate of the storage space resource; and compare the first threshold and resource utilization rate of the CPU resource.
[0052] When the resource utilization rate of a certain resource is less than a first threshold, that resource on the server is sufficient, and each virtual desktop can dynamically allocate that resource according to actual needs. The server can dynamically adjust each resource of each virtual desktop using resource adjustment amounts. This dynamic adjustment can include resource expansion or resource reduction. For example, when the memory resource utilization rate is less than the first threshold, the server can calculate the memory resource adjustment amount for each virtual desktop according to the following steps. Similarly, when the memory resource utilization rate is less than the first threshold for memory resources, and the CPU resource utilization rate is less than the first threshold for CPU resources, the server uses the following steps to calculate the memory resource adjustment amount and the CPU resource adjustment amount for each virtual desktop, respectively.
[0053] When a server determines that it needs to calculate the resource adjustment amount for a resource within a virtual desktop, it can input the current usage information of that resource at the current moment and its historical usage information from the previous moment into the resource allocation model to predict the possible usage information of the virtual desktop at the next moment. Based on the predicted possible usage information of the virtual desktop at the next moment and the current usage information, the server can determine the resource adjustment amount for the current moment.
[0054] Among them, the current usage information at the current moment is as follows: Figure 1 The data acquisition / monitoring unit shown represents the parameters collected in real-time at the current moment. The historical usage information for the previous moment is the parameter stored on the server by the data acquisition / monitoring unit. For example, when the resource is memory, this usage information may include memory utilization and the number of times memory performance exceeds its limit, resulting in bottlenecks. The predicted usage information for the next moment includes parameters that correspond to those in the current usage information. For example, if the current usage parameters include memory utilization and the number of times memory performance exceeds its limit, the predicted usage information will also include these parameters.
[0055] In one example, the resource allocation model may include an input module and an output module. The input module may include a first weight and a second weight.
[0056] In this example, the server can train a neural network model using machine learning algorithms. This neural network model is the resource allocation model. Because the intensity and frequency of user usage of the virtual desktop can vary significantly, this resource allocation model incorporates current usage information and historical usage information from the previous moment to make judgments, avoiding the limitations of using only current data. This resource allocation model can be implemented as follows: Figure 4 As shown. Where X t-1This is historical usage information from the previous moment. X t This represents the current usage information at the current moment. Here, t indicates the current moment, and t-1 indicates the previous moment. The server can use this resource allocation model to predict the resource usage information H for the next moment. t The input and output modules can be as follows: Figure 4 As shown. This input module may include a reset gate and an update gate. The reset gate may include a first weight W. r The update gate may include a second weight W. u .
[0057] In one example, when the server has multiple resources requiring predicted resource adjustments, the server can calculate the resource adjustment amount for each resource based on its resource allocation model. For instance, when both memory and CPU resources require predicted resource adjustments, the server can input the current and historical usage information of the memory resource into the resource allocation model and calculate its resource adjustment amount; similarly, the server can input the current and historical usage information of the CPU resource into the resource allocation model and calculate its resource adjustment amount. The specific process by which the server calculates the resource adjustment amount for the virtual desktop may include:
[0058] Step 1: Use the input module to process the current usage information at the current moment, the historical usage information at the previous moment, and the first weight to determine the first parameter.
[0059] In this step, the server will display the current usage information X at the current moment. t Historical usage information X from the previous moment t-1 And the first weight W r Processing this is equivalent to changing the currently used information X. t and historical usage information X t-1 Enter the reset gate. Within this reset gate, the server can determine the current usage information X. t Historical usage information X t-1 And the first weight W r The input parameters are calculated. These input parameters can be represented as W. r *[X t-1 X t The server can input this input parameter into the reset gate function f(x) to calculate the first reset history information R at the current moment. t .
[0060] The function f(x) can be expressed as:
[0061]
[0062] The function f(x) outputs values in the interval [0,1].
[0063] Among them, the first reset history information R at the current moment t The calculation formula can be expressed as:
[0064] R t =f(W r *[X t-1 X t ])
[0065] When the first reset history information R at the current moment is calculated t Afterwards, the server can also... t Inputting the data into a hyperbolic tangent function g(x) yields the first parameter H′ after filtering out invalid data. t .
[0066] The hyperbolic tangent function g(x) can be expressed as:
[0067]
[0068] Among them, the resource adjustment weight H′ at the current moment t The calculation formula can be expressed as:
[0069] H′ t =g(Wr·[R t *H t-1 X t ])
[0070] For example, the current usage information X at the current moment. t It can include 8 parameters, the current usage information X t It can be represented as X t ={x1 t x2 t x3 t x4 t x5 t x6 t x7 t x8 t The historical usage information X from the previous moment. t-1 It also includes 8 parameters, this historical usage information X t-1 It can be represented as X t-1 ={x1 t-1 x2 t-1 x3 t-1 x4 t-1 x5 t-1 x6 t-1 x7 t-1 x8 t-1}
[0071] Assume that x1 t With x1 t-1 x8 t With x8 t-1 There is a significant difference; x2 t With x2 t-1 x3 t With x3 t-1 x5 t With x5 t-1 The difference is small; x4 t With x4 t-1 x6 t With x6 t-1 x7 t With x7 t-1 There is no difference.
[0072] In one possible calculation, R can be obtained. t ={1, 0.4, 0.7, 0, 2, 0, 0, 1}.
[0073] R t After inputting g(x), H′ can be calculated. t ={x1 t 0.4x2 t 0.7x3 t 0, 2x5 t ,0,0,x8 t}
[0074] Step 2: Use the input module to process the current usage information at the current moment, the historical usage information at the previous moment, and the second weight to determine the second parameter.
[0075] In this step, the server will display the current usage information X at the current moment. t Historical usage information X from the previous moment t-1 Second weight W u Processing this is equivalent to changing the currently used information X. t and historical usage information X t-1 Enter the update gate. Within this update gate, the server can access information based on the current usage information X. t Historical usage information X t-1 Second weight W u The input parameters are calculated. These input parameters can be represented as W. u *[X t-1 X t The server can input this input parameter into the update gate function f(x) to calculate the second reset history information U at the current time. t The second reset history information Ut This is the second parameter. Specifically, it refers to the second reset history information U at the current moment. t The calculation formula can be expressed as:
[0076] U t =f(W u *[X t-1 X t ])
[0077] For example, in one possible calculation, the calculated second reset history information U t For U t ={1,0,0,0,0,0,0,1}.
[0078] Step 3: Input the first and second parameters into the output module to predict the information to be used in the next moment.
[0079] In this step, the server can input the first and second parameters calculated in the previous steps into the output module. The output module can then process the second parameter U... t The indicated valid data to be obtained, based on the first parameter H′ t The prediction information H is used to obtain the prediction for the next time step. t Since the information used for predicting the next time step is always predicted at the current time step, the index of this information is t. The information used for predicting the next time step is H. t The calculation formula can be:
[0080] H t =(1-U t )×X t-1 +U t ×X t
[0081] For example, X given in the example of the steps above. t X t-1 and U t H can be calculated t The value of H. t ={x1 t x2 t-1 x3 t-1 x4 t-1 x5 t-1 x6 t-1 x7 t-1 x8 t}
[0082] Step 4: Determine the amount of resource adjustment for the virtual desktop based on the current usage information and the predicted usage information for the next moment.
[0083] In this step, the server compares the current usage information with the predicted usage information to determine if there is a discrepancy. If there is no discrepancy, the server does not need to adjust the resources for the virtual desktop. The adjustment amount can be 0. If the current usage is less than the predicted usage, the virtual desktop may require more resources in the next moment. The adjustment amount can instruct the server to expand the resources for the virtual desktop to ensure its normal operation. If the current usage is greater than the predicted usage, the virtual desktop may require fewer resources in the next moment. The adjustment amount can instruct the server to reduce the resources for the virtual desktop to avoid resource waste.
[0084] The server can subtract each parameter from the predicted usage information and the current usage information one by one. The server can calculate the difference for each parameter. The server determines these differences as the usage information difference. For example, if the current usage information is X... t ={x1 t x2 t x3 t x4 t x5 t x6 t x7 t x8 t}, the predicted usage information is H t ={h1 t h2 t h3 t h4 t h5 t h6 t h7 t h8 t Using information difference C t It can be represented as:
[0085] C t ={h1 t -x1 t h2 t -x2 t h3 t -x3 t h4 t -x4 t h5 t -x5 t h6 t -x6 t h7-x7 t h8 t -x8 t}
[0086] The server can pre-define a weight for each parameter in the usage information. The server can calculate the weighted sum of each parameter in the usage information difference. The server can use this weighted sum as the final resource adjustment amount. The current resource adjustment amount ΔZ t The calculation formula can be expressed as:
[0087] ΔZ t =w1(h1) t -x1 t )+w2(h2 t -x2 t )+w3(h3 t -x3 t )+w4(h4 t -x4 t +w5(h5 t -x5 t )+w6(h6 t -x6 t )+w7(h7 t -x7 t )+w8(h8 t -x8 t )
[0088] Among them, w1, w2, w3, w4, w5, w6, w7, and w8 are the weights of each parameter in the usage information preset in the server.
[0089] It's important to note that the number of parameters included in the usage information may differ for different resources. The weight of each parameter for each resource is determined based on practical experience. When the server needs to scale down the virtual desktop, the resource adjustment amount ΔZ is... t Less than 0. This resource adjustment amount ΔZ occurs when the server needs to expand the capacity of this virtual desktop. t Greater than 0.
[0090] S103. For each virtual desktop, adjust the resources allocated to the virtual desktop according to the resource adjustment amount of the virtual desktop.
[0091] In this embodiment, after calculating the resource adjustment amount for each virtual desktop on the server, the server can adjust the resources allocated to each virtual desktop based on the resource adjustment amount. When the server determines that a certain resource is in sufficient quantity, the server can calculate the resource adjustment amount for that resource for each virtual desktop on the server through the above steps. Since different virtual desktops have different usage patterns, different resource adjustment amounts can correspond to different virtual desktops.
[0092] For example, if a server includes virtual desktops 1, 2, and 3, and the resource that needs adjustment for virtual desktop 1 is memory, the server can calculate that the memory resource adjustment amount for virtual desktop 1 is 10, for virtual desktop 2 it's 8, and for virtual desktop 3 it's 15. The server then adjusts the memory resources of each virtual desktop according to these adjusted amounts.
[0093] In one example, each resource of each virtual desktop can have a lower limit and a higher limit. When the adjusted allocation of a resource in a virtual desktop is less than the lower limit or greater than the higher limit, the allocation of that resource to the virtual desktop is determined based on the lower or higher limit.
[0094] For example, a virtual desktop currently has 15 memory resources, with a lower limit of 10 and a higher limit of 20. When the resource adjustment amount for this virtual desktop indicates a reduction of 3 memory resources, the server can adjust the virtual desktop's memory resources from 15 to 12. When the resource adjustment amount for this virtual desktop indicates a reduction of 7 memory resources, the server can adjust the virtual desktop's memory resources from 15 to 10. When the resource adjustment amount for this virtual desktop indicates an increase of 3 memory resources, the server can adjust the virtual desktop's memory resources from 15 to 18. When the resource adjustment amount for this virtual desktop indicates an increase of 10 memory resources, the server can adjust the virtual desktop's memory resources from 15 to 20.
[0095] The resource dynamic allocation method provided in this application allows the server to obtain the current resource occupancy rate. The server can also obtain a preset first threshold. The server can compare the first threshold with the resource occupancy rate. When the resource occupancy rate is less than the first threshold, the server can input the current usage information of each virtual desktop at the current moment and the historical usage information from the previous moment into the resource allocation model to obtain the resource adjustment amount for each virtual desktop. After calculating the resource adjustment amount for each virtual desktop in the server, the server can adjust the resources allocated to that virtual desktop according to the resource adjustment amount. In this application, by calculating the resource adjustment amount for each resource in each virtual desktop, the allocation amount of each type of resource for each virtual desktop in the server is dynamically adjusted, thereby improving the utilization rate of various resources in the server.
[0096] Figure 5 A flowchart illustrating a dynamic resource allocation method according to an embodiment of this application is shown. Figures 1 to 4 Based on the illustrated embodiments, as Figure 5As shown, with the server as the execution entity, the training process of the resource allocation model in this embodiment may include the following steps:
[0097] S201, Initialize the first and second weights.
[0098] In this embodiment, the server can extract personalized parameters for each virtual desktop by inputting existing data and usage data obtained through the acquisition / monitoring module into a machine learning model. The server can then use these personalized parameters to achieve personalized management of various resources on the virtual desktops. In actual use, different users typically have different usage intensities and frequencies when using virtualized desktops. Therefore, to achieve personalized management, the server can generate a resource allocation model for each virtual desktop to achieve personalized resource management for that user. Furthermore, considering that different resources are not highly correlated in use, the server can also generate different resource allocation models for different resources of a single virtual desktop to improve the accuracy of dynamic resource allocation. This resource allocation model can be used to preset the resource usage of the virtual desktop at the next moment.
[0099] For a user, the intensity and frequency of virtualized desktop usage will vary at different times. Since user usage is continuous, there may be implicit correlations between the temporal usage information for a single user. Therefore, adjusting the system solely based on current usage information has limitations. To address this, this application introduces a memory training model to train the resource allocation model. During model training, the resource allocation model feeds back its learning results to the judgment module. The judgment module can then continuously optimize the resource allocation model based on these learning results.
[0100] The resource allocation model mainly includes a first weight and a second weight. The server can train the model to obtain the first and second weights for a specific resource of a virtual desktop based on its historical usage information over a second preset time period. Before training the first and second weights, preparatory work for training the resource allocation model may include:
[0101] Step 1: The server retrieves historical usage information for all virtual desktops within a second preset time period. This second preset time period can be a period determined by the user based on their actual needs. For example, it could be historical usage data for one month, from March 1st to March 31st. Or, if the current time is October 15th, the second time period could be historical usage data for 10 days, from October 5th to the current time.
[0102] Step 2: The server determines the historical usage information for each resource of each virtual desktop from this historical usage information. This historical usage information is time-series data. For example, when the resource is memory, the historical usage information may include memory usage rate and the number of times memory performance exceeds the limit, resulting in bottlenecks. The memory usage rate can be data collected by the acquisition / monitoring unit at each moment. The number of times memory performance exceeds the limit can be data obtained by the acquisition / monitoring unit at fixed periods. This fixed period is the time from the first moment to the second moment. The first moment and the second moment are two consecutive moments.
[0103] Step 3: The server initializes the first and second weights. The initial values of the first and second weights can be two random numbers in the range of 0 to 1.
[0104] S202. Repeatedly calculate the predicted usage information for each moment based on the first weight, the second weight, and the historical usage information within the second preset time period. Determine the adjustment difference based on the historical usage information and the predicted usage information for each moment. When the adjustment difference is greater than or equal to the second threshold, update the first weight and the second weight based on the current learning coefficient. Continue until the adjustment difference is less than the second threshold, then output the first weight and the second weight.
[0105] In this embodiment, after the server completes the preparation work for training the resource allocation model, the training process of the first weight and the second weight in the resource allocation model may specifically include:
[0106] Step 1: Calculate the predicted usage information for each moment based on the first weight, the second weight, and the historical usage information within the second preset time period.
[0107] In this step, the server can obtain historical usage information for the first and second moments within the second preset time period. The first and second moments are two consecutive moments within the second preset time period. The server can use the historical usage information for the second moment as the current usage information and the historical usage information for the first moment as the previous historical usage information, inputting these into the resource allocation model. The server can then use this resource allocation model to predict the usage information for the next moment corresponding to the second moment. For ease of statistical analysis, in this embodiment, the predicted usage information for the next moment corresponding to the second moment is referred to as the predicted usage information for the second moment.
[0108] When the second preset time period includes n moments, the historical usage information within the second preset time period can be recorded as X1, X2, ..., X... nThe server can input n-1 consecutive pairs of times within the second preset time period into the resource allocation model to obtain n-1 predicted usage information. This n-1 predicted usage information can be denoted as H2, H3, ..., H... n .
[0109] Step 2: Determine the adjustment difference based on the historical usage information and predicted usage information at each moment.
[0110] In this step, the actual usage information corresponding to n-2 of the n-1 predicted usage information is found in the historical usage information of the second preset time period. For example, H2 corresponds to X3, H3 corresponds to X4, ..., H n-1 Corresponding to X n The server can calculate the adjustment difference based on the predicted usage information and its corresponding actual usage information. The formula for calculating the adjustment difference D is:
[0111]
[0112] When H i and X i+1 When multiple parameters are included, for example, X i+1 ={x1 i+1 x2 i+1 x3 i+1}, H i ={h1 i h2 i h3 i}. D i The calculation formula can be expressed as:
[0113] D i =(x1) i+1 -h1 i ) 2 +(x2 i+1 -h2 i ) 2 +(x3 i+1 -h3 i ) 2
[0114] When the adjustment difference D approaches 0, it indicates that the predicted usage information obtained by the resource allocation model is close to the actual usage information. Otherwise, when the adjustment difference D is large, it indicates that the predicted usage information obtained by the resource allocation model differs significantly from the actual usage information.
[0115] Step 3: When the adjustment difference is greater than or equal to the second threshold, update the first and second weights according to the weight adjustment step size, and return to Step 1. When the adjustment difference is less than the second threshold, output the first and second weights.
[0116] In this step, the server can obtain a second threshold. This second threshold can be a value close to 0. The actual value of the second threshold can be determined empirically. The server can compare the adjustment difference with the second threshold. When the adjustment difference is less than the second threshold, it indicates that the prediction accuracy of the resource allocation model meets the requirements. The server can then end the loop and output the first and second weights. Otherwise, when the adjustment difference is greater than or equal to the second threshold, it indicates that the preset usage information predicted by the resource allocation model differs significantly from the actual usage information, and the resource allocation model needs further optimization. The server can adjust the first and second weights using the weight adjustment step size.
[0117] In one example, the server may include a first weight adjustment step size and a second weight adjustment step size. The first weight adjustment step size can be used to adjust a first weight. The second weight adjustment step size can be used to adjust a second weight.
[0118] In one example, the weight adjustment step size Δw can be determined by both the learning coefficient δ and the derivative of D(W). The weight adjustment step size Δw can be expressed as:
[0119]
[0120] The learning coefficient δ is mainly used to control the size of the stride Δw in order to adjust the training time and training accuracy.
[0121] The learning coefficient δ can be dynamically adjusted during model training. A single dynamic adjustment of the learning coefficient δ may include the following steps:
[0122] Step 1: Initialize the learning coefficient δ1 using the default value. The initial adjustment step size corresponding to this initial learning coefficient δ1 can be represented as Δw1. When using this initial adjustment step size, the number of adjustments required to bring the adjustment difference D to converge is T1.
[0123] Step 2: Generate a new domain {0.5δ1, 1.5δ1} based on the learned parameter δ1. This new domain will serve as the adjustment domain for the new learned parameter.
[0124] Step 3: Calculate the adjustment steps Δwmin and Δwmax corresponding to the learning coefficients at both ends of the adjustment domain, and the adjustment times Tmin and Tmax corresponding to the learning coefficients at both ends. Comparing Tmin, T1, and Tmax may result in three cases: 1) Tmin <T1<Tmax;2)T1<Tmin;3)T1> Tmax. The service can choose to execute one of steps 4 through 6 depending on the situation.
[0125] Step 4: When Tmin < T1 < Tmax, the optimal solution of the learning coefficient δ1 is in the adjustment domain {0.5δ1, 1.5δ1}. The server can obtain the optimal solution of the learning coefficient δ1 by traversing the adjustment domain {0.5δ1, 1.5δ1}.
[0126] Step 5: When T1 < Tmin, the optimal solution of the learning coefficient δ1 is not in the adjustment domain {0.5δ1, 1.5δ1}. The server needs to update the learning parameter δ1. The update process of the learning parameter δ1 can be shown by the following formula:
[0127] δ1 = 0.5 × δ1
[0128] After calculating the new learning parameter δ1, the server can jump to Step 2 and continue to loop and execute this iterative process.
[0129] Step 6: When T1 > Tmax, the optimal solution of the learning coefficient δ1 is not in the adjustment domain {0.5δ1, 1.5δ1}. The server needs to update the learning parameter δ1. The update process of the learning parameter δ1 can be shown by the following formula:
[0130] δ1 = 1.5 × δ1
[0131] After calculating the new learning parameter δ1, the server can jump to Step 2 and continue to loop and execute this iterative process.
[0132] For the resource dynamic allocation method provided in this application, the server can initialize the first weight and the second weight. The server can loop and execute the process of calculating the predicted usage information at each moment according to the first weight, the second weight, and the historical usage information within the second preset time period; determining the adjustment difference according to the historical usage information and the predicted usage information at each moment; when the adjustment difference is greater than or equal to the second threshold, the server can update the first weight and the second weight according to the weight adjustment step until the adjustment difference is less than the second threshold. When the adjustment difference is less than the second threshold, the server can output the first weight and the second weight. In this application, through training iterations, the training of the first weight and the second weight is realized, and the calculation accuracy of the resource adjustment amount in each dynamic adjustment process is improved.
[0133] Figure 6 shows a flowchart of a resource dynamic allocation method provided by an embodiment of this application. Based on Figures 1 to 5 the embodiment, as Figure 6 shown, with the server as the execution entity, the method of this embodiment may include the following steps:
[0134] S301: Obtain the resource occupancy rate of the server at the current moment.
[0135] Among them, Step S301 and Figure 2 The implementation of step S101 in the embodiment is similar, and will not be repeated here.
[0136] S302. When the resource utilization rate is greater than or equal to the first threshold, for each virtual desktop, the resource reduction amount for each virtual desktop is determined based on the current usage information of all virtual desktops on the server at the current moment and the historical usage information within the first preset time period.
[0137] In this embodiment, the server can obtain a preset first threshold. For each type of resource, the server can preset different first thresholds. The server can compare the first threshold and resource utilization rate of the same resource. For example, when the resource is memory, the server can compare the first threshold and the resource utilization rate of memory. Similarly, when the resource includes memory, storage space, and CPU resources, the server can compare the first threshold and the resource utilization rate of memory; compare the first threshold and the resource utilization rate of storage space; and compare the first threshold and the resource utilization rate of CPU. When the resource utilization rate of any resource is greater than or equal to the first threshold, that resource on the server is under strain. To ensure the system stability of the server, the server needs to reduce the utilization rate of that resource for each virtual desktop.
[0138] In one example, the process by which the server calculates the resource reduction for each virtual desktop may include the following steps:
[0139] Step 1: Based on the historical usage information of all virtual desktops on the server within the first preset time period, divide the virtual desktops into primary virtual desktops and advanced virtual desktops.
[0140] In this step, before determining the reduction amount for each user, the server needs to categorize virtual desktops. The server can divide virtual desktops into two types: primary virtual desktops and advanced virtual desktops. Advanced virtual desktops will not participate in the reduction. The calculation process for the resource reduction amount of these advanced virtual desktops can be as shown in step 3. The reduction task will be undertaken by the remaining primary virtual desktops.
[0141] In one implementation, the server can determine whether each virtual desktop belongs to the advanced virtual desktop category based on memory resource usage. The determination process may include the following steps:
[0142] Step 1.1: The server can obtain memory usage information for each virtual desktop within a first preset time period. This memory usage information may include the memory usage rate of the virtual desktop at each moment, and the number of times the virtual desktop has been throttled from the previous moment to the current moment. The first preset time period can be a period determined by the user according to actual needs. For example, historical usage data for one month from March 1st to March 31st. Or, if the current time is October 15th, the first time period could be historical usage data for 10 days from October 5th to the current time.
[0143] Step 1.2: The server can determine the average memory usage of each virtual desktop within the first preset time period based on the memory usage at each moment within that time period. This average memory usage... The calculation formula can be:
[0144]
[0145] in, This represents the average memory usage of the j-th virtual desktop on the server. The first preset time period includes n moments. Where a... ji This represents the memory usage of the j-th virtual desktop at the i-th moment in the server.
[0146] Step 1.3: The server determines the first memory usage rate corresponding to the upper quartile based on the average memory usage rate of all virtual desktops on the server. The server then determines a third threshold based on this first memory usage rate. Virtual desktops with an average memory usage rate greater than the third threshold are added to the first virtual desktop set.
[0147] For example, the server may include 8 virtual desktops, and the average memory usage of these 8 virtual desktops may be as shown in Table 1.
[0148] Table 1
[0149] Virtual Desktop 1 2 3 4 5 6 7 8 Average memory usage 23% 85% 44% 67% 59% 40% 92% 75% Number of times the rate is limited 7 9 3 6 20 7 10 21
[0150] Table 2 can be obtained by sorting the eight virtual memory locations by their average memory usage.
[0151] Table 2
[0152] Virtual Desktop 1 6 3 5 4 8 2 7 Average memory usage 23% 40% 44% 59% 67% 75% 85% 92%
[0153] According to the formula for calculating the position of the upper quartile Q3, P3 = (n+1)*0.75, when n=8, the position of the upper quartile Q3 is calculated to be P3 = (8+1)*0.75 = 6.75. Therefore, the upper quartile Q3 can be calculated as 85%*0.75 + 75%*0.25 = 82.5%. This upper quartile Q3 is the first memory utilization rate.
[0154] The server can determine a third threshold based on the first memory usage rate. For example, the server can determine that the third threshold is the product of the first memory usage rate and a first preset parameter. The first preset parameter can be 1, 2, 0.5, etc. This first preset parameter can be determined based on empirical values. When the first preset parameter is 1, the server can determine that the third threshold is 82.5%.
[0155] The server can compare the average memory usage of each virtual desktop with the third threshold. Of the eight virtual desktops, virtual desktop 2 has an average memory usage of 85%, which is greater than the third threshold. Virtual desktop 7 has an average memory usage of 92%, which is also greater than the third threshold. Therefore, the first set of virtual desktops includes virtual desktop 2 and virtual desktop 7.
[0156] Step 1.4: Count the number of times each virtual desktop has its memory throttling limit within the first preset time period. Determine the average number of times memory throttling limits are applied to all virtual desktops on the server. Add virtual desktops with memory throttling limits exceeding the average number of times memory throttling limits are added to the second virtual desktop set.
[0157] In this step, the server can count the number of times each virtual desktop is rate-limited within a first preset time period. For example, when the server can include 8 virtual desktops, the average memory usage of these 8 virtual desktops can be shown in Table 1.
[0158] The server can calculate the average number of times it has been subject to memory throttling. The formula for calculating the average number of times memory throttling has been subject to memory throttling is as follows:
[0159]
[0160] in, This specifies the average number of memory rate limits applied to this server. This server can include m virtual desktops. ra j This is used to represent the number of rate limits for the j-th virtual desktop.
[0161] For example, the calculation process of the average number of memory throttling attempts for the 8 virtual desktops shown in Table 1 can be expressed as (7+9+3+6+20+7+10+21) / 8=10.375.
[0162] The server can determine a fourth threshold based on the average number of times memory throttling occurs on the server. For example, the server can determine that the fourth threshold is the product of the average number of times memory throttling occurs and a second preset parameter. The second preset parameter can be 1, 2, 0.5, etc. This second preset parameter can be determined based on empirical values. For example, when the second preset parameter is 2, the server can determine that the fourth threshold is 20.7.
[0163] The server can compare the memory throttling attempts of each virtual desktop with this fourth threshold. For example, among the eight virtual desktops shown in Table 1, virtual desktop 8 has more than the fourth threshold for memory throttling attempts. Therefore, virtual desktop 8 is included in the second set of virtual desktops.
[0164] Step 1.5: Determine the virtual desktops in the intersection of the first and second virtual desktop sets as advanced virtual desktops. Determine all virtual desktops on the server other than advanced virtual desktops as primary virtual desktops.
[0165] In this step, after obtaining the first set of virtual desktops and the second set of virtual desktops, the server can calculate the intersection of the first set of virtual desktops and the second set of virtual desktops. That is, the server can filter out virtual desktops from the first set of virtual desktops and the second set of virtual desktops that simultaneously meet the judgment conditions in steps 1.3 and 1.4. The server can determine that the virtual desktops in this intersection are advanced virtual desktops. The server can determine that the virtual desktops other than the already determined advanced virtual desktops are primary virtual desktops. For example, the 8 virtual desktops in Table 1 above are all primary virtual desktops.
[0166] In one implementation, the server can further determine that users in the first set of virtual desktops are heavy virtual desktop users. For example, among the eight virtual desktops in Table 1 above, virtual desktops 2 and 7 are heavy virtual desktops. The remaining six virtual desktops are primary virtual desktops.
[0167] In another implementation, the server can determine whether each virtual desktop belongs to the advanced virtual desktop category based on storage space resource or CPU resource usage information. This usage information can include storage space utilization rate, CPU utilization rate, the number of times storage space performance exceeds its limit resulting in a bottleneck, and the number of times CPU performance exceeds its limit resulting in a bottleneck. The process for determining this usage information is similar to that for memory resources and will not be elaborated further here.
[0168] In another implementation, the server can determine whether each virtual desktop is an advanced virtual desktop based on at least two of the following resources: storage resources, storage space resources, or CPU resources. The server can determine that a virtual desktop is an advanced virtual desktop if at least two of its resources indicate that the virtual desktop is an advanced virtual desktop.
[0169] In another implementation, the server can determine whether each virtual desktop is an advanced virtual desktop based on at least two of the following resources: storage resources, storage space resources, or CPU resources. The server can determine that a virtual desktop is an advanced virtual desktop if one of its resources indicates that the virtual desktop is an advanced virtual desktop.
[0170] Step 2: When the virtual desktop is a primary virtual desktop, determine the resource reduction amount of the virtual desktop based on the current usage information of all primary virtual desktops on the server at the current moment and the historical usage information within the first preset time period.
[0171] In this step, the server can assess the resource requirements of the virtual desktops using variance.
[0172] In one implementation, the usage information includes memory usage. When the virtual desktop is a primary virtual desktop, the resource reduction amount for the virtual desktop is determined based on the current usage information of all primary virtual desktops on the server at the current moment and the historical usage information within a first preset time period. Specifically, this includes:
[0173] Step 2.1: Determine the memory usage variance of each primary virtual desktop within the first preset time period based on the memory usage rate of each primary virtual desktop within the first preset time period.
[0174] In this step, the server can calculate the memory variance of the memory resource based on the memory usage at various times within the first preset time period. The formula for calculating the memory variance Sa is as follows:
[0175]
[0176] Among them, Sa j This represents the variance of memory resources for the j-th virtual desktop on the server. n indicates that the first preset time period includes n moments. a ji This represents the memory usage rate of the j-th virtual desktop on the server at the i-th moment within the first preset time period. This represents the average memory usage of the j-th virtual desktop on the server during the first preset time period.
[0177] Step 2.2: Determine the reduction ratio based on the ratio of the memory usage variance of the primary virtual desktops to the sum of the memory usage patterns of all primary virtual desktops on the server.
[0178] In this step, the server does not reduce resources for advanced virtual desktops. Resource reduction is entirely handled by primary virtual desktops. Therefore, the server can calculate the sum of memory variances for all primary virtual desktops. For example, when the server has m virtual desktops, and only virtual desktop 8 is an advanced virtual desktop, the sum of memory variances Ssum for all primary virtual desktops can be expressed as:
[0179]
[0180] Based on the sum of the memory variances Ssum of all primary virtual desktops and one virtual desktop, the server can calculate the reduction ratio of that virtual desktop. This reduction ratio can be expressed as:
[0181]
[0182] Step 2.3: Determine the amount of resource reduction for the primary virtual desktop based on its current memory usage and reduction ratio.
[0183] In this step, when the j-th virtual desktop in the server is a primary virtual desktop, the resource reduction amount Δa for the j-th virtual desktop is... j The calculation formula can be expressed as:
[0184]
[0185] In another implementation, the server can calculate the resource reduction for each primary virtual desktop based on storage space resource or CPU resource usage information. This usage information can include storage space utilization, CPU utilization, the number of times storage performance exceeds its limit resulting in a bottleneck, and the number of times CPU performance exceeds its limit resulting in a bottleneck. The calculation process for this usage information is similar to that for memory resources and will not be elaborated further here.
[0186] Step 3: When the virtual desktop is an advanced virtual desktop, ensure that the resource reduction of the virtual desktop is zero.
[0187] S303. For each virtual desktop, reduce the resources allocated to the virtual desktop according to the resource reduction amount of the virtual desktop.
[0188] In this embodiment, after calculating the resource reduction amount for each virtual desktop on the server, the server can reduce the resources allocated to each virtual desktop according to the resource reduction amount. When the server determines that a resource is in a state of shortage, in order to ensure the use of that resource on the server, the server usually needs to reduce the resource for all virtual desktops. Since the usage of different virtual desktops is different, different resource reduction amounts can be applied to different virtual desktops.
[0189] For example, when a server includes virtual desktops 1, 2, and 3, and the server detects a shortage of memory resources, it can calculate that the memory resource reduction for virtual desktop 1 is 0, for virtual desktop 2 it is 10, and for virtual desktop 3 it is 20. The server then reduces the memory resources of each virtual desktop according to these reduction amounts.
[0190] In one example, each resource of each virtual desktop can have a resource minimum. When the scaled-down allocation of a resource in a virtual desktop is less than the resource minimum, the allocation of that resource to the virtual desktop is determined based on the resource minimum.
[0191] For example, a virtual desktop currently has 15 memory resources, and the minimum memory resource limit for that virtual desktop is 10. When the resource reduction amount for that virtual desktop's memory resources indicates a reduction of 3, the server can adjust the virtual desktop's memory resources from 15 to 12. When the resource reduction amount for that virtual desktop's memory resources indicates a reduction of 7, the server can adjust the virtual desktop's memory resources from 15 to 10.
[0192] Because this server can include various resources, including multiple virtual desktops, the types of resources that need to be reduced may differ for different desktops. For example, virtual desktop 1 may need to reduce its memory resources. The server can calculate the required reduction amount for virtual desktop 1's memory resources and then reduce those resources accordingly. Similarly, virtual desktop 2 may need to reduce its memory and CPU resources. The server can calculate the required reduction amounts for both memory and CPU resources for virtual desktop 2 and then reduce those resources accordingly.
[0193] The resource dynamic allocation method provided in this application allows the server to obtain the current resource occupancy rate. The server can also obtain a preset first threshold. The server can compare the first threshold with the resource occupancy rate. When the resource occupancy rate is greater than or equal to the first threshold, the server can determine the resource reduction amount for each virtual desktop based on the current usage information of all virtual desktops on the server and their historical usage information within a first preset time period. After calculating the resource reduction amount for each virtual desktop on the server, the server can reduce the resources allocated to each virtual desktop according to the resource reduction amount. In this application, by calculating the resource reduction amount for each virtual desktop and reducing the resources allocated to each virtual desktop, the intelligence of virtual desktop resource allocation is improved, and the stability of the server is enhanced.
[0194] Based on the above embodiments, in addition to determining the first threshold based on user experience, the server can also dynamically analyze the first threshold according to the user profile through the following steps. The specific calculation steps may include:
[0195] Step 1: The server retrieves historical usage information within a third preset time period. This historical usage information may include multiple parameters for each resource. For example, it may include memory usage, storage space usage, CPU usage, the number of times memory performance exceeded its limit, the number of times storage space performance exceeded its limit, and the number of times CPU performance exceeded its limit.
[0196] Step 2: The server calculates the user profile for each virtual desktop based on its historical usage information.
[0197] For example, the user profile of the j-th virtual desktop on this server can be represented as:
[0198]
[0199] in, Sa represents the average memory usage of the j-th virtual desktop on this server during the third preset time period. j Let ra be the memory variance of the j-th virtual desktop during the third preset time period. j This refers to the number of times the j-th virtual desktop's memory resources are limited during the third preset time period, i.e., the number of times performance exceeds the upper limit and a bottleneck occurs. Sb represents the average storage space utilization of the j-th virtual desktop on this server during the third preset time period. j Let rb be the storage space variance of the j-th virtual desktop during the third preset time period. j The number of times the storage space resources of the j-th virtual desktop are limited during the third preset time period. Sc represents the average CPU utilization of the j-th virtual desktop on this server during the third preset time period. j Let be the CPU variance of the j-th virtual desktop during the third preset time period. j The number of times the CPU resources of the j-th virtual desktop are limited during the third preset time period.
[0200] Step 3: Set the minimum resource requirements for each non-advanced virtual desktop on the server.
[0201] In this step, for non-premium virtual desktops, the server calculates their minimum resource requirements based on the minimum performance requirements of each virtual desktop. The server can use a resource allocation model to predict the usage information of each non-premium virtual desktop under the user's minimum tolerance limit. The server can use the usage information corresponding to the moment with the most rate throttling attempts as the current usage information, and then predict the usage information. This predicted usage information is the minimum performance requirement for the non-premium virtual desktop.
[0202] The server calculates the minimum performance requirements for each non-premium virtual desktop. Then, it sums these minimum performance requirements to obtain the minimum resource requirements for all non-premium virtual desktops on the server.
[0203] For example, when the resource is a memory resource, the minimum resource requirement A for the non-advanced virtual desktops of the server is accumulated. min The calculation formula can be expressed as:
[0204]
[0205] Among them, amin j This represents the minimum memory performance requirement for the j-th virtual desktop.
[0206] When the resource is storage space, the server can also calculate B using the above method. min When the resource is CPU, the server can also calculate C using the above method. min .
[0207] Step 4: The server accumulates the resource requirements for each advanced virtual desktop.
[0208] In this step, for advanced virtual desktops, it's necessary to ensure that their performance remains unaffected even when resource thresholds are reached. Therefore, the resource requirements of each advanced virtual desktop are the resource demands of that virtual desktop at the current moment. For example, the server can accumulate the memory resources of the advanced virtual desktops to obtain A. vip Storage space resources and for B vip CPU resources and C vip .
[0209] Step 5: Calculate the first threshold based on the total resources in the server.
[0210] In this step, the first threshold is the difference between the available resources on the server and the minimum resource requirements for non-advanced virtual desktops and the resource requirements for advanced virtual desktops.
[0211] For example, when the resource is a memory resource, the formula for calculating the first threshold is:
[0212] μ=θ×A T -A vip -A min
[0213] Among them, A T θ represents the total memory resources of the server. θ is the impact factor. The default value for this impact factor is 1. Alternatively, the value of this impact factor can be set according to actual needs. This impact factor is mainly used to address different requirements. For example, when the server requires high availability, to ensure that all virtual desktops on the server can still function normally even if only half of the memory resources are available in extreme cases, this impact factor can be defined as 0.5.
[0214] Figure 7 This application provides a schematic diagram of the structure of a resource dynamic allocation device according to an embodiment of the present application. Figure 7 As shown, the resource dynamic allocation device 10 of this embodiment is used to implement the operation corresponding to the server in any of the above method embodiments. The resource dynamic allocation device 10 of this embodiment includes:
[0215] Module 11 is used to obtain the current resource utilization rate of the server.
[0216] Processing module 12 is used to, when the resource occupancy rate is less than a first threshold, input the current usage information of the virtual desktop at the current moment and the historical resource adjustment information at the previous moment into the resource allocation model for each virtual desktop to obtain the resource adjustment amount for the virtual desktop. For each virtual desktop, the resources allocated to the virtual desktop are adjusted according to the resource adjustment amount.
[0217] In one example, the processing module 12 is further configured to, when the resource utilization rate is greater than or equal to a first threshold, determine the resource reduction amount for each virtual desktop based on the current usage information of all virtual desktops on the server at the current moment and the historical usage information within a first preset time period. Then, for each virtual desktop, the resources allocated to the virtual desktop are reduced according to the resource reduction amount.
[0218] In one example, the resource allocation model includes an input module and an output module. The input module includes a first weight and a second weight.
[0219] Processing module 12 is specifically used to process the current usage information at the current moment, the historical usage information at the previous moment, and the first weight using the input module to determine the first parameter. It then processes the current usage information at the current moment, the historical usage information at the previous moment, and the second weight using the input module to determine the second parameter. The first and second parameters are input to the output module to predict the predicted usage information for the next moment. Based on the current usage information at the current moment and the predicted usage information for the next moment, the resource adjustment amount for the virtual desktop is determined.
[0220] In one example, the processing module 12 is further configured to input the historical usage information of all virtual desktops of the server within a second preset time period into the resource allocation model, and train it to obtain the first weight and the second weight.
[0221] In one example, processing module 12 is specifically used to initialize a first weight and a second weight. It repeatedly calculates the predicted usage information for each moment based on the first weight, the second weight, and historical usage information within a preset time period. An adjustment difference is determined based on the historical and predicted usage information for each moment. When the adjustment difference is greater than or equal to a second threshold, the first and second weights are updated according to the weight adjustment step size. The process continues until the adjustment difference is less than the second threshold, at which point the first and second weights are output.
[0222] In one example, processing module 12 is specifically used to classify virtual desktops into primary virtual desktops and advanced virtual desktops based on the historical usage information of all virtual desktops on the server within a first preset time period. When a virtual desktop is a primary virtual desktop, the resource reduction amount for the virtual desktop is determined based on the current usage information of all primary virtual desktops on the server at the current moment and the historical usage information within the first preset time period. When a virtual desktop is an advanced virtual desktop, the resource reduction amount for the virtual desktop is determined to be zero.
[0223] In one example, processing module 12 is specifically configured to: determine the average memory usage of each virtual desktop within a first preset time period based on the memory usage of each virtual desktop at each moment within that time period; determine the first memory usage corresponding to the upper quartile based on the average memory usage of all virtual desktops on the server; determine a third threshold based on the first memory usage; add virtual desktops with average memory usage greater than the third threshold to a first virtual desktop set; count the number of memory rate limiting attempts for each virtual desktop within the first preset time period, and determine the average number of memory rate limiting attempts based on the total number of memory rate limiting attempts for all virtual desktops on the server; determine a fourth threshold based on the average number of memory rate limiting attempts; add virtual desktops with memory rate limiting attempts greater than the fourth threshold to a second virtual desktop set; identify the virtual desktops in the intersection of the first and second virtual desktop sets as advanced virtual desktops; and identify all virtual desktops on the server other than advanced virtual desktops as primary virtual desktops.
[0224] In one example, the usage information includes memory usage rate. Processing module 12 is specifically used to determine the memory usage variance of each primary virtual desktop within the first preset time period, based on the memory usage rate of each primary virtual desktop on the server at each moment within the first preset time period. It then determines the reduction ratio based on the ratio of the memory usage variance of the primary virtual desktops to the sum of the memory usage patterns of all primary virtual desktops on the server. Finally, it determines the resource reduction amount for each primary virtual desktop based on its memory usage rate and the reduction ratio at the current moment.
[0225] The resource dynamic allocation device 10 provided in this application embodiment can execute the above method embodiment. Its specific implementation principle and technical effect can be found in the above method embodiment, and will not be repeated here.
[0226] Figure 8 A schematic diagram of the hardware structure of a server provided in an embodiment of this application is shown. Figure 8 As shown, the server 20 is used to implement the operations corresponding to the server in any of the above method embodiments. The server 20 in this embodiment may include: a memory 21, a processor 22, and a communication interface 24.
[0227] The memory 21 is used to store computer programs. The memory 21 may include high-speed random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0228] Processor 22 is used to execute computer programs stored in memory to implement the resource dynamic allocation method in the above embodiments. For details, please refer to the relevant descriptions in the foregoing method embodiments. The processor 22 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0229] Alternatively, the memory 21 can be either standalone or integrated with the processor 22.
[0230] When the memory 21 is a device independent of the processor 22, the server 20 may also include a bus 23. This bus 23 is used to connect the memory 21 and the processor 22. The bus 23 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0231] The communication interface 24 can be connected to the processor 21 via the bus 23. This communication interface is used to enable interaction between the user terminal and the server.
[0232] The server provided in this embodiment can be used to execute the above-described dynamic resource allocation method. Its implementation and technical effects are similar, and will not be described again here.
[0233] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, is used to implement the methods provided in the various embodiments described above.
[0234] The computer-readable storage medium can be a computer storage medium or a communication medium. A communication medium includes any medium that facilitates the transfer of a computer program from one location to another. A computer storage medium can be any available medium accessible to a general-purpose or special-purpose computer. For example, a computer-readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the computer-readable storage medium. Of course, the computer-readable storage medium can also be a component of the processor. The processor and the computer-readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the ASIC can reside in a user equipment. Of course, the processor and the computer-readable storage medium can also exist as discrete components in a communication device.
[0235] Specifically, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0236] This application also provides a computer program product comprising a computer program stored in a computer-readable storage medium. At least one processor of the device can read the computer program from the computer-readable storage medium, and the at least one processor executes the computer program to cause the device to implement the methods provided in the various embodiments described above.
[0237] This application also provides a chip including a memory and a processor. The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that a device with the chip installed performs the methods described in the various possible implementations above.
[0238] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0239] The modules can be physically separate, for example, installed in different locations within a single device, installed on different devices, distributed across multiple network units, or distributed across multiple processors. Alternatively, the modules can be integrated, for example, installed in the same device, or integrated into a single codebase. The modules can exist in hardware form, software form, or a combination of both. This application can select some or all of the modules to achieve the objectives of this embodiment based on actual needs.
[0240] When the various modules are implemented as integrated software functional modules, they can be stored in a computer-readable storage medium. The aforementioned software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application.
[0241] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0242] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for dynamic resource allocation, characterized in that, Applied to a server, wherein multiple virtual desktops are configured, the method includes: Obtain the resource utilization rate of the server at the current moment, and when the resource utilization rate is less than a first threshold, for each virtual desktop, input the current usage information of the virtual desktop at the current moment and the historical resource adjustment information of the previous moment into the resource allocation model to obtain the resource adjustment amount of the virtual desktop; For each virtual desktop, adjust the resources allocated to the virtual desktop according to the resource adjustment amount of the virtual desktop; The resource allocation model includes an input module and an output module; the input module includes a first weight and a second weight. The step of inputting the current usage information of the virtual desktop at the current moment and the historical resource adjustment information from the previous moment into the resource allocation model to obtain the resource adjustment amount of the virtual desktop includes: The input module is used to process the current usage information at the current moment, the historical usage information at the previous moment, and the first weight to determine the first parameter; The input module is used to process the current usage information at the current moment, the historical usage information at the previous moment, and the second weight to determine the second parameter; The first parameter and the second parameter are input into the output module to predict the usage information for the next moment. Based on the current usage information at the current moment and the predicted usage information at the next moment, the resource adjustment amount of the virtual desktop is determined; The usage information includes memory usage rate and the number of times memory flow was limited.
2. The method according to claim 1, characterized in that, The method further includes: When the resource utilization rate is greater than or equal to the first threshold, for each virtual desktop, the resource reduction amount for each virtual desktop is determined based on the current usage information of all virtual desktops on the server at the current moment and the historical usage information within the first preset time period. For each virtual desktop, the resources allocated to that virtual desktop are reduced according to the resource reduction amount of that virtual desktop.
3. The method according to claim 1 or 2, characterized in that, The method further includes: The historical usage information of all virtual desktops on the server within a second preset time period is input into the resource allocation model to train and obtain the first weight and the second weight.
4. The method according to claim 3, characterized in that, The step of inputting the historical usage information of all virtual desktops on the server within a second preset time period into the resource allocation model to train and obtain the first weight and the second weight specifically includes: Initialize the first and second weights; Repeatedly calculate the predicted usage information for each moment based on the first weight, the second weight, and the historical usage information within the second preset time period; determine the adjustment difference based on the historical usage information and the predicted usage information for each moment; when the adjustment difference is greater than or equal to the second threshold, update the first weight and the second weight according to the weight adjustment step; until the adjustment difference is less than the second threshold, output the first weight and the second weight.
5. The method according to claim 2, characterized in that, The step of determining the resource reduction amount for virtual desktops based on the current usage information of all virtual desktops on the server at the current moment and the historical usage information within a first preset time period includes: Based on the historical usage information of all the virtual desktops on the server within a first preset time period, the virtual desktops are divided into primary virtual desktops and advanced virtual desktops; When the virtual desktop is a primary virtual desktop, the resource reduction amount of the virtual desktop is determined based on the current usage information of all primary virtual desktops on the server at the current moment and the historical usage information within a first preset time period. When the virtual desktop is an advanced virtual desktop, the resource reduction amount of the virtual desktop is determined to be zero.
6. The method according to claim 5, characterized in that, The step of classifying virtual desktops into primary virtual desktops and advanced virtual desktops based on the historical usage information of all virtual desktops on the server within a first preset time period specifically includes: Based on the memory usage rate of each virtual desktop in the server at each moment within a first preset time period, determine the average memory usage rate of each virtual desktop within the first preset time period. Based on the average memory usage of all virtual desktops on the server, determine the first memory usage corresponding to the upper quartile; determine a third threshold based on the first memory usage; add virtual desktops with average memory usage greater than the third threshold to the first virtual desktop set; The number of times each virtual desktop experiences memory throttling within a first preset time period is counted. Based on the total number of times memory throttling is performed on all virtual desktops on the server, the average number of times memory throttling is determined. A fourth threshold is determined based on the average number of times memory throttling is performed. Virtual desktops with memory throttling counts greater than the fourth threshold are added to a second virtual desktop set. The virtual desktops in the intersection of the first virtual desktop set and the second virtual desktop set are identified as advanced virtual desktops; the other virtual desktops in all the virtual desktops of the server, excluding the advanced virtual desktops, are identified as primary virtual desktops.
7. The method according to claim 5, characterized in that, The usage information includes memory usage rate; when the virtual desktop is a primary virtual desktop, the resource reduction amount of the virtual desktop is determined based on the current usage information of all primary virtual desktops on the server at the current moment and the historical usage information within a first preset time period, specifically including: Based on the memory usage rate of each primary virtual desktop on the server at each moment within a first preset time period, the memory usage variance of each primary virtual desktop within the first preset time period is determined. The reduction ratio is determined based on the ratio of the memory usage variance of the primary virtual desktops to the sum of the memory usage patterns of all the primary virtual desktops on the server. The resource reduction amount of the primary virtual desktop is determined based on the memory usage and reduction ratio of the primary virtual desktop at the current moment.
8. A server, characterized in that, The server includes: a memory and a processor; The memory is used to store computer programs; the processor is used to implement the resource dynamic allocation method as described in any one of claims 1-7 according to the computer programs stored in the memory.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, is used to implement the resource dynamic allocation method as described in any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the resource dynamic allocation method according to any one of claims 1-7.