Resource scheduling method and device

By creating an empty container on the target node of the Kubernetes cluster and adjusting its resource specifications to respond to capacity reduction and expansion requests, the problem of difficulty in taking into account resource utilization and reliability in the Kubernetes cluster is solved, and efficient utilization and flexible scheduling of resources are achieved.

CN120020724APending Publication Date: 2025-05-20BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311540663.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-17
Publication Date
2025-05-20

AI Technical Summary

Technical Problem

In Kubernetes clusters, it is difficult for users to take into account resource utilization and resource reliability, resulting in waste of resources and low reliability.

Method used

By creating empty containers on the target node of the computer cluster, responding to capacity reduction and expansion requests, adjusting the resource specifications of the empty containers to occupy or release resources, achieving flexible scheduling of resources and the execution of external tasks.

Benefits of technology

On the premise of ensuring the flexible expansion and reduction of the target container, improve resource utilization, realize the reuse of resources between the original tasks and external tasks, and avoid idleness and waste of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120020724A_ABST
    Figure CN120020724A_ABST
Patent Text Reader

Abstract

The invention discloses a resource scheduling method and device, and relates to the technical field of cloud computing. A specific embodiment of the method comprises the following steps: creating an empty container at a target node of a computer cluster; in response to the received capacity reduction request for any target container, determining the quantity of reduced resources corresponding to the capacity reduction request, increasing the resource specification of the empty container so as to occupy the resources of which the quantity is equal to the quantity of the reduced resources in the empty container, and executing an external task based on the currently occupied resources of the empty container; in response to the received capacity expansion request for any target container, judging whether an empty container currently occupies resources of which the quantity is the expansion resource quantity corresponding to the capacity expansion request or not; and if so, recycling the resources with the quantity equal to the quantity of the extended resources from the external task, and reducing the resource specification of the empty container to release the resources with the quantity equal to the quantity of the extended resources in the empty container. According to the embodiment, the resource utilization rate can be improved on the premise of ensuring flexible capacity expansion and shrinkage of the working container.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud computing, and in particular, to a resource scheduling method and apparatus. Background Art

[0002] Kubernetes (abbreviated as K8S) is a container orchestration and management system that has been widely used in enterprise-level applications and cloud computing environments. In the current K8S cluster, it is difficult for users to balance resource utilization and resource reliability. For example, a user applies for 10 containers with 8C12G (i.e., 8 CPU cores and 12GB of memory) in the K8S cluster. These resources can meet the usage during the business peak period. However, the business peak period usually lasts for 1 to 2 hours (such as the e-commerce promotion scenario), and then enters the business stable period. The resource utilization rate during the business stable period is very low, and the CPU usage rate is between 3% and 5%, resulting in a great waste of resources. However, users cannot scale down the resources during the business stable period because if they do so, there may be a problem of insufficient resources when they need to scale up during the business peak period. For example, when scaling up is required, K8S has already allocated the resources scaled down by the user to other services and cannot allocate them to the user's service, resulting in a serious impact on the user's service. This situation means low resource reliability. In practice, users often have to keep the resources at the usage level required during the business peak period. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a resource scheduling method and apparatus, which can improve resource utilization while ensuring flexible scaling up and down of working containers.

[0004] To achieve the above object, according to one aspect of the present invention, a resource scheduling method is provided.

[0005] The resource scheduling method of the embodiments of the present invention includes: creating an empty container on a target node of a computer cluster; wherein, the target node contains at least one working container including a target container; in response to receiving a scale-down request for any target container, determining the reduced resource quantity corresponding to the scale-down request, increasing the resource specification of the empty container to occupy resources with a quantity of the reduced resource quantity in the empty container, and executing an external task based on the currently occupied resources of the empty container; in response to receiving a scale-up request for any target container, determining whether the empty container currently occupies resources of the target container with a quantity of the extended resource quantity corresponding to the scale-up request; if so, reclaiming resources with a quantity of the extended resource quantity from the external task and reducing the resource specification of the empty container to release resources with a quantity of the extended resource quantity in the empty container.

[0006] Optionally, the method further includes: after receiving a scale-down request for any target container, performing a scale-down operation on the target container; after reducing the resource specification of the empty container to release resources in an amount equal to the extended resource amount, performing a scale-up operation on the corresponding target container based on the resources released by the empty container.

[0007] Optionally, the method further includes: after creating the empty container, obtaining and recording the initial resource amounts of the target containers in the target node; after performing the scale-down operation on the target container, determining the scale-down target resource amount carried in the scale-down request for the target container as the current resource amount of the target container and recording it.

