Resource allocation method and device for database nodes, equipment and medium

Through real-time monitoring and dynamic adjustment of the resource proportion of database node tasks, the problem that traditional methods cannot dynamically adjust CPU resource allocation is solved, and the resource utilization rate and task execution efficiency of the database system are improved.

CN119473615AInactive Publication Date: 2025-02-18SHENZHEN INST OF COMPUTING SCI
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411618506.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional CPU resource scheduling and allocation methods cannot be dynamically adjusted according to the actual operation of distributed database systems and changes in business requirements, resulting in delayed execution of important tasks due to insufficient resources, while some non-critical tasks occupy too much CPU resources, reducing the System resource utilization rate.

Method used

By monitoring the real-time resource proportion during task execution in real time, calculate the historical resource proportion of the task, calculate and adjust the resource weight value based on the initial resource weight value, historical resource proportion and task weight value, dynamically adjust the resource proportion of the task, To achieve adaptive adjustment of resources.

Benefits of technology

It realizes dynamic adjustment of CPU resource allocation according to the real-time execution and importance of the task, improves the utilization rate of CPU resources by the database system, makes resource allocation closer to the needs of the task, and avoids resource waste and delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473615A_ABST
    Figure CN119473615A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of databases, and particularly relates to a resource allocation method and device for database nodes, equipment and a medium. The method comprises the following steps: for any N tasks to be subjected to resource allocation in a database node, determining an initial resource proportion according to initial resource weight values of the N tasks, executing the tasks according to the initial resource proportion, monitoring a real-time resource proportion in a task execution process in real time, obtaining a historical resource proportion according to the real-time resource proportion before the current moment, and executing the tasks according to the historical resource proportion. Obtaining an adjustment resource weight value according to the initial resource weight value, the historical resource proportion and the task weight value of the task, determining an adjustment resource proportion according to the adjustment resource weight values of the N tasks, executing the task according to the adjustment resource proportion, and returning to the step of monitoring the real-time resource proportion in the task execution process in real time until the task execution is completed. And on the basis of improving the utilization rate of the resources, the adjusted resource proportion is closer to the demand of the task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application is applicable to the field of database technology, and in particular, relates to a resource allocation method, device, equipment and medium for a database node. Background Art

[0002] In a distributed database system, the scheduling and allocation of CPU (Central Processing Unit) resources is one of the key factors to ensure the efficient operation of the system. The traditional method of scheduling and allocating CPU resources mainly relies on the load balancing mechanism of the operating system or static configuration based on business characteristics. However, due to the diversity and dynamic nature of business scenarios, the demand and consumption of CPU resources for each business will change in real time. The traditional method cannot dynamically adjust the CPU resources according to the actual operation of the system and the changes in business needs, resulting in the delay of important tasks due to insufficient resources, while some non-critical tasks do occupy too much CPU resources. Therefore, how to improve the utilization of CPU resources in the database system based on business characteristics has become an urgent problem to be solved. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a method, apparatus, device and medium for allocating resources of a database node to solve the problem of how to improve the utilization of CPU resources of a database system based on business characteristics.

[0004] In a first aspect, an embodiment of the present application provides a resource allocation method for a database node, the resource allocation method comprising: Determine N tasks to be resource-allocated in the database node, and for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task, where N is an integer greater than 1; Monitor the real-time resource ratio during the execution of the task in real time, and calculate the historical resource ratio of the task based on the real-time resource ratio before the current moment; Obtaining a task weight value corresponding to the task, and calculating an adjusted resource weight value of the task according to the initial resource weight value, historical resource ratio and task weight value of the task; According to the adjustment resource weight values ​​of the N tasks, determine the adjustment resource ratio of the task, execute the task according to the adjustment resource ratio of the task, and return to the step of real-time monitoring of the real-time resource ratio during the execution of the task until the task is completed.

[0005] In a second aspect, an embodiment of the present application provides a resource allocation device for a database node, the resource allocation device comprising: A first execution module, used to determine N tasks to be resource-allocated in the database node, and for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task, where N is an integer greater than 1; The first monitoring module is used to monitor the real-time resource ratio during the execution of the task in real time, and calculate the historical resource ratio of the task according to the real-time resource ratio before the current moment; A first adjustment module is used to obtain a task weight value corresponding to the task, and calculate an adjustment resource weight value of the task according to an initial resource weight value, a historical resource ratio and a task weight value of the task; The first loop module is used to determine the adjustment resource ratio of the task according to the adjustment resource weight values ​​of the N tasks, execute the task according to the adjustment resource ratio of the task, and return to the step of real-time monitoring of the real-time resource ratio during the execution of the task until the task is completed. In a third aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the resource allocation method for the database node as described in the first aspect is implemented.

