Method for automatically scheduling offline applications according to application types
By automatically scheduling offline applications based on application types and cluster monitoring information, the problems of low scheduling flexibility and high labor costs in the existing technology are solved, and efficient utilization and reasonable allocation of resources are achieved.
Patent Information
- Application Number
- CN202111110826.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-18
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-09-18
AI Technical Summary
The existing technology has the problems of low flexibility and high labor cost when scheduling offline applications. Especially when resource occupancy is irregular, cluster resources cannot be effectively utilized.
By classifying offline applications according to preset classification standards, automatically scheduling offline applications according to cluster monitoring indicators and preset scheduling rules, and using task pools and CRDs to define monitoring indicators and scheduling rules, automatic sensing and scheduling of resources can be achieved.
It improves the flexibility and efficiency of offline application scheduling, reduces labor costs, ensures reasonable allocation and utilization of resources, and is suitable for cluster environments with irregular resources.
Smart Images

Figure CN113791885B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed computing technology, and in particular to a method for automatically scheduling offline applications according to application types in a container cluster. Background Art
[0002] During the operation of online applications, resource utilization is a dynamic process, which usually presents periodicity, with obvious peak and valley periods. For example, online applications have more visits during the day and less visits at night, and more visits during holidays and less visits on weekdays, which makes online applications have idle resources during valley periods. In addition to online applications, enterprises also need to run offline applications, which do not provide external services and are executed independently. They can be applications such as data collection, statistical analysis, and resource recycling. These services do not require immediate operation. Offline applications that require computing resources are assigned to run during the valley period of online applications.
[0003] Currently, tools such as Crontab are used to regularly assign offline applications that require computing resources to run during the off-peak period of online applications. However, the relevant technology requires the specification of application running rules, which consumes manpower. In the actual application process, there are different off-peak time periods on weekdays and holidays, and the occupancy of cluster resources does not show a periodic regularity. This situation cannot be controlled by timing applications, and applications can only be managed manually. This makes the relevant technology have the disadvantages of low application scheduling flexibility and high labor costs. Summary of the invention
[0004] In view of this, a method for automatically scheduling offline applications according to application types is provided to solve the problems of low flexibility and high labor cost in offline application scheduling in related technologies.
[0005] The present invention adopts the following technical solution:
[0006] A method for automatically scheduling offline applications according to application types, comprising:
[0007] Classifying each offline application according to a preset classification standard; the preset classification standard is formulated according to the resources consumed when the application is executed;
[0008] Put the classified offline applications into the task pool;
[0009] Get cluster monitoring indicators;
[0010] Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, schedule the offline application corresponding to the idle resources from the task pool at least once according to the preset scheduling rules and the offline application classification results until there are no idle resources in the current cluster.
[0011] Preferably, the determining whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, scheduling the offline application corresponding to the idle resources from the task pool at least once according to the preset scheduling rule and the offline application classification result until there are no idle resources in the current cluster, includes:
[0012] Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator;
[0013] When there are idle resources in the current cluster, a copy of the first offline application corresponding to the idle resources is scheduled from the task pool according to a preset scheduling rule and the offline application classification result; the preset scheduling rule is to preferentially call the copy with the highest preset priority;
[0014] Determining whether the number of scheduled copies of the first offline application reaches a maximum number of copies of the first offline application;
[0015] When the number of scheduled copies of the first offline application does not reach the maximum number of copies of the first offline application, executing the steps of: determining whether there are idle resources in the current cluster according to a preset monitoring indicator threshold and the cluster monitoring indicator;
[0016] When the number of scheduled copies of the first offline application reaches the maximum number of copies of the first offline application, scheduling a copy of the second offline application corresponding to the idle resource from the task pool according to a preset scheduling rule and an offline application classification result;
[0017] The above steps are repeated until there are no idle resources in the current cluster.
[0018] Preferably, when the number of scheduled copies of the first offline application does not reach the maximum number of copies of the first offline application, the method for automatically scheduling offline applications according to application types of the present invention further includes:
[0019] Determining whether the first offline application has been executed;
[0020] When the execution of the first offline application is completed, the first offline application is deleted from the task pool.
[0021] Preferably, after obtaining the cluster monitoring indicators, the method of automatically scheduling offline applications according to application types of the present invention further includes:
[0022] Determine whether there is insufficient resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator;
[0023] When there are scarce resources in the current cluster, releasing a copy of the first online application corresponding to the scarce resources from the current cluster according to a preset release rule; the preset release rule is to release the copy with the lowest preset priority first;
[0024] Determining whether the copy of the first online application is completely released;
[0025] When the copy of the first online application is not completely released, the steps of: determining whether there are tight resources in the current cluster according to a preset monitoring indicator threshold and the cluster monitoring indicator;
[0026] When the copy of the first online application is completely released, releasing a copy of the second online application corresponding to the scarce resource from the current cluster according to a preset release rule;
[0027] The above steps are repeated until there are no scarce resources in the current cluster.
[0028] Preferably, the preset monitoring indicator threshold, the task pool and the offline application are all defined through CRD (Custom Resource Definition).
[0029] Preferably, before classifying each offline application according to a preset classification standard, the method for automatically scheduling offline applications according to application type of the present invention further includes:
[0030] Each of the offline applications is split to obtain a copy of each of the offline applications.
[0031] The present invention adopts the above technical scheme, a method for automatically scheduling offline applications according to application types, including: classifying each offline application according to a preset classification standard; placing the classified offline applications into a task pool; the preset classification standard is formulated according to the resources consumed when the application is executed; obtaining cluster monitoring indicators; judging whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, scheduling the offline application corresponding to the idle resources from the task pool at least once according to the preset scheduling rules and the offline application classification results, until there are no idle resources in the current cluster. Based on this, the present invention can be used for clusters with irregular resources by automatically sensing the state of the current cluster according to the monitoring information and automatically scheduling offline applications according to the monitoring results, and has the advantages of flexibility, high efficiency and low labor cost. In addition, the present invention classifies applications and selects corresponding tasks according to the state of the current cluster, so that when offline applications are distributed in the current cluster, the allocation of idle resources is more reasonable. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 It is a flowchart of a method for automatically scheduling offline applications according to application types provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0034] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0035] Figure 1 FIG. 1 is a flow chart of a method for automatically scheduling offline applications according to application types provided by an embodiment of the present invention. Figure 1 As shown, the method of automatically scheduling offline applications according to application types in this embodiment includes:
[0036] S101. Classify each offline application according to a preset classification standard; the preset classification standard is formulated according to resources consumed when the application is executed.
[0037] Specifically, when creating an offline application, the attributes of the offline application are defined, and the task controller decides whether to put the application into the task pool based on the attributes of the offline application. Application attributes include type, maximum number of copies, priority, application switch, application cycle, and execution time period.
[0038] Among them, offline applications are classified according to their characteristics, for example, web crawlers are defined as network IO intensive, data analysis applications are defined as computation intensive, and log analysis is defined as disk IO intensive.
[0039] It should be noted that one application can correspond to multiple types.
[0040] The maximum number of copies is the number of application copies that the system can execute simultaneously.
[0041] Priority indicates the priority of application execution. When the system calls an application from the task pool, it calls it in order of priority.
[0042] The application switch indicates whether the current application can be executed. The system default application switch is on. When the application switch is off, the application will not be executed.
[0043] The application cycle indicates the interval time required for repeated application execution. The default is independent application. After the application is executed, the application switch is turned off and the application is no longer executed. If the application cycle is specified, the repeated application will automatically add the application to the task pool again according to the rules. The periodic application is similar to the scheduled application, but it cannot determine the application startup time. It can only indicate the cycle of the application joining the task pool.
[0044] The execution time period indicates the time period during which the application can be executed. By default, there is no limit. If this parameter is specified, the system will not execute the application at other times.
[0045] S102: Put the classified offline applications into a task pool.
[0046] Specifically, the task controller decides whether to put the offline application into the task pool based on its properties. The task pool can record the current execution status of each offline application, which includes waiting and executing. After the application is executed, it will be deleted from the task pool.
[0047] S103. Obtain cluster monitoring indicators.
[0048] In detail, the system's monitoring module is responsible for obtaining cluster monitoring indicators from monitoring services such as Promtheus. If the monitoring service is Promtheus, PromQL is used to obtain cluster monitoring indicators. Cluster monitoring indicators include CPU resource share, remaining memory, IOPS, and import and export network bandwidth.
[0049] S104. Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, schedule the offline application corresponding to the idle resources from the task pool at least once according to the preset scheduling rules and application classification results until there are no idle resources in the current cluster.
[0050] Specifically, the preset scheduling rule is to preferentially call the copy with the highest preset priority. Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, schedule a copy of the first offline application corresponding to the idle resources from the task pool according to the preset scheduling rules and application classification results; determine whether the number of scheduled copies of the first offline application has reached the maximum number of copies of the first offline application; when the number of scheduled copies of the first offline application has not reached the maximum number of copies of the first offline application, execute the following steps: Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when the number of scheduled copies of the first offline application has reached the maximum number of copies of the first offline application, schedule a copy of the second offline application corresponding to the idle resources from the task pool according to the preset scheduling rules and application classification results;
[0051] The above steps are repeated until there are no idle resources in the current cluster.
[0052] More specifically, when the average usage rate of the target monitoring indicator in the cluster monitoring indicator is lower than the corresponding preset monitoring indicator threshold within the preset time period, it is defined that the resources monitored by the target monitoring indicator are idle. Then, the corresponding offline application is determined according to the application classification result and the target monitoring indicator, and a copy of the determined offline application is scheduled from the task pool according to the priority of the offline application. If after the preset time period, the average usage rate of the target monitoring indicator is judged to be lower than the preset monitoring indicator threshold, the copies of the offline application continue to be increased until the number of scheduled copies of the offline application reaches the maximum number of copies of the offline application. After reaching the maximum number of copies, the copy of the offline application with the next highest priority is called, and the above steps are repeated until there are no idle resources in the current cluster.
[0053] This embodiment adopts the above technical solution, a method for automatically scheduling offline applications according to application types, including: classifying each offline application according to a preset classification standard; placing the classified offline applications into a task pool; the preset classification standard is formulated according to the resources consumed when the application is executed; obtaining cluster monitoring indicators; judging whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; when there are idle resources in the current cluster, scheduling the offline application corresponding to the idle resources from the task pool at least once according to the preset scheduling rules and the offline application classification results, until there are no idle resources in the current cluster. Based on this, this embodiment can be used for clusters with irregular resources by automatically sensing the state of the current cluster according to the monitoring information and automatically scheduling offline applications according to the monitoring results, and has the advantages of flexibility, high efficiency and low labor cost. In addition, the present invention classifies applications and selects corresponding tasks according to the state of the current cluster, so that when offline applications are distributed in the current cluster, the allocation of idle resources is more reasonable.
[0054] Preferably, when the number of scheduled copies of the first offline application does not reach the maximum number of copies of the first offline application, the method for automatically scheduling offline applications according to application types in this embodiment further includes:
[0055] Determining whether the first offline application has been executed;
[0056] When the execution of the first offline application is completed, the first offline application is deleted from the task pool.
[0057] Preferably, after obtaining the cluster monitoring indicators, the method of automatically scheduling offline applications according to application types in this embodiment further includes:
[0058] Determine whether there is insufficient resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator;
[0059] When there are scarce resources in the current cluster, releasing a copy of the first online application corresponding to the scarce resources from the current cluster according to a preset release rule;
[0060] Determining whether the copy of the first online application is completely released;
[0061] When the copy of the first online application is not completely released, the steps of: determining whether there are tight resources in the current cluster according to a preset monitoring indicator threshold and the cluster monitoring indicator;
[0062] When the copy of the first online application is completely released, releasing a copy of the second online application corresponding to the scarce resource from the current cluster according to a preset release rule;
[0063] The above steps are repeated until there are no scarce resources in the current cluster.
[0064] Specifically, the preset release rule is to release the copy with the lowest preset priority first. If within the preset time period, the average usage rate of the target monitoring indicator is higher than the corresponding preset monitoring indicator threshold, it means that the resources currently monitored by the target monitoring indicator are relatively tight. The system's task controller will release the running application copy corresponding to the target monitoring indicator from the current cluster, and put the released application copy back into the task pool. The release rule is to release in order from low to high preset priorities, until the average usage rate of the target monitoring indicator of the current cluster is lower than the corresponding preset monitoring indicator threshold, and then take the corresponding application out of the task pool again. When the application is recycled, there is no need to modify the task pool, because the task has not been completed and is still in the task pool.
[0065] Preferably, the preset monitoring indicator threshold, the task pool and the application in the task pool are all defined through CRD, which is convenient for users to add or delete defined content.
[0066] Among them, CRD refers to the custom resource of kubernetest (k8s). Users can create their own resource type definition according to k8s rules, define the attributes (fields) of the resource, and use this resource definition to create multiple resource objects. The task pool is a custom resource type, and multiple task pools can be created through custom resources. Similarly, offline applications are also custom resource types, and multiple offline applications can be created through custom resources.
[0067] Preferably, before classifying each offline application according to a preset classification standard, the method of automatically scheduling offline applications according to application type in this embodiment further includes:
[0068] Each of the offline applications is split to obtain a copy of each of the offline applications.
[0069] Specifically, the offline application is split to ensure that multiple copies of the offline application can be executed concurrently and can be closed and recycled at any time without affecting subsequent execution.
[0070] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0071] It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0072] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present invention belong.
[0073] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0074] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0075] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0076] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0077] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0078] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for automatically scheduling offline applications according to application types, characterized in that: include: Classifying each offline application according to a preset classification standard; the preset classification standard is formulated according to the resources consumed when the offline application is executed; Put the classified offline applications into the task pool; Get cluster monitoring indicators; Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; When there are idle resources in the current cluster, scheduling the offline application corresponding to the idle resources from the task pool at least once according to a preset scheduling rule and an offline application classification result until there are no idle resources in the current cluster, including: Determine whether there are idle resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; When there are idle resources in the current cluster, a copy of the first offline application corresponding to the idle resources is scheduled from the task pool according to a preset scheduling rule and an application classification result; the preset scheduling rule is to preferentially call the copy with the highest preset priority; Determining whether the number of scheduled copies of the first offline application reaches a maximum number of copies of the first offline application; When the number of scheduled copies of the first offline application does not reach the maximum number of copies of the first offline application, executing the steps of: determining whether there are idle resources in the current cluster according to a preset monitoring indicator threshold and the cluster monitoring indicator; When the number of scheduled copies of the first offline application reaches the maximum number of copies of the first offline application, scheduling a copy of the second offline application corresponding to the idle resource from the task pool according to a preset scheduling rule and an offline application classification result; The above steps are repeated until there are no idle resources in the current cluster.
2. The method for automatically scheduling offline applications according to application type according to claim 1, characterized in that: When the number of scheduled copies of the first offline application does not reach the maximum number of copies of the first offline application, the method further includes: Determining whether the first offline application has been executed; When the execution of the first offline application is completed, the first offline application is deleted from the task pool.
3. The method for automatically scheduling offline applications according to application type according to claim 1, characterized in that: After obtaining the cluster monitoring indicators, the following steps are also included: Determine whether there is insufficient resources in the current cluster according to the preset monitoring indicator threshold and the cluster monitoring indicator; When there are scarce resources in the current cluster, releasing a copy of the first online application corresponding to the scarce resources from the current cluster according to a preset release rule; the preset release rule is to release the copy with the lowest preset priority first; Determining whether the copy of the first online application is completely released; When the copy of the first online application is not completely released, the steps of: determining whether there are tight resources in the current cluster according to a preset monitoring indicator threshold and the cluster monitoring indicator; When the copy of the first online application is completely released, releasing a copy of the second online application corresponding to the scarce resource from the current cluster according to a preset release rule; The above steps are repeated until there are no scarce resources in the current cluster.
4. The method for automatically scheduling offline applications according to application type according to claim 1, characterized in that: The preset monitoring indicator threshold, the task pool and the offline application are all defined through CRD.
5. The method for automatically scheduling offline applications according to application type according to claim 1, characterized in that: Before classifying each offline application according to the preset classification standard, the method further includes: Each of the offline applications is split to obtain a copy of each of the offline applications.