[0008] Optionally, determining the reduced resource amount corresponding to the scale-down request includes: subtracting the scale-down target resource amount carried in the scale-down request for any target container from the initial resource amount of the target container to obtain the reduced resource amount corresponding to the scale-down request; and the method further includes: subtracting the current resource amount of the target container from the scale-up target resource amount carried in the scale-up request for any target container to obtain the extended resource amount corresponding to the scale-up request.

[0009] Optionally, performing an external task based on the currently occupied resources of the empty container includes: in response to receiving a specific container creation request, creating a specific container that does not belong to the working containers in the target node based on the currently occupied resources of the empty container, and performing the external task in the created specific container.

[0010] Optionally, in response to receiving a specific container creation request, creating a specific container that does not belong to the working containers in the target node based on the currently occupied resources of the empty container includes: after receiving the specific container creation request, attempting to create the specific container in the target node by using the currently occupied resources of the empty container; determining whether the specific container is successfully created within a preset time period; if it is successfully created, adjusting the currently occupied resource amount of the empty container; if it fails to be created, releasing the resources used to create the specific container and maintaining the currently occupied resource amount of the empty container.

[0011] To achieve the above object, according to another aspect of the present invention, there is provided a resource scheduling device.

[0012] The resource scheduling device according to an embodiment of the present invention includes: an empty container creation unit, a controller, and a scheduler; wherein, the empty container creation unit is used to create an empty container on a target node of a computer cluster; the target node contains at least one working container including a target container; the controller is used to: receive a scaling-down request for any target container, determine the reduced resource quantity corresponding to the scaling-down request, increase the resource specification of the empty container to occupy resources with a quantity of the reduced resource quantity; receive a scaling-up request for any target container, and determine whether the empty container currently occupies resources of this target container with a quantity of the extended resource quantity corresponding to the scaling-up request; if so, after the resources with a quantity of the extended resource quantity are recycled from an external task, reduce the resource specification of the empty container to release resources with a quantity of the extended resource quantity; the scheduler is used to: execute an external task based on the currently occupied resources of the empty container; after the controller determines that the empty container currently occupies resources of this target container with a quantity of the extended resource quantity corresponding to the scaling-up request, recycle resources with a quantity of the extended resource quantity from the external task.

[0013] Optionally, the controller is further used to: after receiving a scaling-down request for any target container, perform a scaling-down operation on this target container; after reducing the resource specification of the empty container to release resources with a quantity of the extended resource quantity, perform a scaling-up operation on the corresponding target container based on the resources released by the empty container.

[0014] To achieve the above object, according to another aspect of the present invention, an electronic device is provided.

[0015] An electronic device according to the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the resource scheduling method provided by the present invention.

[0016] To achieve the above object, according to still another aspect of the present invention, a computer-readable storage medium is provided.

[0017] A computer-readable storage medium according to the present invention stores a computer program thereon, and when the program is executed by a processor, it implements the resource scheduling method provided by the present invention.

[0018] According to the technical solution of the present invention, the embodiments in the above invention have the following advantages or beneficial effects:

[0019] The resource scheduling device (hereinafter referred to as the device) pre-creates empty containers on the target nodes of the K8S cluster, where the target nodes are the nodes where the target containers with the resource pre-occupation function are located. After receiving the scale-down request for the target container, the device performs the scale-down operation and increases the resource specifications of the empty containers to occupy resources with the reduced resource quantity. The currently occupied resources of the empty containers can be used to create specific containers on the same node to execute external tasks. After receiving the scale-up request for the target container, if the device determines that the empty containers currently occupy resources of the target container with the quantity of the expanded resource quantity, it reclaims the corresponding quantity of resources from the external tasks, reduces the resource specifications of the empty containers to release the corresponding quantity of resources, and finally uses the released resources to perform the scale-up operation on the target container. In this way, through the resource pre-occupation of the empty containers in the target nodes, the resource utilization rate is improved on the premise of ensuring that any target container can be scaled up and down flexibly (i.e., high resource reliability), realizing the reuse of resources between the original tasks and external tasks, and avoiding the idle and waste of resources. The above device can be adapted to the K8S cluster to achieve the balance between resource reliability and resource utilization rate without affecting the original functions of K8S.

[0020] The further effects of the above non-conventional optional methods will be described in combination with specific embodiments below. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings are used to better understand the present invention and do not unduly limit the present invention. Among them:

[0022] Figure 1 is a schematic diagram of the main steps of the resource scheduling method in the embodiment of the present invention;

[0023] Figure 2 is a schematic diagram of the system architecture of the resource scheduling method in the embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of the life cycle of a specific container in the embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of the components of the resource scheduling device in the embodiment of the present invention;

[0026] Figure 5 is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;

[0027] Figure 6 is a schematic diagram of the structure of an electronic device for implementing the resource scheduling method in the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, descriptions of well-known functions and structures are omitted in the following description for clarity and conciseness.

[0029] The following description will be carried out taking the resource scheduling scenario of the K8S platform as an example, but this does not impose any limitation on the application scenario of the present invention. In fact, the method of the present invention can be applied to any other applicable scenario. K8S is a lightweight and scalable open-source platform for managing containerized applications and services. Through K8S, automated deployment, scaling, and shrinking of applications can be performed. In K8S, docker (docker is an open-source application container engine) containers that make up an application are combined into a logical unit for easier management and discovery. This logical unit is the Pod. The Pod is the most basic operation unit in K8S. It encapsulates one or more closely related docker containers internally. One or more labels can be attached to the Pod to mark relevant information. For example, labels are used to indicate the empty containers to be described below. It should be noted that in the following text, various Pods are referred to as containers, that is, the containers in the following text specifically refer to Pods rather than the aforementioned docker containers.

[0030] K8S adopts a master-slave architecture. The master node mainly consists of four modules: kube-apiserver, kube-scheduler, kube-manager, and etcd. Among them, kube-apiserver is the core of the K8S control plane, enabling communication between users, different parts of the cluster, and external components of the cluster; kube-scheduler is responsible for resource scheduling and schedules Pods to corresponding slave nodes according to predefined scheduling policies; kube-manager is responsible for maintaining the state of the cluster, such as fault detection, auto-scaling, rolling updates, etc.; etcd is used to store relevant data to ensure the high availability of the cluster. The slave node (node) is used to execute specific tasks through the Pods within it. The node mentioned in the following text refers to the slave node. Additionally, in the K8S system, DaemonSet can be used to ensure that a container replica runs on each node or specific nodes, usually used to deploy cluster logs, monitoring, or other management applications. vpa (vertical pod autoscaler) can be used to automatically adjust the current resource size of Pods, and the resource usage limit of any Pod can be restricted through a configuration file based on cgroup (a kernel infrastructure of Linux). Furthermore, the resources in the embodiments of the present invention can include any computer resources, such as the number of CPU cores, memory capacity, disk capacity, etc.

[0031] It should be noted that, without conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.

[0032] Figure 1 It is a schematic diagram of the main steps of the resource scheduling method according to the embodiments of the present invention.

[0033] As Figure 1 shown, the resource scheduling method of the embodiments of the present invention can be specifically executed according to the following steps:

[0034] Step S101: Create an empty container on the target node of the computer cluster.

[0035] In practical applications, the resource scheduling device can provide a resource reservation function for any container in any node, that is, the scaled-down resources of the container are reserved in the empty container to improve utilization rate, and the scaled-down resources can be released at any time for container expansion. The container with the resource reservation function enabled is the target container, and the node where the target container is located is the target node. The target container is the working container in the target node. The working container refers to the Pod used by the target node to execute the original task, as opposed to the empty container and specific container used to implement the resource reservation function described below. There can be one or more target containers in the same target node.

[0036] In this step, the device pre-creates an empty container at the target node. The empty container is a special container used to pre-occupy the resources of other containers. When it is created, it only occupies a negligible amount of resources, such as 10MB of memory, so it is called an empty container. In one embodiment, the device can use the DaemonSet module of K8S to create an empty container for each target container. During the creation of the empty container, the empty container image format with the smallest data volume can be used to reduce the data volume occupied.

[0037] Preferably, after creating the empty container, the device can obtain and record the initial resource quantity of each target container in the target node. Preferably, the device can record the initial resource quantity in the annotation of the corresponding target container. The above initial resource quantity can be used for subsequent calculation of the reduced resource quantity.

[0038] Step S102: In response to receiving a scale-down request for any target container, determine the reduced resource quantity corresponding to the scale-down request, increase the resource specification of the empty container so that the occupied quantity of the empty container is the reduced resource quantity, and execute an external task based on the currently occupied resources of the empty container.