[0006] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the resource allocation method for a database node as described in the first aspect is implemented.

[0007] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the present application is applicable to the scenario where N tasks are executed in parallel in a database node, where N is an integer greater than 1. During the execution of the N tasks, the resources of each task are adaptively adjusted. The adaptive resource adjustment of any task is taken as an example below: according to the initial resource weight values ​​of the N tasks, the initial resource ratio of the task is determined, the task is executed according to the initial resource ratio, the real-time resource ratio during the execution of the task is monitored in real time, the historical resource ratio is calculated according to the real-time resource ratio before the current moment, the adjustment resource weight value is calculated according to the initial resource weight value, the historical resource ratio and the task weight value corresponding to the task, the adjustment resource weight value is determined according to the adjustment resource weight values ​​of the N tasks, the task is executed according to the adjustment resource ratio, and the step of real-time monitoring the real-time resource ratio during the execution of the task is returned until the task is completed. Among them, by automatically monitoring the real-time resource ratio during task execution, the resource ratio of the task is dynamically and adaptively adjusted according to the real-time resource ratio and the task weight value. It not only realizes the dynamic adjustment of resources according to the real-time execution of the task, but also realizes the dynamic adjustment of resources according to the task characteristics based on the task weight value, so that important tasks can use more resources. On the basis of improving the resource utilization of the database system, the adjusted resource ratio also makes it closer to the task requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0009] Figure 1 It is a flowchart of a method for allocating resources of a database node provided in Example 1 of the present application; Figure 2 It is a flowchart of a method for allocating resources of a database node provided in Embodiment 2 of the present application; Figure 3 It is a flowchart of a method for allocating resources of a database node provided in Embodiment 3 of the present application; Figure 4 It is a flowchart of a method for allocating resources of a database node provided in Embodiment 4 of the present application; Figure 5 It is a flowchart of a method for allocating resources of a database node provided in Embodiment 5 of the present application; Figure 6It is a structural diagram of a resource allocation device for a database node provided in Embodiment 6 of the present application; Figure 7 It is a structural diagram of a computer device provided in Example 7 of the present application. DETAILED DESCRIPTION

[0010] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0011] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0012] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0013] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0014] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0015] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0016] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0017] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0018] It should be understood that the size of the serial numbers of the steps in the following embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0019] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.

[0020] See also Figure 1 , is a flow chart of a method for allocating resources of a database node provided in Example 1 of the present application. Figure 1 As shown, the resource allocation method may include the following steps: Step S101, determine N tasks to be allocated resources in the database node, for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task.

[0021] In an embodiment of the present application, the resource allocation method of the database node is applicable to a scenario in which N tasks are executed in parallel in the database node, where N is an integer greater than 1, and during the execution of the N tasks, the resources of each task are adaptively adjusted.

[0022] A task may refer to any task executed in a database node. An initial resource weight value may refer to a weight value pre-allocated to a task according to the CPU resources required for task execution when the task is executed. The initial resource weight value may be pre-configured according to execution requirements, or may be obtained by evaluating and calculating the CPU resources required for task execution. An initial resource proportion may refer to a percentage of CPU resources occupied by each task during execution, calculated based on the initial resource weight values ​​of N tasks.

[0023] Specifically, N tasks to be allocated resources in the database node are determined. For any task, the adjusted resource weight values ​​of the N tasks are added up to obtain a summed result. The ratio of the initial resource weight value of the task and the summed result is the initial resource ratio of the task, and the task is executed according to the initial resource ratio.

[0024] Step S102 , monitoring the real-time resource ratio during the task execution in real time, and calculating the historical resource ratio of the task based on the real-time resource ratio before the current moment.

[0025] In an embodiment of the present application, the real-time resource ratio may refer to the percentage of CPU resources actually occupied by a task during its execution. In order to improve the utilization rate of CPU resources by the database system, during the execution of the task, the CPU resources occupied by the task may be dynamically adjusted according to factors such as the actual execution status of the task and the importance of the task. The corresponding moment when the CPU resources occupied by the task are adjusted may be recorded as the current moment. The historical resource ratio may refer to the real-time resource ratio of the task monitored before the current moment.

[0026] Specifically, the real-time CPU resource usage during task execution can be monitored in real time through kernel components, such as control groups (Cgroup). When the initial resource ratio is adjusted according to factors such as task execution requirements, the real-time resource ratio of the task during execution before the current moment monitored by the Cgroup is obtained, and the historical resource ratio is calculated based on the obtained real-time resource ratio.

