Method and device for dynamically limiting off-line task resources in off-line mixed part
By monitoring the cgroup kernel interface and message queue mechanism, the quota of offline task resources is dynamically adjusted, which solves the problem of insufficient control of the proportion of offline task resource occupancy in the existing technology, and achieves efficient resource utilization and guarantees the quality of online business services.
Patent Information
- Application Number
- CN202410590278.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2024-08-23
AI Technical Summary
Existing technologies fail to effectively limit the overall upper limit of resource usage by offline tasks in hybrid deployment scenarios, resulting in a decline in online business service quality and failure to achieve effective control of resource utilization.
By continuously monitoring the cgroup kernel interface, resource update events are captured in real time and sent to the offline engine module through the message queue. The resource quotas of offline tasks are dynamically adjusted, and upper limits of CPU and memory resources are set to form hard resource limits to ensure efficient utilization of resources. Reasonable allocation.
It achieves refined and dynamic management of offline task resources in an offline mixed-deployment environment, improves resource utilization, ensures the stability and performance of online services, and reduces operation and maintenance complexity.
Smart Images

Figure CN118535327A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and in particular to a method and device for dynamically limiting offline task resources in offline colocation. Background Art
[0002] In recent years, with the widespread application of cloud native technologies, effective management and efficient utilization of cluster resources have become one of the core issues in the field of cloud computing. In hybrid deployment (co-location) scenarios, especially when online and offline services are integrated and run in the same cluster, resource utilization has been significantly improved. However, the peak problem caused by co-location has become a key challenge that needs to be solved urgently. Online services require guaranteed quality of service (QoS) due to their latency sensitivity and bursty resource demand. Although offline services are not sensitive to latency, they may affect online service performance due to high resource consumption.
[0003] In the prior art, such as the Chinese patent application with application number CN202310872087.0, attempts to improve node resource utilization through Kubernetes cluster resource super-division technology, and effectively improves the utilization efficiency of cluster resources by dynamically calculating super-divided resources and reasonably allocating them to applications, but does not set a clear total control mechanism to prevent offline tasks from over-consuming resources to ensure the QoS of online services. In addition, such as the Chinese patent application with application number CN202310369688.X, the hybrid scheduling method for deep learning loads, although it can generate a scheduling scheme based on shared throughput data and task queues to ensure that the online load delay limit is not affected and the offline load execution efficiency is taken into account, it also fails to make a direct restriction on the overall resource occupancy rate of offline tasks. Furthermore, the Chinese patent application with application number CN20221122230.6 records the interference quantification method of the hybrid load. Although it can accurately quantify the degree of resource competition between online and offline loads by calculating the interference entropy value, this still does not provide a systematic solution to limit the overall upper limit of offline tasks' use of resources to avoid unacceptable service quality degradation for online services. Finally, the Chinese patent application with application number CN202310357883.0 proposes a container scheduling algorithm based on affinity and anti-affinity awareness for the service co-location container scheduling method in a cloud environment, which realizes optimized scheduling in multiple dimensions of performance, energy consumption and resource utilization. However, it also does not set a global threshold specifically for offline task resource utilization to ensure that while improving resource utilization efficiency, the performance stability of online business will not be sacrificed.
[0004] In summary, the current colocation technology has made some progress in improving cluster resource utilization, but in practical applications, especially when dealing with the balance between offline business resource requirements and online business service quality assurance, there is no effective restriction on the total resource utilization of offline tasks at the technical level, which undoubtedly increases the risk of online business being scrambled for offline task resources and reduces the overall reliability of business operations in the colocation environment. Therefore, it is of great value and practical significance to design and implement a technical solution that can fully utilize cluster resources and strictly control the proportion of offline task resources, thereby effectively protecting the quality of online business services. Summary of the invention
[0005] The technical problem to be solved by the present invention is: in response to the technical problems existing in the prior art, the present invention provides a method and device for dynamically limiting offline task resources in offline colocation with high reliability and stability, which can control the proportion of offline task resources occupied while making full use of cluster resources, so as to effectively improve resource utilization.
[0006] In order to solve the above technical problems, the technical solution proposed by the present invention is:
[0007] A method for dynamically limiting offline task resources in offline colocation includes the following steps:
[0008] Step S01. Continuously monitor the cgroup kernel interface, capture resource update events in real time, and when the cluster static resources change, send the static resource changes to the offline engine module through the message queue;
[0009] Step S02. The offline engine module dynamically adjusts the resource quota of offline tasks, creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
[0010] Furthermore, in step S01, the real-time capture of resource update events is to filter the messages reported to the message queue by the Agent node to obtain offline task resource change information and extract designated fields.
[0011] Furthermore, in step S02, the resource quota of the offline task is dynamically adjusted by monitoring the overall resource usage of the cluster in real time. When it is detected that a new offline task is created or an existing offline task is terminated, the resource adjustment mechanism is triggered. The resource quota of the offline task includes:
[0012] CPU usage threshold, used to limit the maximum percentage of CPU resources occupied by offline tasks;
[0013] Network watermark configuration is used to limit the network bandwidth that can be used by offline tasks;
[0014] Memory recycling mechanism, used to set different levels of memory usage limits.
[0015] Furthermore, in step S02, the corresponding processing rules for creating offline Pods in the cluster include:
[0016] Step S201. When a resource is updated, detailed information related to the resource update is obtained, and it is determined whether the current resource update is an offline task. If it is an offline task, step S02 is executed;
[0017] Step S202. Check whether there is a pod directory corresponding to the current offline task under the offline directory. If there is no corresponding pod directory, create a subdirectory under the offline directory. If there is a corresponding pod directory, compare whether the content under the pod directory is consistent with the value of the cgroup kernel interface. If not, execute step S203.
[0018] Step S203: Copy the value of the cgroup kernel interface to the offline directory of the corresponding pod to achieve unified management and update.
[0019] Furthermore, it also includes constructing a dedicated offline task management directory for storing resource quota information of all offline tasks.
[0020] Furthermore, the static resource changes include changing kernel interface values, creating a new container directory, deleting a container directory, and starting a new process.
[0021] A device for dynamically limiting offline task resources in offline colocation, comprising:
[0022] The resource usage monitoring module is used to continuously monitor the cgroup kernel interface and capture resource update events in real time. When the static resources of the cluster change, the static resource changes are sent to the offline engine module through the message queue. The static resources are relatively fixed resource limits that are configured during program operation.
[0023] Resource quota adjustment module: The offline engine module dynamically adjusts the resource quota of offline tasks, creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
[0024] Furthermore, the resource usage monitoring module includes an offline task change information acquisition unit, which is used to filter the messages reported by the Agent node to the message queue to obtain offline task resource change information and extract specified fields.
[0025] A computer device includes a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the above method.
[0026] A computer-readable storage medium storing a computer program, wherein the computer program executes the above method.
[0027] Compared with the prior art, the advantages of the present invention are:
[0028] The present invention monitors the static changes of cluster resources in real time by continuously monitoring the cgroup kernel interface. When events such as the creation and deletion of container directories occur, the events are passed to the offline engine module through the message queue. After receiving the resource change message, the offline engine module dynamically adjusts the resource quota used by the offline task. At the same time, the offline tasks are centrally managed under the specified directory and the CPU and memory upper limits are set separately for each offline task. The present invention realizes the refined and dynamic management of offline task resources in an offline mixed deployment environment. Through the cgroup technology and the message queue mechanism, the efficient utilization and reasonable allocation of resources are realized, which can not only ensure that offline tasks make full use of idle resources when cluster resources are sufficient, but also ensure that online services are not affected when resources are tight. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 The flowchart is a method for dynamically limiting offline task resources in offline colocation according to an embodiment of the present invention.
[0030] Figure 2 This is a diagram of the offline colocation directory structure in an embodiment of the present invention.
[0031] Figure 3 This is a flow chart of offline task processing rules according to an embodiment of the present invention.
[0032] Figure 4 Schematic diagram of the system architecture of an embodiment of the present invention DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] like Figure 1 As shown, the method for dynamically limiting offline task resources in offline colocation in this embodiment includes the following steps:
[0035] Step S01. Continuously monitor the cgroup kernel interface, capture resource update events in real time, and when the cluster static resources change, send the static resource changes to the offline engine module through the message queue.
[0036] This embodiment can capture resource update events in real time by continuously monitoring the cgroup kernel interface, and quickly respond to changes in cluster static resources, thereby achieving dynamic adjustment of offline task resource usage and improving the real-time and flexibility of resource management.
[0037] In this embodiment, the resource update event is captured in real time, and the messages reported to the message queue by the Agent node are screened to obtain the offline task resource change information and extract the specified field.
[0038] Specifically, the Agent node monitors and collects the status changes of system resources in real time, such as changes in CPU usage, increases and decreases in memory usage, and changes in other resources. Whenever the resource status changes, the Agent node sends the change information to the message queue. Since the offline engine module only focuses on the usage of resources directly related to offline tasks, such as CPU and memory, after receiving the message sent by the Agent node, the message notification service will perform a filtering operation to filter out messages related to offline task resource changes. The filtered offline resource change messages are parsed to extract the specific field information required by the offline engine module.
[0039] In this embodiment, static resource changes include changing kernel interface values, creating a new container directory, deleting a container directory, and starting a new process.
[0040] Step S02. The offline engine module dynamically adjusts the resource quota of offline tasks, creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
[0041] In this embodiment, the resource quota of offline tasks is dynamically adjusted by monitoring the overall resource usage of the cluster in real time. When a new offline task is created or an existing offline task is terminated, the resource adjustment mechanism is triggered. The resource quota of offline tasks includes:
[0042] CPU usage threshold, used to limit the maximum percentage of CPU resources occupied by offline tasks;
[0043] Network watermark configuration is used to limit the network bandwidth that can be used by offline tasks;
[0044] Memory recycling mechanism, used to set different levels of memory usage limits.
[0045] In a specific application embodiment, the corresponding offline task configuration is dynamically adjusted for the offline resources of the cluster, so as to achieve real-time adjustment of various resource parameter configurations of offline tasks according to the actual usage of offline resources in the cluster under the premise of normal system operation. The offline strategy includes but is not limited to the setting of the network waterline netConfig, the setting of memory recycling cacheConfig, and the offline task resource quota offlineConfig. Specifically, a common resource usage upper limit is set for all offline tasks. If a resource quota is not specified for an offline task, the default strategy preset by the system is adopted. The detailed offline rules are defined in json format, and the example is as follows:
[0046]
[0047] like Figure 2 As shown, in this embodiment, a dedicated offline task management directory is also constructed to store resource quota information of all offline tasks.
[0048] Specifically, for each pod in the cluster, a corresponding offline task processing strategy is formulated to ensure that each offline task can be adapted to the corresponding Pod. During the implementation process, the offline tasks originally scattered in different locations are moved to a specially established "offline" directory for integrated management. Through a centralized management model, flexible resource allocation is achieved based on the real-time resource status of the entire cluster and the specific resource requirements of each offline task. While ensuring the normal operation of online services, the idle resources in the cluster can be fully utilized to process offline tasks. This significantly improves the overall resource utilization of the cluster and ensures that offline computing workloads are efficiently executed without interfering with online business.
[0049] like Figure 3 As shown, in this embodiment, corresponding processing rules are created for offline Pods in the cluster, including:
[0050] Step S201. When a resource is updated, detailed information related to the resource update is obtained, and it is determined whether the current resource update is an offline task. If it is an offline task, step S02 is executed;
[0051] Step S202. Check whether there is a pod directory corresponding to the current offline task under the offline directory. If there is no corresponding pod directory, create a subdirectory under the offline directory. If there is a corresponding pod directory, compare the content under the pod directory with the value of the cgroup kernel interface to see if they are consistent. If not, execute step S203.
[0052] Step S203: Copy the value of the cgroup kernel interface to the offline directory of the corresponding pod to achieve unified management and update.
[0053] This embodiment creates specific resource processing rules for each offline Pod, and independently sets the CPU and memory resource upper limits for each offline task. Fine-grained resource control not only ensures the performance of offline tasks, but also prevents system stability problems caused by excessive resource consumption. It can fully utilize cluster resources and strictly control the proportion of offline task resources, thereby effectively protecting the quality of online business services. It simplifies the complexity of offline task resource management, facilitates operation and maintenance personnel to more intuitively view and manage offline task resource usage, and facilitates the implementation of a unified resource scheduling strategy. During the entire dynamic resource adjustment process, there is no need to restart the offline mixed deployment system. While ensuring the stable operation of the system, it ensures the service continuity of offline tasks, reducing the complexity and potential risks of operation and maintenance.
[0054] like Figure 4 As shown, in a specific application embodiment, when a resource update event occurs, the system will automatically trigger a series of operations, including calling API services, message notification services, and offline engines, and finally processing offline tasks. The entire process is coordinated and managed through the message queue to ensure the flow of information in the system. Specifically, the following steps are included:
[0055] Step 1. The user or system administrator initiates a resource management request through the API service, such as setting resource quotas, network watermarks, or memory recycling mechanisms. After receiving the above request, the API service converts it into a message format that can be processed internally by the system and puts these messages into the message queue so that the offline engine module can process them asynchronously.
[0056] Step 2. The system monitors the activities of the cgroup kernel interface, including but not limited to resource update events such as changes in kernel interface values, additions and deletions of container directories, and the start of new processes. When a resource update event occurs, the resource update event information is encapsulated into a message and sent to the message queue, waiting for further processing by the offline engine module.
[0057] Step 3. The message notification service is responsible for monitoring the entire message queue and filtering out messages related to cluster resource changes, such as specific information on resource creation, update, and deletion operations. The filtered messages related to cluster resource changes are parsed and processed and then delivered to the message queue again to ensure that the offline engine module can receive complete and accurate resource change notifications.
[0058] Step 4. The offline engine module continuously monitors the message queue. When a request for resource management or a resource update event is found, the corresponding offline task processing operation is performed, including: adjusting the resource allocation of offline tasks according to the new resource quota, updating the network configuration according to the network waterline setting, and adjusting the memory management strategy according to the memory recovery mechanism.
[0059] Among them, the message queue plays a central coordinating role in the whole process. As a communication channel between different service components, it ensures the decoupling and asynchronous communication capabilities between various components. By using message queues, each component can run independently and scale horizontally, which improves the elasticity and scalability of the system, and also makes resource management more flexible and efficient.
[0060] This embodiment receives and processes resource management requests through API services, uses message queues for cross-component communication, and combines real-time monitoring of resource update events to enable the offline engine module to adjust the offline task resource allocation strategy in real time, thereby effectively improving resource utilization efficiency and enhancing system stability and adaptability.
[0061] This embodiment also provides a device for dynamically limiting offline task resources in offline colocation, including:
[0062] The resource usage monitoring module is used to continuously monitor the cgroup kernel interface and capture resource update events in real time. When the static resources of the cluster change, the static resource changes are sent to the offline engine module through the message queue. Static resources are relatively fixed resource limits that are configured during program operation.
[0063] Resource quota control module, the offline engine module dynamically adjusts the resource quota of offline tasks, and creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
[0064] In this embodiment, the resource usage monitoring module includes an offline task change information acquisition unit, which is used to filter the messages reported by the Agent node to the message queue to obtain offline task resource change information and extract specified fields.
[0065] In this embodiment, the apparatus for dynamically limiting offline task resources in offline colocation corresponds to the method for dynamically limiting offline task resources in offline colocation, and they are not described one by one here.
[0066] This embodiment further provides a computer device, including a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.
[0067] It is understandable that the above method of this embodiment can be executed by a single device, such as a computer or server, etc., and can also be applied to a distributed scenario and completed by multiple devices in cooperation with each other. In the case of a distributed scenario, one of the multiple devices can only execute one or more steps in the above method of this embodiment, and multiple devices interact to complete the above method. The processor can be implemented in the form of a general-purpose CPU, a microprocessor, an application-specific integrated circuit, or one or more integrated circuits, etc., for executing related programs to implement the above method of this embodiment. The memory can be implemented in the form of a read-only memory ROM, a random access memory RAM, a static storage device, and a dynamic storage device. The memory can store an operating system and other applications. When the above method of this embodiment is implemented by software or firmware, the relevant program code is stored in the memory and called and executed by the processor.
[0068] This embodiment further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0069] Those skilled in the art will appreciate that the above-mentioned embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The above are only preferred embodiments of the present invention and are not intended to limit the present invention in any form. Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.
[0070] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.
Claims
1. A method for dynamically limiting offline task resources in offline colocation. It is characterized in that The following steps are involved: Step S01. Continuously monitor the cgroup kernel interface, capture resource update events in real time, and when the cluster static resources change, send the static resource changes to the offline engine module through the message queue; Step S02. The offline engine module dynamically adjusts the resource quota of offline tasks, creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
2. The method for dynamically limiting offline task resources in offline colocation according to claim 1, It is characterized in that In step S01, the real-time capture of resource update events is to filter the messages reported to the message queue by the Agent node to obtain offline task resource change information and extract designated fields.
3. The method for dynamically limiting offline task resources in offline colocation according to claim 1, It is characterized in that In step S02, the resource quota of the offline task is dynamically adjusted by monitoring the overall resource usage of the cluster in real time. When a new offline task is created or an existing offline task is terminated, the resource adjustment mechanism is triggered. The resource quota of the offline task includes: CPU usage threshold, used to limit the maximum percentage of CPU resources occupied by offline tasks; Network watermark configuration is used to limit the network bandwidth that can be used by offline tasks; Memory recycling mechanism, used to set different levels of memory usage limits.
4. The method for dynamically limiting offline task resources in offline colocation according to claim 1, It is characterized in that In step S02, the corresponding processing rules for creating offline Pods in the cluster include: Step S201. When a resource is updated, detailed information related to the resource update is obtained, and it is determined whether the current resource update is an offline task. If it is an offline task, step S02 is executed; Step S202. Check whether there is a pod directory corresponding to the current offline task under the offline directory. If there is no corresponding pod directory, create a subdirectory under the offline directory. If there is a corresponding pod directory, compare whether the content under the pod directory is consistent with the value of the cgroup kernel interface. If not, execute step S203. Step S203: Copy the value of the cgroup kernel interface to the offline directory of the corresponding pod to achieve unified management and update.
5. The method for dynamically limiting offline task resources in offline colocation according to any one of claims 1 to 4, It is characterized in that It also includes building a dedicated offline task management directory to store resource quota information of all offline tasks.
6. The method for dynamically limiting offline task resources in offline colocation according to any one of claims 1 to 4, It is characterized in that The static resource changes include changing kernel interface values, creating a new container directory, deleting a container directory, and starting a new process.
7. A device for dynamically limiting offline task resources in offline colocation, It is characterized in that include The resource usage monitoring module is used to continuously monitor the cgroup kernel interface and capture resource update events in real time. When the static resources of the cluster change, the static resource changes are sent to the offline engine module through the message queue. The static resources are relatively fixed resource limits that are configured during program operation. Resource quota adjustment module: The offline engine module dynamically adjusts the resource quota of offline tasks, creates corresponding processing rules for offline Pods in the cluster, moves offline tasks to a designated directory for central management, and sets CPU and memory resource limits for each offline task to form hard resource limits.
8. The device for dynamically limiting offline task resources in offline colocation according to claim 7, It is characterized in that The resource usage monitoring module includes an offline task change information acquisition unit, which is used to filter the messages reported to the message queue by the Agent node to obtain offline task resource change information and extract specified fields.
9. A computer device comprising a processor and a memory, wherein the memory is used to store a computer program. It is characterized in that The processor is configured to execute the computer program to perform the method according to any one of claims 1 to 6.
10. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Resource allocation method and device, computer equipment, storage medium and program product
CN120029774A