[0039] In this step, the device can intercept the scale-down request for any target container sent to K8S, and subtract the scale-down target resource quantity (i.e., the resource quantity that needs to be reached after scale-down) carried in the scale-down request from the initial resource quantity of the target container to obtain the reduced resource quantity corresponding to the scale-down request. After obtaining the reduced resource quantity, the device can increase the resource specification of the empty container (i.e., increase the resource upper limit of the empty container) by modifying the configuration file of the empty container, so that the occupied quantity of the empty container is the reduced resource quantity. In practical applications, after the device receives a scale-down request for any target container, it can perform a scale-down operation on the target container. It can be understood that the vpa of K8S can also perform a scale-down operation on the target container. In specific applications, after the scale-down operation is completed, the device can determine the scale-down target resource quantity carried in the scale-down request as the current resource quantity of the corresponding target container and record it in the annotation of the target container.

[0040] Through the above resource occupation process of each target container in the same target node, the empty container can have a certain amount of occupied resources, and these occupied resources can be used to execute external tasks. The above external tasks, compared with the original tasks executed by the working containers, can be tasks corresponding to any user and application. Preferably, if the target container corresponding to the occupied resources of the empty container and the task executed by the occupied resources belong to the same user, this can avoid providing the resources under a certain user's name to other users.

[0041] Preferably, the specific steps of executing an external task based on the currently occupied resources of the empty container are as follows. The device receives a specific container creation request sent externally, creates a specific container that does not belong to the above working containers on the target node based on the currently occupied resources of the empty container, and executes the above external task in the created specific container. The above specific container refers to a special container created by using the occupied resources in the empty container and used to execute external tasks. Through the deployment of the above empty container and specific container, the decoupling and separation of resource reservation and external task execution can be achieved, ensuring the high availability of the system.

[0042] In one embodiment, after receiving the specific container creation request, the device may first attempt to create a specific container on the target node by using the currently occupied resources of the empty container, and store the relevant data in a cache with a certain expiration time. Thereafter, the device determines whether the specific container is successfully created within a preset time period (i.e., the time period where the cache expiration time is located); if it is successfully created, the currently occupied resource quantity of the empty container is adjusted by modifying the configuration file; if it fails to be created, the device releases the resources used to create the specific container and maintains the currently occupied resource quantity of the empty container. The above steps can avoid calculation errors in the currently occupied resource quantity of the empty container caused by factors such as network latency and system creation failure, as well as subsequent resource allocation errors based on the incorrect calculation results.

[0043] Step S103: In response to receiving an expansion request for any target container, determine whether the empty container currently occupies resources of the target container with a quantity equal to the extended resource quantity corresponding to the expansion request; if it occupies, recycle resources with a quantity equal to the extended resource quantity from the external task, and reduce the resource specification of the empty container to release resources with a quantity equal to the extended resource quantity in the empty container.

[0044] The purpose of this step is to restore the preoccupied resources for the target container to enable expansion at any time. Specifically, the device intercepts an expansion request for any target container, determines whether the empty container currently occupies resources of the target container with a quantity equal to the extended resource quantity corresponding to the expansion request; if it occupies, the device recycles resources with a quantity equal to the extended resource quantity from the external task, and reduces the resource specification of the empty container (i.e., reduces the resource upper limit) by modifying the configuration file of the empty container, so as to release resources with a quantity equal to the extended resource quantity in the empty container. It can be understood that the device can subtract the current resource quantity of the target container previously recorded from the expanded target resource quantity carried in the expansion request for any target container, so as to obtain the extended resource quantity corresponding to the expansion request. In practical applications, the device can release the reduced resource quantity of a certain target container reserved by the empty container at one time for the expansion of the target container, or release the reduced resource quantity multiple times separately to enable the target container to be expanded multiple times. Thereafter, the device can perform an expansion operation on the corresponding target container based on the resources released by the empty container, and the above expansion operation can also be executed by the vpa of K8S.