[0027] Step S103, obtaining the task weight value corresponding to the task, and calculating the adjusted resource weight value of the task according to the initial resource weight value of the task, the historical resource ratio and the task weight value.

[0028] Step S104, determine the adjustment resource ratio of the task according to the adjustment resource weight values ​​of the N tasks, execute the task according to the adjustment resource ratio of the task, and return to the step of performing real-time monitoring of the real-time resource ratio during the task execution process until the task execution is completed.

[0029] In an embodiment of the present application, the task weight value may refer to the weight value assigned to the task according to the importance of the task, and the adjusted resource weight value may refer to the CPU resource occupancy weight value after adaptively adjusting the initial resource weight value.

[0030] Specifically, for any task, the task weight value assigned to the task by the relevant operator according to the importance of the task can be obtained, and the initial resource weight value can be adaptively adjusted according to the initial resource weight value, historical resource ratio and task weight value of the task to obtain the adjustment resource weight value of the task, and the adjustment resource weight values ​​of the N tasks calculated in the current monitoring time period corresponding to the current moment are added to obtain the sum result, and the ratio of the adjustment resource weight value of the task and the sum result is the adjustment resource ratio of the task, and the task is executed according to the determined adjustment resource ratio, and at regular intervals, the step of executing the real-time resource ratio in the above-mentioned real-time monitoring task execution process is returned to perform real-time dynamic adjustment of the resource ratio of the task until the task is completed.

[0031] For example, if the distributed database system includes three database nodes, namely database node 1, database node 2 and database node 3, the resource allocation method of the database node is applied to any database node in the distributed database system. The following is an example of applying the resource allocation method to database node 1: There are three parallel-executed tasks in database node 1, namely, task 1, task 2 and task 3, among which task 3 is a specific task (its resource weight value is constant). If the control center of the distributed database system pre-allocates an initial resource weight value of 10 for task 1, an initial resource weight value of 20 for task 2, and a constant resource weight value of 10 for task 3, that is, the ratio of the initial resource weight values ​​of task 1, task 2 and task 3 is 10:20:10, and the task weight value assigned to task 1 according to the importance of task 1 is 1, and the task weight value assigned to task 2 according to the importance of task 2 is 2, that is, the ratio of the task weight values ​​of task 1 and task 2 is 1:2, then the overall process of the resource allocation method of task 1, task 2 and task 3 in the database node 1 can be: 1) According to the initial resource weight values ​​of Task 1, Task 2 and Task 3, the initial resource ratio of Task 1 is determined to be 25%, the initial resource ratio of Task 2 is 50%, and the initial resource ratio of Task 3 is 25%. Task 1, Task 2 and Task 3 are executed according to the initial resource ratios of 25%, 50% and 25% respectively; 2) Use Cgroup to monitor the real-time resource ratio of Task 1 and Task 2 in real time. If the average real-time resource ratio of Task 1 in the current monitoring time period corresponding to the current moment is 10%, and the historical resource ratio of Task 1 in the last five times before the current moment is 20%; the average real-time resource ratio of Task 2 in the current monitoring time period corresponding to the current moment is 20%, and the historical resource ratio of Task 2 in the last five times before the current moment is 30%; based on the average real-time resource ratio of Task 1 of 20% and the average real-time resource ratio of Task 2 of 10%, it can be determined that the ratio of the real-time resource weight values ​​of Task 1 and Task 2 is 2:1; based on the historical resource ratio of Task 1 of 20% and the historical resource ratio of Task 2 of 30%, it can be determined that the ratio of the historical resource weight values ​​of Task 1 and Task 2 is 2:3; 3) Based on the initial resource weight value of Task 1, which is 10, the task weight value, which is 1, the real-time resource weight value, which is 2, and the historical resource weight value, which is 2, the adjusted resource weight value of Task 1 can be calculated to be 10. 1 2+2=22. Accordingly, based on the initial resource weight value of Task 2, which is 20, the task weight value is 2, the real-time resource weight value is 1, and the historical resource weight value is 3, we can calculate that the adjusted resource weight value of Task 2 is 20. 2 1+3=43, and Task 3 is a specific task, and its constant resource weight value is 10; 4) According to the adjustment resource weight value 22 of Task 1, the adjustment resource weight value 43 of Task 2, and the constant resource weight value 10 of Task 3, it can be determined that the adjustment resource ratio of Task 1 is 30%, the adjustment resource ratio of Task 2 is 57%, and the adjustment resource ratio of Task 3 is 13%. Task 1, Task 2, and Task 3 are executed at the adjustment resource ratios of 30%, 57%, and 13%, respectively. At regular intervals, return to execute the step of monitoring the real-time resource ratios of Task 1 and Task 2 in real time through Cgroup in the above 2) to dynamically adjust the resources occupied by Task 1, Task 2, and Task 3 until the corresponding tasks are completed.

