Resource scheduling method and device
By calculating the average CPU utilization of devices in a distributed cluster and automatically adjusting the weights, the problem of uneven CPU utilization is solved, dynamic resource scheduling without manual operation is achieved, and the stability of cluster services is improved.
Patent Information
- Application Number
- CN202010219853.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-25
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2040-03-25
AI Technical Summary
In a distributed cluster, due to aging device hardware or uneven resource allocation, CPU utilization is too high or too low, affecting service stability. Existing technologies require manual adjustments, which is time-consuming and labor-intensive.
By counting resource utilization within a preset period, calculating the average utilization of devices, automatically adjusting the weights of devices with excessively high CPU utilization, dynamically balancing cluster resources, and reducing weights to achieve resource scheduling without manual operation.
In a distributed cluster environment, automatically adjust devices with excessively high CPU utilization to achieve a dynamic balance of overall CPU utilization and improve service stability.
Smart Images

Figure CN113448717B_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] In the Internet environment, user visits are usually in the tens of millions or even hundreds of millions, so the number of application clusters providing services ranges from hundreds to thousands. The level of CPU (Central Processing Unit) resources of each device will affect the quality of the entire cluster service.
[0003] In existing device management, due to aging hardware or uneven resource allocation, some devices experience excessive CPU utilization while others experience low CPU utilization, leading to unstable service provisioning. Developers typically use resource monitoring and alarms. Manually removing devices with excessive CPU utilization lowers their load weight, reducing CPU resource consumption by reducing resource access.
[0004] In the process of implementing the present invention, the inventors discovered that the prior art has at least the following problems:
[0005] There are a large number of devices in a distributed cluster, and manually handling devices with high CPU utilization is time-consuming and labor-intensive. Summary of the Invention
[0006] In view of this, an embodiment of the present invention provides a resource scheduling method and apparatus, which can at least solve the problem in the prior art that manual adjustment is required for devices with excessively high CPU utilization.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a resource scheduling method is provided, comprising:
[0008] For the same application cluster, count the resource scheduling amount of a single device within a preset period to determine the resource utilization of the single device;
[0009] Taking the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extracting the first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0010] The weight of the first device is adjusted in a preset manner so that when a resource scheduling request is received, the scheduling amount of resources for each device is determined based on the weight of each device and the total amount of scheduled resources.
[0011] Optionally, the adjusting the weight of the first device according to a preset method includes:
[0012] Obtaining a preset weight for the first device, and determining whether a resource utilization rate of the first device is greater than or equal to the preset weight;
[0013] If yes, adjusting the weight of the first device to the first weight;
[0014] If not, the difference between the resource utilization of the first device and the average resource utilization is calculated, combined with the preset weight to obtain a second weight, and then the weight of the first device is adjusted to the second weight.
[0015] Optionally, also include:
[0016] Obtaining the IP address and preset weight of a single device and uploading them to a data center, so that the data of the single device is transmitted to the resource scheduling module through the data center; wherein the data includes the IP address, resource utilization rate and preset weight;
[0017] After determining the scheduling amount for each device resource, the method further includes:
[0018] The resource scheduling module transmits the IP address of the device to the second device that sends the resource scheduling request according to the scheduling result, so that the second device performs resource scheduling through the transmitted IP address.
[0019] Optionally, transmitting the data of a single device to the resource scheduling module through the data center includes: when the resource scheduling module detects that the data of the device in the data center has changed, acquiring the changed data of the device from the data center.
[0020] Optionally, before transmitting the IP address of the device to the second device that sends the resource scheduling request, it also includes: obtaining the scheduling request amount of each second device for the resource, determining at least one second device whose sum of the scheduling request amounts is the scheduling amount, and then establishing a mapping relationship between the device and the at least one second device.
[0021] Optionally, before transmitting the IP address of the device to the second device that sends the resource scheduling request, the method further includes:
[0022] Sorting the determined scheduling amount of each device resource to obtain a device queue;
[0023] Sorting the resource scheduling requests of the second devices to obtain a second device queue;
[0024] In a round-robin manner, the second devices in the second device queue are assigned to the devices in the device queue, thereby establishing a mapping relationship between the devices and the second devices.
[0025] To achieve the above object, according to another aspect of an embodiment of the present invention, a resource scheduling device is provided, comprising:
[0026] The resource calculation module is used to calculate the resource scheduling amount of a single device within a preset period for the same application cluster to determine the resource utilization rate of the single device;
[0027] a device extraction module, configured to use a ratio of a sum of resource utilization rates to the number of devices as an average resource utilization rate of devices in the application cluster, and extract a first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0028] The weight adjustment module is used to adjust the weight of the first device in a preset manner so as to determine the scheduling amount of each device resource based on the weight of each device and the total amount of scheduled resources when a resource scheduling request is received.
[0029] Optionally, the weight adjustment module is used to:
[0030] Obtaining a preset weight for the first device, and determining whether a resource utilization rate of the first device is greater than or equal to the preset weight;
[0031] If yes, adjusting the weight of the first device to the first weight;
[0032] If not, the difference between the resource utilization of the first device and the average resource utilization is calculated, combined with the preset weight to obtain a second weight, and then the weight of the first device is adjusted to the second weight.
[0033] Optionally, a service provision module is also included to:
[0034] Obtaining the IP address and preset weight of a single device and uploading them to a data center, so that the data of the single device is transmitted to the resource scheduling module through the data center; wherein the data includes the IP address, resource utilization rate and preset weight;
[0035] Resource scheduling module, used to:
[0036] The resource scheduling module transmits the IP address of the device to the second device that sends the resource scheduling request according to the scheduling result, so that the second device performs resource scheduling through the transmitted IP address.
[0037] Optionally, the service providing module is configured to: when the resource scheduling module detects that the data of the device in the data center has changed, obtain the changed data of the device from the data center.
[0038] Optionally, the resource scheduling module is further used to: obtain the scheduling request amount of each second device for resources, determine at least one second device whose sum of the scheduling request amounts is the scheduling amount, and then establish a mapping relationship between the device and the at least one second device.
[0039] Optionally, the resource scheduling module is further configured to:
[0040] Sorting the determined scheduling amount of each device resource to obtain a device queue;
[0041] Sorting the resource scheduling requests of the second devices to obtain a second device queue;
[0042] In a round-robin manner, the second devices in the second device queue are assigned to the devices in the device queue, thereby establishing a mapping relationship between the devices and the second devices.
[0043] To achieve the above objective, according to another aspect of an embodiment of the present invention, a resource scheduling electronic device is provided.
[0044] The electronic device of an embodiment of the present invention includes: 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 resource scheduling methods described above.
[0045] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, any of the above-mentioned resource scheduling methods is implemented.
[0046] According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: in a distributed cluster environment, based on the average value of the existing cluster CPU utilization, the devices whose utilization exceeds the average value are automatically adjusted, such as by using the weight reduction method, and no manual operation is required as a whole, thereby achieving a dynamic balance of the CPU utilization of the entire cluster.
[0047] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.
[0049] Figure 1 This is a schematic diagram of the main process of a resource scheduling method according to an embodiment of the present invention;
[0050] Figure 2is a flow chart of an optional resource scheduling method according to an embodiment of the present invention;
[0051] Figure 3 This is a schematic diagram of a resource scheduling method framework according to an embodiment of the present invention;
[0052] Figure 4 1 is a schematic diagram of main modules of a resource scheduling device according to an embodiment of the present invention;
[0053] Figure 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
[0054] Figure 6 It is a schematic diagram of the structure of a computer system of a mobile device or server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled 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 the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0056] See also Figure 1 , which shows a main flow chart of a resource scheduling method provided by an embodiment of the present invention, including the following steps:
[0057] S101: For the same application cluster, count the resource scheduling amount of a single device within a preset period to determine the resource utilization rate of the single device;
[0058] S102: taking the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extracting the first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0059] S103: Adjust the weight of the first device in a preset manner, so as to determine the scheduling amount of resources for each device based on the weight of each device and the total amount of scheduled resources when a resource scheduling request is received.
[0060] In the above implementation, for steps S101 and S102, the present invention is mainly applied in a distributed cluster environment to achieve dynamic scheduling of device CPU resource utilization.
[0061] The control center is equipped with a resource scheduling module. When the module is started, it will first calculate the average CPU utilization of all available devices in the entire application cluster. Specifically:
[0062] 1) Calculate the CPU utilization of a single device, for example, by calculating the amount of CPU scheduling for that device within a preset time period or a preset cycle;
[0063] 2) Count the number of devices, that is, the number of available devices in a unified application cluster;
[0064] 3) Calculate the sum of the device CPU utilization and the number of available devices, and use the resulting quotient as the average CPU utilization of the devices in the entire application cluster.
[0065] The above can be set up as a scheduled task to periodically calculate the average CPU utilization of the devices in the application cluster, for example, updating it every 5 minutes.
[0066] Based on the calculated average CPU utilization, the devices in the application cluster are divided into two categories: the first device whose CPU utilization is greater than or equal to the average CPU utilization, and the remaining devices. Considering that excessively high CPU utilization may affect the performance of the entire application cluster, the present invention primarily addresses the first device.
[0067] In step S103, the resource scheduling module periodically adjusts the weight of each device for the CPU scheduling amount to achieve the purpose of dynamically adjusting the CPU utilization; wherein the weight is the allocation strategy of resource scheduling, and the greater the weight means the more resource scheduling requests are allocated.
[0068] Determine whether the CPU utilization of the first device exceeds its preset weight, for example, 100%:
[0069] 1) If yes, its weight is directly returned to the first weight, for example, 0, which means that the first device will not participate in the load in the future and no traffic / resource scheduling allocation will occur;
[0070] 2) If not, the weight is adjusted according to a predetermined algorithm, specifically: preset weight - (CPU utilization - average CPU utilization) × 100%.
[0071] After receiving the resource scheduling request from the second device, the resource allocation module allocates resource scheduling amounts to each device based on the readjusted weights. Devices with smaller scheduling amounts will see their CPU utilization gradually decrease. At the next cycle, all devices in the application cluster will participate in the next weight adjustment, ultimately dynamically adjusting the overall CPU utilization to below the average.
[0072] The method provided in the above embodiment dynamically adjusts the load weight of the devices in the entire application cluster according to the CPU utilization of the devices in a distributed cluster environment to avoid the situation where the CPU utilization of some devices is too high and affects the service quality of the entire cluster.
[0073] See also Figure 2 , shows a schematic flow chart of an optional resource scheduling method according to an embodiment of the present invention, comprising the following steps:
[0074] S201: For the same application cluster, count the resource scheduling amount of a single device within a preset period to determine the resource utilization rate of the single device;
[0075] S202: Obtaining an IP address and a preset weight of a single device and uploading them to a data center, so that the data of the device is transmitted to a resource scheduling module via the data center; wherein the data includes the IP address, resource utilization, and preset weight;
[0076] S203: Taking the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extracting the first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0077] S204: Obtain a preset weight for the first device, and determine whether the resource utilization rate of the first device is greater than or equal to the preset weight;
[0078] S205: If yes, adjust the weight of the first device to the first weight;
[0079] S206: If not, calculate the difference between the resource utilization of the first device and the average resource utilization, combine the preset weight to obtain a second weight, and then adjust the weight of the first device to the second weight.
[0080] S207: upon receiving the resource scheduling request, determining the scheduling amount of resources for each device based on the weight of each device and the total amount of resources to be scheduled;
[0081] S208: The resource scheduling module transmits the IP address of the device to the second device that sends the resource scheduling request according to the scheduling result, so that the second device performs resource scheduling through the transmitted IP address.
[0082] In the above embodiment, for steps S201, S203 to S207, please refer to Figure 1 The description of steps S101 to S103 is omitted here.
[0083] In the above embodiment, for step S202, the device mentioned in the present invention can be regarded as a server that provides resource scheduling. The service provision module (server) and the resource calculation module can be deployed as different components in the same device.
[0084] After the service provider module starts, it proactively obtains the device's IP address and preset weight (e.g., 100%) and uploads it to the distributed data center. After the service provider module completes the data upload, it automatically triggers the resource calculation module to start. Once started, the resource calculation module counts the CPU usage of each device within a preset period, calculates CPU utilization (in seconds and minutes), and synchronizes this CPU utilization to the distributed data center.
[0085] It should be noted that the device startup must be prior to the second device (sending a resource scheduling request), and the resource calculation module can only be started after the service provision module synchronizes data, otherwise it may easily lead to service unavailability.
[0086] Modules associated with distributed data centers include, in addition to the service provision module and resource calculation module in the device, a resource scheduling module to dynamically adjust the CPU utilization / weight of the device.
[0087] After the resource scheduling module is started, it subscribes to the data of the devices in the distributed data center (including IP address, CPU utilization and preset interruption). When it detects changes in its data, it will actively pull data from the distributed data center to achieve the purpose of data synchronization.
[0088] It should be noted that the resource scheduling module and the distributed data center are not a whole. The distributed data center can be regarded as a control center based on Zookeeper (this is just an example) for storing data.
[0089] In addition, heartbeat monitoring is set up between the distributed data center and the service provider module. When the data status provided by the service provider module is detected to be abnormal, it will be automatically removed from the data center and then synchronized to the resource scheduling module.
[0090] Regarding step S208, the second device aims to schedule CPU resources in the device, so it is usually started after the device is started, or it can be started before the device is started, and waits until the device is started before sending the resource scheduling request.
[0091] The determined device serving the second device can be calculated as follows:
[0092] 1) Comparing the resource scheduling request amount of the second device with the determined resource scheduling amount for the device, ultimately obtaining the second device with the sum of the scheduling requests. For example, the resource scheduling amount for device a is 100, while the resource scheduling amount for second device I is 50, and the resource scheduling amount for second device II and second device III is 20 and 50 respectively. Ultimately, a mapping relationship between device a, second device I, second device II, and second device III is obtained;
[0093] 2) Sequential training method:
[0094] ① First, establish a device queue based on the resource scheduling amount of the device, such as device a, device b, device c, device d...
[0095] A second device queue is established based on the resource scheduling request amount of the second device, for example, second device I, second device II, second device III, etc.
[0096] ② According to the round-robin training method, the second device I is assigned to device a, the second device II is assigned to device b, and so on.
[0097] It should be noted that during rotation training, it is necessary to compare the resource scheduling request amount of the second device to see whether it is greater than the resource scheduling amount of the corresponding device (or scheduling amount - allocated scheduling request amount). If it is greater, only a part of it will be allocated, and the second device will be moved to the end of the second device queue. At this time, one second device can correspond to multiple devices, and the two present a many-to-many relationship.
[0098] 3) Random training method
[0099] The difference from the above 2) is that the second device is randomly allocated to the device, and the resource scheduling request amount and the resource scheduling amount are compared at the same time.
[0100] After determining the mapping relationship between the device and the second device, the device IP address is transmitted to the corresponding second device. Only after obtaining the device IP address can the second device communicate with the device and access the CPU resources in the device.
[0101] The method provided in the above embodiment establishes a mapping relationship between the device and the second device based on the sum of resource scheduling request amounts, sequential round-robin training, random round-robin training, etc., so as to achieve rational resource scheduling in the device.
[0102] See also Figure 3 , shows a schematic diagram of a resource scheduling framework according to an embodiment of the present invention, including a distributed data center, a device, a second device, and a resource scheduling module:
[0103] 1) Equipment, including service provision module (server) and resource calculation module:
[0104] ① The service provision module actively obtains the IP address and preset weight of the device and uploads them to the distributed data center;
[0105] ② The resource calculation module, in response to the service provision module completing the data upload, counts the CPU scheduling amount of a single device within a preset period to calculate the CPU utilization rate, and then synchronizes the CPU utilization rate to the distributed data center;
[0106] 2) Distributed data center: used to store device data, including IP addresses, preset weights, and CPU utilization;
[0107] 3) a resource scheduling module, associated with the distributed data center, for obtaining device data, dynamically adjusting the weight of each device based on the device data, and determining a mapping relationship between the device and the second device;
[0108] 4) A second device is configured to send a resource scheduling request.
[0109] The method provided by the embodiment of the present invention automatically adjusts devices with excessively high CPU utilization in a distributed cluster environment by reducing their weights to achieve a dynamic balance in the CPU utilization of devices in the entire cluster.
[0110] See also Figure 4 , which shows a schematic diagram of the main modules of a resource scheduling device 400 provided in an embodiment of the present invention, including:
[0111] The resource calculation module 401 is used to calculate the resource scheduling amount of a single device within a preset period for the same application cluster to determine the resource utilization rate of the single device;
[0112] A device extraction module 402 is configured to use the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extract the first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0113] The weight adjustment module 403 is used to adjust the weight of the first device in a preset manner, so as to determine the scheduling amount of each device resource based on the weight of each device and the total amount of scheduled resources when receiving a resource scheduling request.
[0114] In the implementation device of the present invention, the weight adjustment module 403 is used to:
[0115] Obtaining a preset weight for the first device, and determining whether a resource utilization rate of the first device is greater than or equal to the preset weight;
[0116] If yes, adjusting the weight of the first device to the first weight;
[0117] If not, the difference between the resource utilization of the first device and the average resource utilization is calculated, combined with the preset weight to obtain a second weight, and then the weight of the first device is adjusted to the second weight.
[0118] The implementation device of the present invention further includes a service providing module 404 (not shown in the figure) for:
[0119] Obtaining the IP address and preset weight of a single device and uploading them to a data center, so that the data of the single device is transmitted to the resource scheduling module through the data center; wherein the data includes the IP address, resource utilization rate and preset weight;
[0120] The resource scheduling module 405 (not shown) is used to:
[0121] The resource scheduling module transmits the IP address of the device to the second device that sends the resource scheduling request according to the scheduling result, so that the second device performs resource scheduling through the transmitted IP address.
[0122] In the implementation device of the present invention, the service providing module 404 is used to:
[0123] When the resource scheduling module detects that the data of the device in the data center has changed, it obtains the changed data of the device from the data center.
[0124] In the implementation device of the present invention, the resource scheduling module 405 is further configured to:
[0125] Obtain the scheduling request amount of each second device for resources, determine at least one second device whose sum of the scheduling request amounts is the scheduling amount, and then establish a mapping relationship between the device and the at least one second device.
[0126] In the implementation device of the present invention, the resource scheduling module 405 is further configured to:
[0127] Sorting the determined scheduling amount of each device resource to obtain a device queue;
[0128] Sorting the resource scheduling requests of the second devices to obtain a second device queue;
[0129] In a round-robin manner, the second devices in the second device queue are assigned to the devices in the device queue, thereby establishing a mapping relationship between the devices and the second devices.
[0130] In addition, the specific implementation content of the device in the embodiment of the present invention has been described in detail in the above method, so the repeated content will not be described again here.
[0131] Figure 5 An exemplary system architecture 500 is shown in which embodiments of the present invention may be applied.
[0132] like Figure 5As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505 (only as an example). Network 504 is used to provide a medium for communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0133] Users can use terminal devices 501, 502, 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503.
[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, and desktop computers.
[0135] The server 505 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using the terminal devices 501 , 502 , and 503 (for example only).
[0136] It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the device is generally set in the server 505 .
[0137] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0138] Reference below Figure 6 , which shows a schematic structural diagram 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 unit 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the system 600 are also stored in the RAM 603. The CPU 601, ROM 602, and 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, and the like; an output section 607 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 608 including a hard disk; and a communication section 609 including a network interface card such as a LAN card or a modem. 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, or a semiconductor memory, is installed in the drive 610 as needed, so that computer programs read therefrom can be installed into the storage section 608 as needed.
[0141] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from a 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 performed.
[0142] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0143] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that 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 flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the 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 in software or in hardware. The modules described may also be provided in a processor. For example, they may be described as follows: a processor including a resource calculation module, a device extraction module, and a weight adjustment module. The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, the weight adjustment module may also be described as a "device weight adjustment module."
[0145] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiments, or may exist independently without being incorporated into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes:
[0146] For the same application cluster, count the resource scheduling amount of a single device within a preset period to determine the resource utilization of the single device;
[0147] Taking the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extracting the first device whose resource utilization rate is greater than or equal to the average resource utilization rate;
[0148] The weight of the first device is adjusted in a preset manner so that when a resource scheduling request is received, the scheduling amount of resources for each device is determined based on the weight of each device and the total amount of scheduled resources.
[0149] According to the technical solution of an embodiment of the present invention, in a distributed cluster environment, based on the average value of the existing cluster CPU utilization, the devices whose utilization exceeds the average value are automatically adjusted, such as by adopting the weight reduction method, and no manual operation is required as a whole, thereby achieving a dynamic balance of the CPU utilization of the entire cluster.
[0150] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A resource scheduling method, characterized in that: include: For the same application cluster, count the resource scheduling amount of a single device within a preset period to determine the resource utilization of the single device; Taking the ratio of the sum of resource utilization rates to the number of devices as the average resource utilization rate of the devices in the application cluster, and extracting the first device whose resource utilization rate is greater than or equal to the average resource utilization rate; The weight of the first device is adjusted in a preset manner, so that when a resource scheduling request is received, a scheduling amount of resources for each device is determined based on the weight of each device and the total amount of resources scheduled; wherein the weight is an allocation strategy for resource scheduling, and a greater weight means a greater amount of resource scheduling requests are allocated; the weight of the first device is adjusted in a preset manner, including: Obtaining a preset weight for the first device, and determining whether a resource utilization rate of the first device is greater than or equal to the preset weight; If yes, the weight of the first device is adjusted to a first weight; the first weight indicates that the first device will not participate in the load subsequently and no traffic / resource scheduling or allocation will occur; If not, calculate the difference between the resource utilization of the first device and the average resource utilization, combine it with the preset weight, obtain the second weight, and then adjust the weight of the first device to the second weight; the second weight is the difference between the preset weight and the difference.
2. The method according to claim 1, characterized in that Also includes: Obtaining the IP address and preset weight of a single device and uploading them to a data center, so that the data of the single device is transmitted to the resource scheduling module through the data center; wherein the data includes the IP address, resource utilization rate and preset weight; After determining the scheduling amount for each device resource, the method further includes: The resource scheduling module transmits the IP address of the device to the second device that sends the resource scheduling request according to the scheduling result, so that the second device performs resource scheduling through the transmitted IP address.
3. The method according to claim 2, characterized in that The transmitting of the data of a single device to the resource scheduling module through the data center includes: When the resource scheduling module detects that the data of the device in the data center has changed, it obtains the changed data of the device from the data center.
4. The method according to claim 2, characterized in that Before transmitting the IP address of the device to the second device that sends the resource scheduling request, the method further includes: Obtain the scheduling request amount of each second device for resources, determine at least one second device whose sum of the scheduling request amounts is the scheduling amount, and then establish a mapping relationship between the device and the at least one second device.
5. The method according to claim 2, characterized in that Before transmitting the IP address of the device to the second device that sends the resource scheduling request, the method further includes: Sorting the determined scheduling amount of each device resource to obtain a device queue; Sorting the resource scheduling requests of the second devices to obtain a second device queue; In a round-robin manner, the second devices in the second device queue are assigned to the devices in the device queue, thereby establishing a mapping relationship between the devices and the second devices.
6. A resource scheduling device, characterized in that: include: The resource calculation module is used to calculate the resource scheduling amount of a single device within a preset period for the same application cluster to determine the resource utilization rate of the single device; a device extraction module, configured to use a ratio of a sum of resource utilization rates to the number of devices as an average resource utilization rate of devices in the application cluster, and extract a first device whose resource utilization rate is greater than or equal to the average resource utilization rate; A weight adjustment module is configured to adjust the weight of the first device in a preset manner, so as to determine, upon receiving a resource scheduling request, a scheduling amount for each device resource based on the weight of each device and the total amount of scheduled resources; wherein the weight is an allocation strategy for resource scheduling, and a greater weight means a greater amount of allocated resource scheduling requests; adjusting the weight of the first device in a preset manner includes: Obtaining a preset weight for the first device, and determining whether a resource utilization rate of the first device is greater than or equal to the preset weight; If yes, the weight of the first device is adjusted to a first weight; the first weight indicates that the first device will not participate in the load subsequently and no traffic / resource scheduling or allocation will occur; If not, calculate the difference between the resource utilization of the first device and the average resource utilization, combine it with the preset weight, obtain the second weight, and then adjust the weight of the first device to the second weight; the second weight is the difference between the preset weight and the difference.
7. An electronic device, 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 5.
8. 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 5 is implemented.
Citation Information
Patent Citations
Method and device for dynamically distributing resources under cloud computing environment
CN102594869A
Load balancing method and apparatus, and computer readable storage medium
CN107124472A