[0045] In the technical solution of the embodiment of the present invention, the device pre-creates empty containers on the target nodes of the K8S cluster, where the target nodes are the nodes where the target containers with the resource pre-occupation function are enabled. After receiving the scale-down request for the target container, the device performs a scale-down operation and increases the resource specifications of the empty containers to occupy resources with the number of reduced resources by the empty containers. The currently occupied resources of the empty containers can be used to create specific containers on the same node to execute external tasks. After receiving the scale-up request for the target container, if the device determines that the empty containers currently occupy resources of the target container with the number of expanded resources, it reclaims the corresponding amount of resources from the external tasks, reduces the resource specifications of the empty containers to release the corresponding amount of resources by the empty containers, and finally uses the released resources to perform a scale-up operation on the target container. In this way, through the resource pre-occupation of the empty containers in the target nodes, the resource utilization rate is improved on the premise of ensuring that any target container can be scaled up and down flexibly (i.e., high resource reliability), realizing the reuse of resources between the original tasks and external tasks, and avoiding the idle and waste of resources. The above device can be adapted to the K8S cluster to achieve both resource reliability and resource utilization rate without affecting the original functions of K8S.

[0046] The following describes a specific embodiment of the present invention. Refer to Figure 2 。

[0047] In the current K8S system, each node has certain computing and storage resources for application programs to use. These resources include the number of CPU cores, memory capacity, disk capacity, etc. Each node cooperates with the resource scheduler (kube-scheduler) to complete the allocation and management of resources. Its disadvantages are as follows:

[0048] First, when applying K8S to the production environment, how to allocate resources to meet business requirements becomes an urgent problem to be solved, that is, how to ensure both resource utilization rate and resource reliability (i.e., ensuring that the required resources can be obtained when needed). For example, a user applies for 10 resources of 8C12G in the cluster, and these resources can meet the usage volume during the business peak period. However, the business peak period lasts for 1 to 2 hours, and then enters the business stable period. The resource utilization rate during the business stable period is often very low, and the CPU utilization rate is between 3% and 5%. This causes a great waste of resources. The user cannot scale down the resources during the business stable period. If scaled down, it is very likely that there will be a problem of insufficient resources when the business peak period requires scaling up, which will have a serious impact on the service. Therefore, the user can only keep the resources at the usage volume required during the business peak period all the time.

[0049] Second, it lacks the resource preemption function. Implementing resource preemption through the existing capabilities of K8S is complex and difficult to manage. It requires modifying relevant components such as kube-scheduler and kube-apiserver, which also poses certain challenges to later maintenance.

[0050] The purpose of this embodiment is to solve the above problems, that is, to solve the problems of the resource preemption function and the resource reuse function of the K8S system. The resource calling device provided in this embodiment aims to solve how to implement resource preemption based on the existing functions of K8S, solve the need for instant resource expansion during peak business periods, and reduce resource usage during low business periods to improve resource utilization. The controller developed in the device monitors the resource changes of each node in the cluster to achieve accurate calculation of reusable resources, and then the developed scheduler reasonably allocates resources.

[0051] See Figure 2 , the above device includes an empty container creation unit ( Figure 2 not shown in Figure 2 ), the aforementioned controller and scheduler. Among them, the empty container creation unit creates an empty container on each target node in the cluster through the native daemonset of K8S. There is no business process in the empty container, and its main function is to preempt resources and occupy different amounts of resources on each target node by changing the specifications of the empty container. The controller is responsible for listening to the resource changes of the empty container and synchronizing the resource information to the scheduler in real time. The scheduler realizes the scheduling and allocation of reusable resources (i.e., the resources occupied by the empty container).

[0052] The specific implementation steps of this embodiment are as follows. In the first step, an empty container is created based on the empty container creation unit. Specifically, first, relevant topology information of the empty container to be deployed (such as which nodes need to deploy the empty container and which nodes do not need to deploy the empty container) and label metadata are set. The label metadata can be used to identify the empty container. After that, the mirror format with the smallest data volume is selected as the empty container mirror, and an empty container is created on each target node to ensure that the empty container is in the running state. In this way, the effect of resource pre-occupation can be achieved by modifying the resource specifications of the empty container later. In the second step, the controller is deployed. Specifically, first, the list and watch function of K8S (i.e., the listing-monitoring function) is enabled, the information of each target container is listed, the initial resource quantity of the target container is recorded in the annotation of the corresponding target container, and the scale-down request of the target container is monitored. If a scale-down request is detected, the resources to be scaled down (the resource quantity is equal to the reduced resource quantity) are recorded and the specifications of the empty containers on the same node are increased to achieve resource occupation. In the third step, the scheduler is deployed. Specifically, the scheduler first lists and watches each empty container, takes the occupied resources of each empty container as schedulable resources, and listens to and updates the resource changes in real time. If the scheduler receives a request to create a specific container sent from the outside, a specific container is created according to the resources occupied by the empty container to execute the external task. Through the above steps, the problems of resource pre-occupation and resource reuse in the K8S system are solved.