[0032] The embodiment of the present application automatically monitors the real-time resource ratio during the task execution process in real time, and dynamically and adaptively adjusts the resource ratio of the task according to the real-time resource ratio and the task weight value. This not only realizes the dynamic adjustment of resources according to the real-time execution of the task, but also realizes the dynamic adjustment of resources according to the task characteristics based on the task weight value. On the basis of improving the resource utilization of the database system, the adjusted resource ratio is also made closer to the task requirements.

[0033] See also Figure 2, is a flow chart of a method for allocating resources of a database node provided in Embodiment 2 of the present application. Figure 2 As shown, in the above step S102, the historical resource proportion of the task is calculated according to the real-time resource proportion before the current moment, which may include the following steps: Step S201, obtaining the real-time resource ratio in a preset number of historical monitoring time periods before the current moment.

[0034] Step S202: for any historical monitoring time period, average calculation is performed on the real-time resource proportion within the historical monitoring time period to obtain an average value of the real-time resource proportion within the historical monitoring time period.

[0035] Step S203, calculate the average of the real-time resource ratios in all historical monitoring time periods according to the preset number of times, obtain the overall real-time resource ratio average value in the historical monitoring time periods of the preset number of times before the current moment, and use the overall real-time resource ratio average value as the historical resource ratio of the task.

[0036] In an embodiment of the present application, the historical monitoring time period may refer to the time period for monitoring the real-time resource ratio of the task before the current moment, the preset number of times may refer to the preset number of historical monitoring time periods obtained, the average value of the real-time resource ratio may refer to the average value of all real-time resource ratios in each historical monitoring time period, and the overall real-time resource ratio average value may refer to the overall average value of the real-time resource ratios in all historical monitoring time periods obtained.

[0037] For example, the real-time resource proportions monitored in the last five consecutive historical monitoring time periods before the current moment are obtained, and the average real-time resource proportions in the five historical monitoring time periods can be 10%, 30%, 20%, 20% and 20% respectively. Then, the average overall real-time resource proportions in the last five consecutive historical monitoring time periods before the current moment can be (10%+30%+20%+20%+20%) / 5=20%, that is, the historical resource proportion is 20%.

[0038] In the embodiment of the present application, by calculating the average of the real-time resource proportions in the historical monitoring time period of the most recent preset number of times before the current moment, the average value of the overall real-time resource proportion is obtained as the historical resource proportion. The historical resource proportion can accurately reflect the overall resource usage of the task during the historical execution process. Based on the historical resource proportion, the possible resource requirements of future tasks can be predicted, so as to carry out resource planning in advance, avoid resource shortages or waste, improve resource utilization, and provide real and effective data support for better adjustment and optimization of the resource proportion of tasks.

[0039] See also Figure 3, is a flow chart of a method for allocating resources of a database node provided in Embodiment 3 of the present application. Figure 3 As shown, in the above step S103, the adjusted resource weight value of the task is calculated according to the initial resource weight value of the task, the historical resource ratio and the task weight value, which may include the following steps: Step S301, obtaining the real-time resource proportion in the current monitoring time period corresponding to the current moment, performing mean calculation on the real-time resource proportion in the current monitoring time period, and obtaining the average value of the real-time resource proportion in the current monitoring time period.

[0040] Step S302, determining the real-time resource weight value of the task according to the average real-time resource proportion of the N tasks in the current monitoring time period, and determining the historical resource weight value of the task according to the historical resource proportion of the N tasks.

[0041] Step S303, multiplying the initial resource weight value of the task, the task weight value and the real-time resource weight value to obtain the intermediate adjustment resource weight value of the task.

[0042] Step S304: Add the intermediate adjustment resource weight value and the historical resource weight value of the task to obtain the adjustment resource ratio of the task.

[0043] In an embodiment of the present application, the current monitoring time period may refer to the time period corresponding to the current moment for monitoring the real-time resource ratio of the task, the real-time resource weight value may refer to the resource weight value of the task determined based on the average value of the real-time resource ratio of N tasks in the current monitoring time period, the historical resource weight value may refer to the resource weight value of the task determined based on the historical resource ratio of N tasks, and the intermediate adjustment resource value may refer to the intermediate value of the calculated adjustment resource value.

