Resource scheduling method and device
By dynamically allocating tasks based on resource recycling priorities and available resource amounts, the problem that the load balancing algorithm cannot recycle idle resources is solved, and efficient resource utilization and waste reduction are achieved.
Patent Information
- Application Number
- CN202010214015.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-24
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-03-24
AI Technical Summary
Existing load balancing algorithms cannot effectively recycle idle resources when the resource cluster load is low, resulting in resource waste.
By obtaining the current available resource amount of each resource in the resource cluster, determining its recycling priority, and dynamically allocating tasks based on the recycling priority and available resource amount when receiving new tasks, to maximize resource utilization when the load is high, Gradually reclaim idle resources when load is low.
It maximizes resource utilization when the resource cluster load is high, and recycles idle resources when the load is low, reducing waste and making scheduling more in line with expected requirements.
Smart Images

Figure CN113448715B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a resource scheduling method and device. Background Art
[0002] Today, with the widespread application of cluster technology, a variety of load balancing algorithms have emerged to make full use of cluster resources, including polling, random method, source address hash method, weighted polling method, weighted random method, least connection method, etc. Different load balancing algorithms can meet the needs of resource load balancing in different application scenarios.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: the current load balancing algorithms are all based on how to fully utilize resources, that is, to distribute the load in the resource cluster, but do not consider the recycling and reuse of resources. When the overall load of the resource cluster is small, idle resources cannot be recycled, resulting in a certain waste of resources. For example, taking the polling method as an example, when there are multiple resources in the resource cluster, the load will be balanced to all different resources. If some resources are recycled from them, the objects that are being served by the recycled resources will be affected. If some resources are not recycled, all resources in the resource cluster will always be kept running at the same time, which to a certain extent causes a great waste of resources. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a resource scheduling method that can schedule resources based on the current available resource quantity, recycling priority, etc., so as to maximize the utilization of resources when the resource cluster load is high, and gradually recycle idle resources when the resource cluster load is low.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a resource scheduling method is provided, comprising:
[0006] Get the current available resource amount of each resource in the resource cluster;
[0007] Determining the recycling priority of the resource according to the current available resource amount of the resource;
[0008] When a new task allocation request is received, the new task is allocated to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources.
[0009] Optionally, it also includes:
[0010] Before determining the recycling priority of the resource according to the current available resource amount of the resource, adjusting the current available resource amount of the resource according to the current available resource amount, a first preset weight of the resource, and a second preset weight of the resource, wherein the first preset weight indicates the expected recycling priority of the resource, and the second preset weight indicates the inherent configuration performance of the resource;
[0011] The resource recycling priority is determined according to the adjusted current available resource amount.
[0012] Optionally, allocating the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources includes:
[0013] Calculating the current available resource amount of the resource cluster according to the current available resource amount of each resource;
[0014] Predicting the current available resource amount of the resource cluster at a next moment according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments;
[0015] Determine a change trend of the current available resource amount of the resource cluster according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at a next moment;
[0016] According to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources, new tasks are allocated to one or more of the resources.
[0017] Optionally, allocating new tasks to one or more of the resources according to a change trend of the current available resource amount of the resource cluster and a recycling priority of the resources includes:
[0018] When the change trend of the current available resource amount of the resource cluster is stable, load balancing the newly added task to one or more of the resources;
[0019] When the current available resource amount of the resource cluster has an increasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources;
[0020] When the current available resource amount of the resource cluster has a decreasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources.
[0021] Optionally, it also includes:
[0022] When the current available resource amount of the resource cluster has a decreasing trend, adding one or more new resources to the resource cluster;
[0023] Allocate the newly added task to one or more of the new resources.
[0024] Optionally, it also includes:
[0025] When the current available resource amount of the resource cluster has an increasing trend, one or more of the resources with a high recovery priority are recovered from the resource cluster.
[0026] Optionally, in the case where the resource is a server, the currently available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, input / output;
[0027] Or when the resource is any one or more of a central processing unit, memory, disk space, and input / output, the current available resource amount correspondingly indicates: the available amount of the central processing unit, the available amount of memory, the available amount of disk space, and the available amount of input / output.
[0028] Or, in the case where the resource is a service provider that provides services, the currently available resource amount indicates the amount of services that can still be provided by the service provider.
[0029] To achieve the above object, according to another aspect of an embodiment of the present invention, a resource scheduling device is provided, comprising: a current available resource quantity acquisition module, a recycling priority determination module, and a resource scheduling module; wherein,
[0030] The currently available resource amount acquisition module is used to acquire the currently available resource amount of each resource in the resource cluster;
[0031] The recycling priority determination module is used to determine the recycling priority of the resource according to the current available resource amount of the resource;
[0032] The resource scheduling module is used to allocate the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources when receiving the new task allocation request.
[0033] Optionally, the recycling priority determination module is further configured to:
[0034] Before determining the recycling priority of the resource according to the current available resource amount of the resource, adjusting the current available resource amount of the resource according to the current available resource amount, a first preset weight of the resource, and a second preset weight of the resource, wherein the first preset weight indicates the expected recycling priority of the resource, and the second preset weight indicates the inherent configuration performance of the resource;
[0035] The resource recycling priority is determined according to the adjusted current available resource amount.
[0036] Optionally, allocating the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources includes:
[0037] Calculating the current available resource amount of the resource cluster according to the current available resource amount of each resource;
[0038] Predicting the current available resource amount of the resource cluster at a next moment according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments;
[0039] Determining a change trend of the current available resource amount of the resource cluster according to the current service capacity of the resource cluster and the current available resource amount of the resource cluster at the next moment;
[0040] According to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources, new tasks are allocated to one or more of the resources.
[0041] Optionally, allocating new tasks to one or more of the resources according to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources includes:
[0042] When the change trend of the current available resource amount of the resource cluster is stable, load balancing the newly added task to one or more of the resources;
[0043] When the current available resource amount of the resource cluster has an increasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources;
[0044] When the current available resource amount of the resource cluster has a decreasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources.
[0045] Optionally, the resource scheduling module is further used to:
[0046] When the current available resource amount of the resource cluster has a decreasing trend, adding one or more new resources to the resource cluster;
[0047] Allocate the newly added task to one or more of the new resources.
[0048] Optionally, the resource scheduling module is further used to:
[0049] When the current available resource amount of the resource cluster has an increasing trend, one or more of the resources with a high recovery priority are recovered from the resource cluster.
[0050] Optionally, in the case where the resource is a server, the currently available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, input / output;
[0051] Or when the resource is any one or more of a central processing unit, memory, disk space, and input / output, the current available resource amount correspondingly indicates: the available amount of the central processing unit, the available amount of memory, the available amount of disk space, and the available amount of input / output.
[0052] Or, in the case where the resource is a service provider that provides services, the currently available resource amount indicates the amount of services that can still be provided by the service provider.
[0053] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device for resource scheduling, characterized in that it comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described in the resource scheduling method above.
[0054] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the resource scheduling methods described above is implemented.
[0055] An embodiment of the above invention has the following advantages or beneficial effects: the resource recovery priority and the current available resource amount of the resource cluster are determined by the current available resource amount of the resource, so that when there are new tasks, the new tasks are dynamically allocated according to the resource recovery priority and the changing trend of the current available resource amount of the resource cluster, so as to maximize the utilization of resources when the resource cluster load is high, and gradually recover idle resources when the resource cluster load is low; in addition, the current available resource amount of the resource can be adjusted in combination with the first preset weight and the second preset weight of the resource, that is, the expected recovery priority of the resource, the inherent configuration performance of the resource, etc., so that the adjusted current available resource amount of the resource can more truly and effectively reflect the current available resource amount of the resource, so that resource scheduling is more in line with expected requirements.
[0056] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0058] Figure 1 is a schematic diagram of the main process of the resource scheduling method according to an embodiment of the present invention;
[0059] Figure 2 is a schematic diagram of the main process of another resource scheduling method according to an embodiment of the present invention;
[0060] Figure 3 is a schematic diagram of the main process of the method for allocating new tasks according to an embodiment of the present invention;
[0061] Figure 4 is a schematic diagram of main modules of a resource scheduling device according to an embodiment of the present invention;
[0062] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0063] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0064] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0065] Figure 1 is a schematic diagram of the main process of the resource scheduling method according to an embodiment of the present invention, such as Figure 1 As shown, the resource scheduling method may specifically include the following steps:
[0066] Step S101, obtaining the current available resource amount of each resource in the resource cluster.
[0067] A resource can be any one or more of a server, a central processing unit, memory, disk space, input / output, a service provider, etc., and a resource cluster is composed of one or more resources. If the resource is a server, the current available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, input / output. If the resource is any one or more of a central processing unit, memory, disk space, input / output, the current available resource amount indicates the available amount of the central processing unit, the available amount of memory, the available amount of disk space, and the available amount of input / output. If the resource is a service provider that provides services, the current available resource amount indicates the amount of services that the service provider can still provide.
[0068] Specifically, let's take the example that the resource is a provider of session services, and the total number of sessions that the resource can provide is 100. If the resource has provided 40 session services, then the number of session services that the resource can currently provide is 60, that is, the current available resource amount of the resource is 60. On the other hand, let's take the example that the resource is a disk space, and the size of the disk space is 500G. If 200G of the disk space has been occupied and 300G is left, then the current available resource amount of the disk space is 300G.
[0069] Step S102: determining the recycling priority of the resource according to the current available resource amount of the resource.
[0070] The recycling priority indicates the order in which different resources are recycled from the resource cluster. The recycling priority of resources corresponds to the current available resource amount, and the higher the current available resource amount, the higher the corresponding recycling priority. For example, if the resource is a server and the current available resource amounts of server 1, server 2, and server 3 are 10, 20, and 100 respectively, the recycling priority of server 3 is higher than that of server 2, and the recycling priority of server 2 is higher than that of server 1.
[0071] Generally speaking, when there are many idle resources in a resource cluster, the higher the recycling priority of the resource, the more likely it is to give priority to recycling the resource. Therefore, in order to recycle higher priority resources as soon as possible, when allocating new tasks, try to avoid allocating new tasks to resources with higher recycling priorities, so as to gradually release resources, and then recycle idle resources without affecting the objects provided by the resources, thereby reducing the waste caused by resource idling. On the other hand, since the amount of used resources of resources with higher recycling priorities will be gradually reduced when releasing idle resources, the current available amount of resources of resources with higher recycling priorities is very likely to be greater than the available amount of resources on the resources with the recycling priority. Therefore, when the current available amount of resources in the resource cluster is gradually reduced, it is possible to consider allocating new tasks to one or more resources with higher recycling priorities in priority to achieve resource load balancing.
[0072] In an optional embodiment, before determining the recycling priority of the resource based on the current available resource amount of the resource, the current available resource amount of the resource is adjusted based on the current available resource amount, a first preset weight of the resource, and a second preset weight of the resource, the first preset weight indicating the expected recycling priority of the resource, and the second preset weight indicating the inherent configuration performance of the resource; the recycling priority of the resource is determined based on the adjusted current available resource amount.
[0073] It is understandable that whether a resource is available is not only related to the current available amount of resources, that is, the amount of new tasks that can be undertaken, but also to the inherent configuration performance of the resource itself, and whether it is expected to prioritize the recovery or use of resources. Specifically, taking the resource as a server as an example, different servers have different configuration performance (such as CPU, memory, disk space, network card, etc.), so the amount of available resources that the service itself can provide is different, and as the service life of the server increases, the configuration performance of the server is also gradually declining. Therefore, in order to more comprehensively and accurately evaluate the current available amount of resources of the server, the current available amount of resources can be adjusted in combination with the second preset weight related to the inherent configuration performance of the server, and the better the inherent configuration performance of the server, the higher the corresponding second preset weight value. In addition, due to the different locations of the computer rooms where the servers are located, or the different tasks loaded on the servers, the expected recovery priorities corresponding to different servers are different. For example, when the tasks loaded on the server need to be executed for a long time and cannot be migrated or interrupted, regardless of the current available amount of resources of the server, it is not expected to recover the service, that is, the expected recovery priority of the server is low, and the corresponding first preset weight value is low. Therefore, in the actual execution process, the values of the first preset weight and the second preset weight of the server may not be determined based on the expected recycling priority, inherent configuration performance, etc. of the server.
[0074] Furthermore, the current available resource amount of the resource can be adjusted according to the following formula:
[0075] S'=α·β·S
[0076] Wherein, α is a first preset weight, β is a second preset weight, S is a current available resource amount of the resource, and S' is an adjusted current available resource amount.
[0077] Based on the above formula, the resource is still taken as the server and the current available resource amount is the remaining amount of the CPU for explanation. If the current available resource amounts (i.e., the remaining amount of the CPU) corresponding to server 1, server 2, and server 3 are 20, 50, and 30 respectively, and the first preset weight corresponding to server 1 is 0.2 and the second preset weight is 0.1, the first preset weight corresponding to server 2 is 0.1 and the second preset weight is 0.3, and the first preset weight corresponding to server 3 is 0.1 and the second preset weight is 0.2, the current available resource amounts of server 1 after adjustment are 0.4, 1.5, and 0.6, and the corresponding server 2 has the highest recycling priority, followed by server 3, and server 1 has the lowest recycling priority.
[0078] Step S103, when receiving a new task allocation request, allocate the new task to one or more of the resources according to the recycling priority of the resources and the current available resources of the resources. In addition, according to actual needs, for example, when there is an execution task on the server that cannot be interrupted or stopped, in order to ensure the normal execution of the task, the task may not be allocated to the server; or when some task types can only be allocated to designated servers due to specific needs, there is no need to perform load balancing according to the recycling priority of the server, the current available resources, etc., but directly allocate the task of this type to the designated server.
[0079] In an optional embodiment, the allocating new tasks to one or more of the resources based on the recycling priority of the resources and the current available resource amount of the resources includes: calculating the current available resource amount of the resource cluster based on the current available resource amount of each of the resources; predicting the current available resource amount of the resource cluster at a next moment based on the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments; determining the changing trend of the current available resource amount of the resource cluster based on the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at the next moment; allocating new tasks to one or more of the resources based on the changing trend of the current available resource amount of the resource cluster and the recycling priority of the resources.
[0080] The changing trends of the current available resources include decrease, increase and stability. If the current available resources of the resource cluster are less than the current available resources at the next moment, the changing trend of the previous available resources is increase, that is, the idle resources in the resource cluster are increasing; if the current available resources of the resource cluster are equal to the current available resources at the next moment, the changing trend of the previous available resources is stability, that is, the idle resources in the resource cluster are basically balanced; if the current available resources of the resource cluster are greater than the current available resources at the next moment, the changing trend of the previous available resources is decrease, that is, the idle resources in the resource cluster are decreasing.
[0081] Furthermore, the allocation of new tasks to one or more of the resources according to the changing trend of the current available resource amount of the resource cluster and the recycling priority of the resources includes: when the changing trend of the current available resource amount of the resource cluster is stable, the load of the new tasks is balanced to one or more of the resources; when the changing trend of the current available resource amount of the resource cluster is increasing, the new tasks are allocated to one or more of the resources in the order of the recycling priority of the resources from low to high; when the changing trend of the current available resource amount of the resource cluster is decreasing, the new tasks are allocated to one or more of the resources in the order of the recycling priority of the resources from high to low. In this way, when there are many idle resources in the resource cluster, some resources can be recycled to reduce the waste caused by resource idling, and when resources are scarce, resource load balancing can be achieved to improve the processing efficiency of tasks.
[0082] In an optional implementation, when the current available resource amount of the resource cluster shows a decreasing trend, one or more new resources are added to the resource cluster; and the newly added tasks are assigned to one or more of the new resources. In other words, resources can be dynamically added to the resource cluster to complete the task according to the task requirements or the idleness of resources, but there will not be too many idle resources in the resource cluster to cause resource waste. In addition, resources can also be dynamically added to the resource cluster or recovered from the resource cluster according to historical experience or the cycle of resource service provision.
[0083] In an optional implementation, when the current available resource amount of the resource cluster is changing in an increasing trend, one or more of the resources with a high recycling priority are recycled from the resource cluster. That is, when idle resources in the resource cluster increase, by reducing the amount of new tasks on the resources with a high recycling priority, the used resource amount of the resources can be gradually released, thereby realizing the recycling of idle resources.
[0084] Based on the above embodiments, the resource recovery priority and the current available resource amount of the resource cluster are determined by the current available resource amount of the resource, so that when there are new tasks, the new tasks are dynamically allocated according to the resource recovery priority and the changing trend of the current available resource amount of the resource cluster, so as to maximize the utilization of resources when the resource cluster load is high, and gradually recover idle resources when the resource cluster load is low; in addition, the current available resource amount of the resource can also be adjusted in combination with the first preset weight and the second preset weight of the resource, that is, the expected recovery priority of the resource, the inherent configuration performance of the resource, etc., so that the adjusted current available resource amount of the resource can more truly and effectively reflect the current available resource amount of the resource, so that the resource scheduling is more in line with the expected requirements.
[0085] See also Figure 2 Based on the above embodiment, the embodiment of the present invention provides another resource scheduling method, which specifically includes the following steps:
[0086] Step S201, obtaining the current available resource amount of each resource in the resource cluster.
[0087] A resource can be any one or more of a server, a central processing unit, memory, disk space, input / output, a service provider, etc., and a resource cluster is composed of one or more resources. If the resource is a server, the current available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, input / output. If the resource is any one or more of a central processing unit, memory, disk space, input / output, the current available resource amount indicates the available amount of the central processing unit, the available amount of memory, the available amount of disk space, and the available amount of input / output. If the resource is a service provider that provides services, the current available resource amount indicates the amount of services that the service provider can still provide.
[0088] Step S202, according to the current available resource amount, the first preset weight of the resource, and the second preset weight of the resource, adjust the current available resource amount of the resource. The first preset weight indicates the expected recycling priority of the resource, and the second preset weight indicates the inherent configuration performance of the resource. In this way, the current available resource amount of the resource can be comprehensively evaluated or adjusted in combination with multiple aspects such as the inherent configuration performance of the resource and the expected recycling priority, so that the adjusted current available resource amount is more comprehensive and accurate.
[0089] Step S203, determining the recycling priority of the resource according to the adjusted current available resource amount. It is understandable that the preferred embodiment of the present invention only takes the example that the higher the value of the current available resource amount is, the higher the corresponding recycling priority is, but in the actual application process, the corresponding relationship between the current available resource amount and the recycling priority can also be defined according to actual needs, such as when the current available resource amount is within a certain threshold range, the corresponding recycling priority is the highest.
[0090] Step S204: when a new task allocation request is received, the new task is allocated to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources.
[0091] See also Figure 3 To further illustrate step S204, an embodiment of the present invention provides a method for allocating a new task, and the method specifically includes the following steps:
[0092] S2041: Calculate the current available resource amount of the resource cluster according to the current available resource amount of each resource.
[0093] Specifically, the current available resources of the resource cluster can be calculated according to the following formula:
[0094] The current available resources of the cluster = (S1+S2+…+S n )
[0095] Among them, S n Indicates the current available resource amount of the nth resource in the resource cluster. For example, if the resource is still a server and the current available resource amount is the remaining amount of the CPU, the resource cluster only contains three servers, Server 1, Server 2, and Server 3, and the corresponding current available resource amounts (i.e., the remaining amount of the CPU) are 20, 50, and 30 respectively, then the current available resource amount of the resource cluster is 100.
[0096] S2042: predict the current available resource amount of the resource cluster at the next moment based on the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments. Specifically, the current available resource amount V of the resource cluster at time t is t is 100, the current available amount of the resource cluster at time t-1 is V t-1 is 80, the current available amount of the resource cluster at time t-2 is V t-2 is 60, then the current available resource amount V of the resource cluster at time t+1 is t+1 It can be predicted to be 120 according to the following formula:
[0097] V t+1 =Vt +[(V t -V t-1 )+(V t-1 -V t-2 )] / 2
[0098] It is understandable that the above formula is only one way to predict the current available resource amount of the resource cluster at the next moment. In addition, predictions can also be made based on machine learning algorithms, other calculation formulas, etc.
[0099] S2043: Determine a change trend of the current available resource amount of the resource cluster according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at a next moment.
[0100] The change trend of the current available resources includes three situations: decrease, increase, and stability. If the current available resources of the resource cluster are less than the current available resources at the next moment, the change trend of the previous available resources is increase, that is, the idle resources in the resource cluster are increasing; if the current available resources of the resource cluster are equal to the current available resources at the next moment, the change trend of the previous available resources is stability, that is, the idle resources in the resource cluster are basically balanced; if the current available resources of the resource cluster are greater than the current available resources at the next moment, the change trend of the previous available resources is decrease, that is, the idle resources in the resource cluster are decreasing. Specifically, still taking the current available resource amount V of the resource cluster at time t as t is 100, and the predicted current available resource volume V of the resource cluster at time t+1 t+1 Take 120 as an example. t+1 Greater than V t Therefore, it is judged that the change trend of the current available resources of the resource cluster is increasing, that is, the idle resources in the resource cluster are increasing. It can be understood that the available resources of the resource cluster at the next moment predicted based on the current available resources of the resource cluster at the historical moment and the current moment must be consistent with the actual result. In this case, the change trend of the current available resources can be combined with the predicted current available resources according to the actual situation.
[0101] S2044, determine whether the change trend of the current available resource amount of the resource cluster is decreasing, stable, or increasing; if the change trend is decreasing, continue to execute the following step S2045, if the change trend is stable, continue to execute the following step S2046, if the change trend is decreasing, continue to execute the following step S2047.
[0102] S2045: When the current available resource amount of the resource cluster has a decreasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources.
[0103] In addition, resources can be dynamically added to or recovered from the resource cluster based on historical experience or the cycle of resource service provision. In addition, to further reduce resource pressure, one or more new resources can be added to the resource cluster; the newly added tasks can be assigned to one or more of the new resources. In this way, resources can be dynamically added to the resource cluster to complete tasks based on task requirements or the idleness of resources, but there will not be too many idle resources in the resource cluster to cause resource waste.
[0104] S2046, when the change trend of the current available resource amount of the resource cluster is stable, the newly added task load is balanced to one or more of the resources. That is, the newly added task load is only balanced to the resources in the resource cluster according to the polling method.
[0105] S2047: When the current available resource amount of the resource cluster has an increasing trend, the newly added task is allocated to one or more of the resources in order of the recycling priority of the resources from low to high.
[0106] In addition, when the current available resource amount of the resource cluster has an increasing trend, one or more of the resources with a high recycling priority are recycled from the resource cluster. In this way, when idle resources increase in the resource cluster, the used resource amount of the resources can be gradually released by reducing the amount of new tasks on the resources with a high recycling priority, thereby realizing the recycling of idle resources.
[0107] See also Figure 4 Based on the above embodiments, the embodiment of the present invention provides a resource scheduling device 400, including: a current available resource quantity acquisition module 401, a recycling priority determination module 402, and a resource scheduling module 403; wherein,
[0108] The currently available resource amount acquisition module 401 is used to acquire the currently available resource amount of each resource in the resource cluster;
[0109] The recycling priority determination module 402 is used to determine the recycling priority of the resource according to the current available resource amount of the resource;
[0110] The resource scheduling module 403 is used to allocate the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources when receiving the new task allocation request.
[0111] In an optional implementation, the recycling priority determination module 402 is further configured to:
[0112] Before determining the recycling priority of the resource according to the current available resource amount of the resource, adjusting the current available resource amount of the resource according to the current available resource amount, a first preset weight of the resource, and a second preset weight of the resource, wherein the first preset weight indicates the expected recycling priority of the resource, and the second preset weight indicates the inherent configuration performance of the resource;
[0113] The resource recycling priority is determined according to the adjusted current available resource amount.
[0114] In an optional implementation manner, allocating a new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources includes:
[0115] Calculating the current available resource amount of the resource cluster according to the current available resource amount of each resource;
[0116] Predicting the current available resource amount of the resource cluster at a next moment according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments;
[0117] Determine a change trend of the current available resource amount of the resource cluster according to the current service capacity of the resource cluster and the current available resource amount of the resource cluster at the next moment;
[0118] According to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources, new tasks are allocated to one or more of the resources.
[0119] In an optional implementation, allocating new tasks to one or more of the resources according to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources includes:
[0120] When the change trend of the current available resource amount of the resource cluster is stable, load balancing the newly added task to one or more of the resources;
[0121] When the current available resource amount of the resource cluster has an increasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources;
[0122] When the current available resource amount of the resource cluster has a decreasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources.
[0123] In an optional implementation, the resource scheduling module 403 is further configured to:
[0124] When the current available resource amount of the resource cluster has a decreasing trend, adding one or more new resources to the resource cluster;
[0125] Allocate the newly added task to one or more of the new resources.
[0126] In an optional implementation, the resource scheduling module 403 is further configured to:
[0127] When the current available resource amount of the resource cluster has an increasing trend, one or more of the resources with a high recovery priority are recovered from the resource cluster.
[0128] In an optional implementation, the resource is a server, and the currently available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, and input / output.
[0129] In an optional embodiment, when the resource is any one or more of a central processing unit, memory, disk space, and input / output, the current available resource amount correspondingly indicates: the available amount of the central processing unit, the available amount of memory, the available amount of disk space, and the available amount of input / output.
[0130] In an optional implementation manner, in the case where the resource is a service provider that provides services, the currently available resource amount indicates the amount of services that can still be provided by the service provider.
[0131] Figure 5 An exemplary system architecture 500 is shown to which the resource scheduling method or resource scheduling apparatus according to the embodiment of the present invention can be applied.
[0132] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0133] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0134] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0135] The server 505 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - just an example) to the terminal device.
[0136] It should be noted that the resource scheduling method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the resource scheduling device is generally disposed in the server 505 .
[0137] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0138] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0139] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0140] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0141] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0142] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0143] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0144] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a module for obtaining the current available resource quantity, a module for determining recycling priority, and a resource scheduling module. The names of these modules do not constitute a limitation on the modules themselves in certain circumstances. For example, the module for obtaining the current available resource quantity may also be described as "a module for obtaining the current available resource quantity of each resource in a resource cluster".
[0145] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining the current available resource amount of each resource in the resource cluster; determining the recycling priority of the resource according to the current available resource amount of the resource; and when receiving a new task allocation request, allocating the new task to one or more of the resources according to the recycling priority of the resource and the current available resource amount of the resource.
[0146] According to the technical solution of the embodiment of the present invention, the resource recovery priority and the current available resource amount of the resource cluster are determined by the current available resource amount of the resource, so that when there is a new task, the new task is dynamically allocated according to the change trend of the resource recovery priority and the current available resource amount of the resource cluster, so as to maximize the utilization of resources when the resource cluster load is high, and gradually recover idle resources when the resource cluster load is low; in addition, the current available resource amount of the resource can also be adjusted in combination with the first preset weight and the second preset weight of the resource, that is, the expected recovery priority of the resource, the inherent configuration performance of the resource, etc., so that the adjusted current available resource amount of the resource can more truly and effectively reflect the current available resource amount of the resource, so that the resource scheduling is more in line with the expected requirements.
[0147] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A resource scheduling method, characterized in that: include: Get the current available resource amount of each resource in the resource cluster; Determining the recycling priority of the resource according to the current available resource amount of the resource; When receiving a request for allocating a new task, allocating the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources; Specifically, it includes: calculating the current available resource amount of the resource cluster according to the current available resource amount of each of the resources; predicting the current available resource amount of the resource cluster at the next moment according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments; determining the changing trend of the current available resource amount of the resource cluster according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at the next moment; allocating new tasks to one or more of the resources according to the changing trend of the current available resource amount of the resource cluster and the recycling priority of the resources.
2. The resource scheduling method according to claim 1, characterized in that: Also includes: Before determining the recycling priority of the resource according to the current available resource amount of the resource, adjusting the current available resource amount of the resource according to the current available resource amount, a first preset weight of the resource, and a second preset weight of the resource, wherein the first preset weight indicates the expected recycling priority of the resource, and the second preset weight indicates the inherent configuration performance of the resource; The resource recycling priority is determined according to the adjusted current available resource amount.
3. The resource scheduling method according to claim 1, characterized in that: The allocating new tasks to one or more of the resources according to the change trend of the current available resource amount of the resource cluster and the recycling priority of the resources includes: When the change trend of the current available resource amount of the resource cluster is stable, load balancing the newly added task to one or more of the resources; When the current available resource amount of the resource cluster has an increasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources; When the current available resource amount of the resource cluster has a decreasing trend, the newly added task is allocated to one or more of the resources in descending order of the recycling priority of the resources.
4. The resource scheduling method according to claim 3, characterized in that: Also includes: When the current available resource amount of the resource cluster has a decreasing trend, adding one or more new resources to the resource cluster; Allocate the newly added task to one or more of the new resources.
5. The resource scheduling method according to claim 3, characterized in that: Also includes: When the current available resource amount of the resource cluster has an increasing trend, one or more of the resources with a high recovery priority are recovered from the resource cluster.
6. The resource scheduling method according to claim 3, characterized in that: In the case where the resource is a server, the currently available resource amount indicates the remaining amount of one or more of the following physical resources of the server: central processing unit, memory, disk space, input / output; Or when the resource is any one or more of a central processing unit, a memory, a disk space, and an input / output, the current available resource amount indicates: the available amount of the central processing unit, the available amount of the memory, the available amount of the disk space, and the available amount of the input / output; Or, in the case where the resource is a service provider that provides services, the currently available resource amount indicates the amount of services that can still be provided by the service provider.
7. A resource scheduling device, characterized in that: include: Current available resource acquisition module, recycling priority determination module, resource scheduling module; among them, The currently available resource amount acquisition module is used to acquire the currently available resource amount of each resource in the resource cluster; The recycling priority determination module is used to determine the recycling priority of the resource according to the current available resource amount of the resource; The resource scheduling module is used to allocate the new task to one or more of the resources according to the recycling priority of the resources and the current available resource amount of the resources when receiving a new task allocation request; specifically, it is used to calculate the current available resource amount of the resource cluster according to the current available resource amount of each of the resources; predict the current available resource amount of the resource cluster at the next moment according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at one or more historical moments; determine the changing trend of the current available resource amount of the resource cluster according to the current available resource amount of the resource cluster and the current available resource amount of the resource cluster at the next moment; allocate the new task to one or more of the resources according to the changing trend of the current available resource amount of the resource cluster and the recycling priority of the resources.
8. An electronic device for resource scheduling, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Resource allocation method and device, electronic equipment and memory medium
CN109361750A
Cognitive scheduler
US20180113742A1