[0053] Figure 3 is a schematic diagram of the life cycle of a specific container in an embodiment of the present invention. As Figure 3 shown, the resources of the slave nodes in the K8S system are divided into allocable resources (remaining resources), allocated resources (resources that have been allocated to working containers), empty container resources (i.e., resources occupied by empty containers), and system reserved resources (resources used to support system functions). When the scheduler creates a specific container, it first temporarily occupies a certain amount of resources in the allocable resources and tries to create. After the controller releases the corresponding empty container resources, the scheduler uses the resources in the empty container resources (which are the actual occupied resources at this time) to create a specific container. When the specific container is marked for deletion, the above actual occupied resources used to create the specific container start to be released. This part of the resources is converted into temporarily occupied resources in the allocable resources after the controller reclaims the resources of the specific container. Finally, the controller deletes the specific container, causing the temporarily occupied resources in the allocable resources to be released.

[0054] It should be noted that in the technical solution of the present invention, aspects such as the collection, collection, update, analysis, processing, use, transmission, and storage of user personal information that may be involved all comply with the provisions of relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken for user personal information to prevent illegal access to user personal information data, and the security of user personal information, network security, and national security are maintained.

[0055] For each of the foregoing method embodiments, for the sake of convenience of description, they are expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence. In fact, some steps can be performed in other sequences or simultaneously. In addition, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential for implementing the present invention.

[0056] To better implement the above solutions of the embodiments of the present invention, the following also provides related devices for implementing the above solutions.

[0057] Please refer to Figure 4 As shown, the resource scheduling device 400 provided by the embodiment of the present invention may include: an empty container creation unit 401, a controller 402, and a scheduler 403.

[0058] Among them, the empty container creation unit 401 is used to create an empty container on a target node of a computer cluster; the target node contains at least one working container including the target container; the controller 402 is used to: receive a scale-down request for any target container, determine the amount of resources to be reduced corresponding to the scale-down request, increase the resource specification of the empty container to occupy resources in an amount equal to the amount of resources to be reduced; receive a scale-up request for any target container, and determine whether the empty container currently occupies resources of the target container in an amount equal to the amount of extended resources corresponding to the scale-up request; if so, after the resources in an amount equal to the amount of extended resources are recycled from an external task, reduce the resource specification of the empty container to release resources in an amount equal to the amount of extended resources; the scheduler 403 is used to: execute an external task based on the currently occupied resources of the empty container; after the controller determines that the empty container currently occupies resources of the target container in an amount equal to the amount of extended resources corresponding to the scale-up request, recycle resources in an amount equal to the amount of extended resources from the external task.

[0059] In the embodiment of the present invention, the controller 402 may further be used to: perform a scale-down operation on the target container after receiving a scale-down request for any target container; after reducing the resource specification of the empty container to release resources in an amount equal to the amount of extended resources, perform a scale-up operation on the corresponding target container based on the resources released by the empty container.

[0060] As a preferred solution, the controller 402 may further be configured to: after creating the empty container, obtain and record the initial resource quantity of each target container in the target node; after performing a scale-down operation on the target container, determine the scale-down target resource quantity carried in the scale-down request for the target container as the current resource quantity of the target container and record it.

[0061] Preferably, the controller 402 may further be configured to: subtract the scale-down target resource quantity carried in the scale-down request for any target container from the initial resource quantity of the target container to obtain the reduced resource quantity corresponding to the scale-down request; subtract the current resource quantity of any target container from the scale-up target resource quantity carried in the scale-up request for the target container to obtain the extended resource quantity corresponding to the scale-up request.

[0062] In one embodiment, the scheduler 403 may further be configured to: in response to receiving a specific container creation request, create a specific container that does not belong to the working container in the target node based on the currently occupied resources of the empty container, and execute the external task in the created specific container.

[0063] In addition, in the embodiment of the present invention, the scheduler 403 may further be configured to: after receiving the specific container creation request, attempt to create the specific container in the target node by using the currently occupied resources of the empty container; determine whether the specific container is successfully created within a preset time period; if it is successfully created, adjust the currently occupied resource quantity of the empty container; if it fails to be created, release the resources used to create the specific container and maintain the currently occupied resource quantity of the empty container.