[0044] For example, there are two tasks to be allocated resources in the database node, namely Task 1 and Task 2. The initial resource weight value of Task 1 is 10, and the task weight value of Task 1 is 3; the initial resource weight value of Task 2 is 20, and the task weight value of Task 2 is 2; If the average real-time resource ratio of Task 1 in the current monitoring period is 10%, the historical resource ratio of Task 1 is 20%; the average real-time resource ratio of Task 2 in the current monitoring period is 20%, the historical resource ratio of Task 2 is 30%; Based on the average real-time resource ratio of Task 1 (10%) and the average real-time resource ratio of Task 2 (20%), we can determine that the real-time resource weight of Task 1 is 1 and the real-time resource weight of Task 2 is 2. Based on the historical resource ratio of Task 1 (20%) and the historical resource ratio of Task 2 (30%), we can determine that the historical resource weight of Task 1 is 2 and the historical resource weight of Task 3 is 3. Based on the initial resource weight value of Task 1, which is 10, the task weight value, which is 3, the real-time resource weight value, which is 1, and the historical resource weight value, which is 2, we can calculate that the adjusted resource weight value of Task 1 is 10. 3 1+2=32. Based on the initial resource weight of Task 2, which is 20, the task weight of 2, the real-time resource weight of 2, and the historical resource weight of 3, we can calculate that the adjusted resource weight of Task 2 is 20. 2 2+3=83.

[0045] In the embodiment of the present application, the adjusted resource weight value is calculated based on the initial resource weight value, the task weight value, the average real-time resource ratio in the current monitoring time period and the historical resource ratio. This not only realizes the dynamic adjustment of resources according to the real-time execution of the task, but also realizes the dynamic adjustment of resources according to the task characteristics based on the task weight value. On the basis of improving the resource utilization of the database system, the adjusted resource ratio is also made closer to the task requirements.

[0046] See also Figure 4 , is a flow chart of a method for allocating resources of a database node provided in Embodiment 4 of the present application. Figure 4 As shown, after calculating the adjustment resource weight value of the task in the above step S103, the following steps may also be included: Step S401, detecting whether the adjustment resource weight value of the task is within a preset resource weight value range, if the adjustment resource weight value of the task is greater than the maximum value in the preset resource weight value range, taking the maximum value as the adjustment resource weight value of the task.

[0047] Step S402: If the adjustment resource ratio of the task is less than the minimum value in the preset resource weight value range, the minimum value is used as the adjustment resource weight value of the task.

[0048] In an embodiment of the present application, the preset resource weight value range may refer to a preset range of task resource weight values, including a maximum resource weight value and a minimum resource weight value.

[0049] For example, if the preset resource weight value range is [1, 99], that is, the maximum resource weight value is 99 and the minimum resource weight value is 1, if the adjusted resource weight value of the task after adaptive adjustment is 110, and the adjusted resource weight value 110 is greater than the maximum resource weight value 99, then the maximum value 99 of the preset resource weight value range is used as the adjusted resource weight value of the task; if the adjusted resource weight value after adaptive adjustment is 0.5, and the adjusted resource weight value 0.5 is less than the minimum resource weight value 1, then the minimum value 1 of the preset resource weight value range is used as the adjusted resource weight value of the task.

[0050] In the embodiment of the present application, if the adjusted resource weight value is greater than the maximum value of the preset resource weight value range, the maximum value is used as the adjusted resource weight value, thereby avoiding a situation where a single task excessively occupies CPU resources, causing other tasks to run slowly or crash due to insufficient resources. If the adjusted resource weight value is less than the minimum value of the preset resource weight value range, the minimum value is used as the adjusted resource weight value, thereby ensuring that even unimportant tasks can obtain necessary resource allocation, thereby maintaining the basic operation of the task, thereby improving the stability of the database system.

[0051] See also Figure 5 , is a flow chart of a method for allocating resources of a database node provided in Embodiment 5 of the present application. Figure 5 As shown, the resource allocation method may further include the following steps: Step S501, obtaining a constant resource weight value set for a specific task.

[0052] After determining the initial resource ratio of any task according to the initial resource weight values ​​of N tasks in the above step S101, the following further includes: Step S502, determining the initial resource proportion of the specific task according to the constant resource weight value and the initial resource weight values ​​of the N tasks, and executing the specific task according to the initial resource proportion of the specific task.

[0053] After determining the adjustment resource proportions of the tasks according to the adjustment resource weight values ​​of the N tasks in the above step S104, the method further includes: Step S503, determine the adjustment resource ratio of the specific task according to the constant resource weight value and the adjustment resource weight values ​​of N tasks, execute the specific task according to the adjustment resource ratio of the specific task, and return to execute the real-time resource ratio during the execution of the real-time monitoring task until the specific task is completed.

[0054] In an embodiment of the present application, the constant resource weight value may refer to an unchanging resource weight value allocated for the execution of a specific task. For example, the specific task may refer to a system task.

[0055] For example, if there are two tasks to be allocated resources in the database node, namely Task 1, Task 2 and Task 3, among which Task 3 is a specific task, the initial resource weight value of Task 1 is 10, the initial resource weight value of Task 2 is 20, and the constant resource weight value of Task 3 is 10; In the initial stage, according to the initial resource weight values ​​of Task 1 and Task 2 and the constant resource weight value of Task 3, it can be determined that the initial resource ratio of Task 1 is 25%, the initial resource ratio of Task 2 is 50%, and the initial resource ratio of Task 3 is 25%. Task 1, Task 2, and Task 3 are executed according to the initial resource ratios of 25%, 50%, and 25%, respectively; During the execution process, the adjustment resource weight values ​​of Task 1 and Task 2 are dynamically adjusted. If the adjustment resource weight value of Task 1 is calculated to be 12, and the adjustment resource weight value of Task 2 is 24, then according to the adjustment resource weight values ​​of Task 1 and Task 2 and the constant resource weight value of Task 3, it can be determined that the adjustment resource proportion of Task 1 is 26%, the adjustment resource proportion of Task 2 is 52%, and the adjustment resource proportion of Task 3 is 22%. Task 1, Task 2 and Task 3 are executed according to the initial resource proportions of 26%, 52% and 22%, respectively, and the adjustment resource proportion of Task 3 is updated at regular intervals according to the dynamically adjusted adjustment resource weight values ​​of Task 1 and Task 2 until Task 3 is completed.

[0056] In the embodiment of the present application, for a specific task, the adjustment resource ratio of the specific task is always calculated together with the constant resource weight value set for the specific task and the adjustment resource weight value dynamically adjusted for other tasks. Combined with the dynamically adjusted resource weight values ​​of other tasks, the resource ratio of the specific task can be flexibly adjusted according to the current resource status of the system and the resource requirements of other tasks, thereby ensuring that the specific task can obtain the necessary resources during the execution process, optimizing its execution efficiency, helping to reduce the task execution time, and improving the task completion rate.

[0057] Corresponding to the resource allocation method of the database node in the above embodiment, Figure 6 The structure block diagram of the resource allocation device of the database node provided by the sixth embodiment of the present application is shown. For the convenience of description, only the part related to the embodiment of the present application is shown.

[0058] See also Figure 6 , the resource allocation device comprises: The first execution module 61 is used to determine N tasks to be resource-allocated in the database node, and for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task, where N is an integer greater than 1; The first monitoring module 62 is used to monitor the real-time resource ratio during the execution of the task in real time, and calculate the historical resource ratio of the task according to the real-time resource ratio before the current moment; A first adjustment module 63 is used to obtain a task weight value corresponding to the task, and calculate an adjustment resource weight value of the task according to the initial resource weight value, historical resource ratio and task weight value of the task; The first loop module 64 is used to determine the adjustment resource ratio of the task according to the adjustment resource weight values ​​of the N tasks, execute the task according to the adjustment resource ratio of the task, and return to the step of real-time monitoring of the real-time resource ratio during the execution of the task until the task is executed. Optionally, the first monitoring module 62 includes: A first acquisition unit is used to acquire the real-time resource ratio in a preset number of historical monitoring time periods before the current moment; A second mean value calculation unit is used to perform mean value calculation on the real-time resource proportion in any historical monitoring time period to obtain an average value of the real-time resource proportion in the historical monitoring time period; The third mean calculation unit is used to perform mean calculation on the average value of the real-time resource proportion in all historical monitoring time periods according to the preset number of times, to obtain the overall real-time resource proportion average value in the historical monitoring time periods of the preset number of times before the current moment, and to use the overall real-time resource proportion average value as the historical resource proportion of the task.