[0064] According to the technical solution of the embodiment of the present invention, the device pre-creates an empty container on the target node of the K8S cluster, where the target node is the node where the target container with the resource pre-occupation function is enabled. After receiving the scale-down request for the target container, the device performs a scale-down operation and increases the resource specification of the empty container to occupy resources with the number of reduced resources by the empty container. The currently occupied resources of the empty container can be used to create a specific container on the same node to execute external tasks. After receiving the scale-up request for the target container, if the device determines that the empty container currently occupies resources of the target container with the number of expanded resources, it reclaims the corresponding amount of resources from the external task, reduces the resource specification of the empty container to release the corresponding amount of resources by the empty container, and finally uses the released resources to perform a scale-up operation on the target container. In this way, through the resource pre-occupation of the empty container in the target node, the resource utilization rate is improved on the premise of ensuring that any target container can be scaled up and down flexibly (i.e., high resource reliability), realizing the reuse of resources between the original task and the external task, and avoiding the idle and waste of resources. The above device can be adapted to the K8S cluster to achieve both resource reliability and resource utilization rate without affecting the original functions of K8S.

[0065] Figure 5 FIG. 500 shows an exemplary system architecture to which the resource scheduling method or resource scheduling device according to the embodiment of the present invention can be applied.

[0066] As Figure 5 shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505 (this architecture is only an example, and the components included in the specific architecture can be adjusted according to the specific situation of the application). The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0067] Users can use the terminal devices 501, 502, 503 to interact with the server 505 through the network 504 to receive or send messages, etc. Various client applications, such as database applications (only examples), may be installed on the terminal devices 501, 502, 503.

[0068] The terminal devices 501, 502, 503 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.

[0069] The server 505 can be a server that provides various services, such as a cloud server (only an example) that supports database applications operated by users using the terminal devices 501, 502, and 503. The cloud server can process the received capacity reduction request and feedback the processing result (such as whether the capacity reduction is successful - only an example) to the terminal devices 501, 502, and 503.

[0070] It should be noted that the resource scheduling method provided by the embodiments of the present invention is generally executed by the server 505. Correspondingly, the resource scheduling device is generally arranged in the server 505.

[0071] It should be understood that Figure 5 the numbers of the terminal devices, the network, and the server in

[0072] The present invention also provides an electronic device. The electronic device according to the embodiments of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the resource scheduling method provided by the present invention.

[0073] Next, refer to Figure 6 , which shows a schematic structural diagram of a computer system 600 of an electronic device suitable for implementing the embodiments of the present invention. Figure 6 The shown electronic device is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present invention.

[0074] As Figure 6 shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage section 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.

[0075] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. as well as a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.

[0076] Specifically, according to the embodiments disclosed in the present invention, the process described in the above main step diagram can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the method shown in the main step diagram. In the above embodiment, the computer program can be downloaded and installed from a network through the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit 601, the above functions defined in the system of the present invention are executed.

[0077] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the above two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0078] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0079] The units involved in the embodiments of the present invention can be implemented in software or in hardware. The described units can also be provided in a processor. For example, it can be described as: a processor includes an empty container creation unit, a controller, and a scheduler. Among them, the names of these units do not constitute a limitation to the unit itself in some cases. For example, the empty container creation unit can also be described as "a unit that provides empty containers to the controller and the scheduler".

[0080] On the other hand, the present invention also provides a computer-readable medium. The computer-readable medium can be included in the device described in the above embodiments; or it can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the device, the steps performed by the device include: creating an empty container at a target node in a computer cluster; where the target node contains at least one working container including a target container; in response to receiving a request for reducing the capacity of any target container, determining the amount of resources to be reduced corresponding to the request for reducing the capacity, increasing the resource specification of the empty container so that the empty container occupies resources in an amount equal to the amount of resources to be reduced, and performing an external task based on the currently occupied resources of the empty container; in response to receiving a request for expanding the capacity of any target container, determining whether the empty container currently occupies resources of the target container in an amount equal to the amount of extended resources corresponding to the request for expanding the capacity; if so, reclaiming resources in an amount equal to the amount of extended resources from the external task and reducing the resource specification of the empty container so that the empty container releases resources in an amount equal to the amount of extended resources.