[0059] Optionally, the first adjustment module 63 includes: A first mean value calculation unit is used to obtain the real-time resource proportion in the current monitoring time period corresponding to the current moment, perform mean calculation on the real-time resource proportion in the current monitoring time period, and obtain an average value of the real-time resource proportion in the current monitoring time period; A resource weight value calculation unit, used to determine the real-time resource weight value of the task according to the average value of the real-time resource proportion of the N tasks in the current monitoring time period, and determine the historical resource weight value of the task according to the historical resource proportion of the N tasks; A first operation unit is used to perform a multiplication operation on the initial resource weight value, the task weight value and the real-time resource weight value of the task to obtain an intermediate adjustment resource weight value of the task; The second operating unit is used to add the intermediate adjustment resource weight value and the historical resource weight value of the task to obtain the adjustment resource weight value of the task.

[0060] Optionally, the resource allocation device further includes: A second adjustment module is used to detect whether the adjustment resource weight value of the task is within a preset resource weight value range, and if the adjustment resource weight value of the task is greater than a maximum value in the preset resource weight value range, the maximum value is used as the adjustment resource weight value of the task; The third adjustment module is used to use the minimum value as the adjustment resource weight value of the task if the adjustment resource proportion of the task is less than the minimum value in the preset resource weight value range.

[0061] Optionally, the resource allocation device further includes: The second acquisition module is used to obtain the constant resource ratio set for a specific task; A second execution module, configured to determine an initial resource ratio of the specific task according to the constant resource weight value and the initial resource weight values ​​of the N tasks, and execute the specific task according to the initial resource ratio of the specific task; The second loop module is used to determine the adjustment resource ratio of the specific task according to the constant resource weight value and the adjustment resource weight values ​​of the N tasks, execute the specific task according to the adjustment resource ratio of the specific task, and return to execute the real-time monitoring of the real-time resource ratio during the execution of the task until the specific task is completed.

[0062] Optionally, the first execution module 61 includes: A first summing calculation unit, configured to sum the adjustment resource weight values ​​of the N tasks to obtain a first summing result; A first ratio calculation unit, configured to calculate the ratio of the initial resource weight value of the task and the sum as the initial resource ratio of the task; Optionally, the first circulation module 64 includes: A second summing calculation unit, used for summing the adjustment resource weight values ​​of the N tasks to obtain a second summing result; The second ratio calculation unit is used to calculate the ratio of the adjustment resource weight value of the task and the second addition result as the adjustment resource ratio of the task.

[0063] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0064] Figure 7 This is a schematic diagram of the structure of a computer device provided in Example 7 of this application. Figure 7 As shown, the computer device of this embodiment includes: at least one processor ( Figure 7 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps in the resource allocation method embodiment of any of the above-mentioned database nodes are implemented.

[0065] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 7 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.

[0066] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0067] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments, it may also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.

[0068] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0069] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.

[0070] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0071] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0072] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0073] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0074] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for allocating resources of a database node, characterized in that: The resource allocation method comprises: Determine N tasks to be resource-allocated in the database node, and for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task, where N is an integer greater than 1; Monitor the real-time resource ratio during the execution of the task in real time, and calculate the historical resource ratio of the task based on the real-time resource ratio before the current moment; Obtaining a task weight value corresponding to the task, and calculating an adjusted resource weight value of the task according to the initial resource weight value, historical resource ratio and task weight value of the task; According to the adjustment resource weight values ​​of the N tasks, determine the adjustment resource ratio of the task, execute the task according to the adjustment resource ratio of the task, and return to the step of real-time monitoring of the real-time resource ratio during the execution of the task until the task is completed.

2. The method for allocating resources of a database node according to claim 1, characterized in that: The historical resource ratio of the task is calculated based on the real-time resource ratio before the current moment, including: Obtain the real-time resource ratio within a preset number of historical monitoring time periods before the current moment; For any historical monitoring time period, the average of the real-time resource proportions in the historical monitoring time period is calculated to obtain an average value of the real-time resource proportions in the historical monitoring time period; According to the preset number of times, the average value of the real-time resource proportion in all historical monitoring time periods is averaged to obtain the overall real-time resource proportion average value in the preset number of historical monitoring time periods before the current moment, and the overall real-time resource proportion average value is used as the historical resource proportion of the task.

3. The method for allocating resources of a database node according to claim 1, characterized in that: The step of calculating the adjusted resource weight value of the task according to the initial resource weight value, the historical resource proportion and the task weight value of the task includes: Obtain the real-time resource proportion in the current monitoring time period corresponding to the current moment, perform mean calculation on the real-time resource proportion in the current monitoring time period, and obtain an average value of the real-time resource proportion in the current monitoring time period; Determine the real-time resource weight value of the task according to the average value of the real-time resource proportion of the N tasks in the current monitoring time period, and determine the historical resource weight value of the task according to the historical resource proportion of the N tasks; The initial resource weight value, the task weight value and the real-time resource weight value of the task are multiplied to obtain the intermediate adjustment resource weight value of the task; The intermediate adjustment resource weight value and the historical resource weight value of the task are added together to obtain the adjustment resource weight value of the task.

4. The method for allocating resources of a database node according to claim 1, characterized in that: After the calculation obtains the adjustment resource weight value of the task, the method further includes: Detecting whether the adjustment resource weight value of the task is within a preset resource weight value range, and if the adjustment resource weight value of the task is greater than a maximum value in the preset resource weight value range, taking the maximum value as the adjustment resource weight value of the task; If the adjustment resource ratio of the task is less than the minimum value in the preset resource weight value range, the minimum value is used as the adjustment resource weight value of the task.

5. The method for allocating resources of a database node according to claim 1, characterized in that: The resource allocation method further comprises: Get the constant resource weight value set for a specific task; After determining the initial resource proportion of any task according to the initial resource weight values ​​of the N tasks, the method further includes: Determine the initial resource proportion of the specific task according to the constant resource weight value and the initial resource weight values ​​of the N tasks, and execute the specific task according to the initial resource proportion of the specific task; After determining the adjustment resource proportion of the task according to the adjustment resource weight values ​​of the N tasks, the method further includes: According to the constant resource weight value and the adjustment resource weight values ​​of the N tasks, determine the adjustment resource ratio of the specific task, execute the specific task according to the adjustment resource ratio of the specific task, and return to execute the real-time monitoring of the real-time resource ratio during the execution of the task until the specific task is completed.

6. The method for allocating resources of a database node according to claim 1, characterized in that: For any task, determining the initial resource proportion of the task according to the initial resource weight values ​​of the N tasks includes: Adding and calculating the adjustment resource weight values ​​of the N tasks to obtain a first sum result; The ratio of the initial resource weight value of the task and the sum is taken as the initial resource ratio of the task; Correspondingly, determining the proportion of the adjustment resources of the task according to the adjustment resource weight values ​​of the N tasks includes: Adding and calculating the adjustment resource weight values ​​of the N tasks to obtain a second sum result; The ratio of the adjustment resource weight value of the task and the second sum result is used as the adjustment resource proportion of the task.

7. A resource allocation device for a database node, characterized in that: The resource allocation device comprises: A first execution module, used to determine N tasks to be resource-allocated in the database node, and for any task, determine the initial resource ratio of the task according to the initial resource weight values ​​of the N tasks, and execute the task according to the initial resource ratio of the task, where N is an integer greater than 1; The first monitoring module is used to monitor the real-time resource ratio during the execution of the task in real time, and calculate the historical resource ratio of the task according to the real-time resource ratio before the current moment; A first adjustment module is used to obtain a task weight value corresponding to the task, and calculate an adjustment resource weight value of the task according to an initial resource weight value, a historical resource ratio and a task weight value of the task; The first loop module is used to determine the adjustment resource ratio of the task according to the adjustment resource weight values ​​of the N tasks, execute the task according to the adjustment resource ratio of the task, and return to the step of real-time monitoring of the real-time resource ratio during the execution of the task until the task is completed.

8. The resource allocation device for a database node according to claim 7, characterized in that: The first adjustment module includes: A first mean value calculation unit is used to obtain the real-time resource proportion in the current monitoring time period corresponding to the current moment, perform mean calculation on the real-time resource proportion in the current monitoring time period, and obtain an average value of the real-time resource proportion in the current monitoring time period; A resource weight value calculation unit, used to determine the real-time resource weight value of the task according to the average value of the real-time resource proportion of the N tasks in the current monitoring time period, and determine the historical resource weight value of the task according to the historical resource proportion of the N tasks; A first operation unit is used to perform a multiplication operation on the initial resource weight value, the task weight value and the real-time resource weight value of the task to obtain an intermediate adjustment resource weight value of the task; The second operating unit is used to add the intermediate adjustment resource weight value and the historical resource weight value of the task to obtain the adjustment resource weight value of the task.

9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the resource allocation method for a database node according to any one of claims 1 to 6 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the resource allocation method for a database node according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Request processing method and server

    CN110377415A

  • Resources use method, electronic device and computer program product

    CN113742028A

  • Cluster multi-task sliding window scheduling processing method, system, equipment and medium

    CN116149821A

  • Cluster resource scheduling method and device, computer equipment and storage medium

    CN116661957A

  • Batch task scheduling method and system, electronic equipment and storage medium

    CN117149388A