[0081] In the technical solution of the embodiment of the present invention, the device pre-creates an empty container on the target node of the K8S cluster, where the target node is the node where the target container with the resource pre-occupation function is enabled. After receiving the downscaling request for the target container, the device performs the downscaling operation and increases the resource specification of the empty container to occupy resources with the number of reduced resources. The currently occupied resources of the empty container can be used to create a specific container on the same node to execute external tasks. After receiving the upscaling request for the target container, if the device determines that the empty container currently occupies resources of the target container with the number of extended resources, it recovers the corresponding amount of resources from the external task, reduces the resource specification of the empty container to release the corresponding amount of resources in the empty container, and finally uses the released resources to perform the upscaling operation on the target container. In this way, through the resource pre-occupation of the empty container in the target node, the resource utilization rate is improved on the premise of ensuring that any target container can be scaled up and down flexibly (i.e., high resource reliability), realizing the reuse of resources between the original task and the external task, and avoiding the idle and waste of resources. The above device can be adapted to the K8S cluster to achieve both resource reliability and resource utilization rate without affecting the original functions of K8S.

[0082] The above specific implementation manners do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A resource scheduling method, characterized in that: include: Creating an empty container at a target node in a computer cluster; wherein the target node contains at least one working container including the target container; In response to receiving a shrink request for any target container, determining a reduced number of resources corresponding to the shrink request, increasing a resource specification of the empty container so that a number of resources occupied by the empty container is equal to the reduced number of resources, and executing an external task based on currently occupied resources of the empty container; In response to receiving a capacity expansion request for any target container, determine whether the empty container currently occupies resources of the target container, the number of which is the number of extended resources corresponding to the capacity expansion request; if occupied, reclaim the resources in the number of extended resources from the external task, and reduce the resource specification of the empty container to release resources in the empty container in the number of extended resources.

2. The method according to claim 1, characterized in that: The method further comprises: After receiving a shrink request for any target container, performing a shrink operation on the target container; After reducing the resource specification of the empty container to release resources in an amount equal to the expanded resource amount in the empty container, a capacity expansion operation is performed on the corresponding target container based on the resources released by the empty container.

3. The method according to claim 2, characterized in that The method further comprises: After creating the empty container, obtaining and recording the initial resource quantity of each target container in the target node; After the shrinking operation is performed on the target container, the shrinking target resource quantity carried in the shrinking request for the target container is determined as the current resource quantity of the target container and recorded.

4. The method according to claim 3, characterized in that: Determining the reduced resource quantity corresponding to the shrink request includes: subtracting the shrink target resource quantity carried in the shrink request for the target container from the initial resource quantity of any target container to obtain the reduced resource quantity corresponding to the shrink request; and The method further includes: subtracting the current resource quantity of any target container from the target resource quantity carried in the capacity expansion request for any target container to obtain the extended resource quantity corresponding to the capacity expansion request.

5. The method according to claim 1, characterized in that The executing the external task based on the currently occupied resources of the empty container includes: In response to receiving a specific container creation request, a specific container that does not belong to the working container is created at the target node based on currently occupied resources of the empty container, and the external task is executed in the created specific container.

6. The method according to claim 5, characterized in that In response to receiving the specific container creation request, creating a specific container that does not belong to the working container at the target node based on the currently occupied resources of the empty container includes: After receiving the specific container creation request, try to create the specific container at the target node using the currently occupied resources of the empty container; Determine whether the specific container is successfully created within a preset time period; if the creation is successful, adjust the current occupied resource quantity of the empty container; if the creation fails, release the resources used to create the specific container and maintain the current occupied resource quantity of the empty container.

7. A resource scheduling device, characterized in that: include: The empty container creates a unit, a controller, and a scheduler; among them, The empty container creation unit is used to create an empty container at a target node in a computer cluster; The target node contains at least one working container including the target container; The controller is used to: receive a request for reducing capacity for any target container, determine the number of reduced resources corresponding to the request for reducing capacity, increase the resource specification of the empty container to occupy resources in the empty container in the amount of the reduced resources; receive a request for expanding capacity for any target container, determine whether the empty container currently occupies resources of the target container in the amount of the extended resources corresponding to the request for expanding capacity; if occupied, reduce the resource specification of the empty container to release resources in the empty container in the amount of the extended resources after the resources in the amount of the extended resources are recovered from the external task; The scheduler is used to: execute an external task based on the currently occupied resources of the empty container; after the controller determines that the empty container currently occupies resources of the target container, the number of which is the number of extended resources corresponding to the capacity expansion request, reclaim the resources of the number of extended resources from the external task.

8. The device according to claim 7, characterized in that The controller is further configured to: After receiving a reduction request for any target container, a reduction operation is performed on the target container; after reducing the resource specification of the empty container to release resources of the empty container equal to the expanded resource quantity, an expansion operation is performed on the corresponding target container based on the resources released by the empty container.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.