Container resource scheduling method, device, storage medium and computer equipment

By obtaining the container to be recycled, saving it as a mirror and generating an identification code, the image and its identification code are recycled into the database, releasing the cluster resources, and sending the identification code to the user to request the recycled container, the container cluster resource scheduling management is solved. The problem of low efficiency achieves efficient utilization and reasonable recycling of resources.

CN114064279BActive Publication Date: 2024-11-29GUANGZHOU WERIDE TECH LTD CO
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111371464.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2024-11-29
Estimated Expiration
2041-11-18

AI Technical Summary

Technical Problem

In the prior art, the scheduling and management efficiency of container cluster resources is low, resulting in insufficient resource utilization and complex management.

Method used

By obtaining the container to be recycled, saving it as a mirror and generating an identification code, the image and its identification code are recycled into the database, the cluster resources are released, and the identification code is sent to the user to request the recycled container.

Benefits of technology

It improves the scheduling and management efficiency of container cluster resources, ensuring the rational utilization and efficient recycling of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064279B_ABST
    Figure CN114064279B_ABST
Patent Text Reader

Abstract

The container resource scheduling method, device, storage medium and computer equipment provided by the present application, when obtaining the container to be recycled returned by the current node, the server can first save the container to be recycled as an image and generate an identification code corresponding to the image, then recycle the image and its corresponding identification code to the database, and release the cluster resources occupied by the container to be recycled when it is used, so that other nodes in the cluster can use the released cluster resources to perform related operations such as container creation. In addition, the server can also send the identification code to the user who uses the container to be recycled, so that the user can use the identification code to request the recycled container, thereby greatly improving the scheduling and management efficiency of container cluster resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a container resource scheduling method, device, storage medium and computer equipment. Background Art

[0002] In recent years, with the rapid development of container technology, the application scenarios of containers have become more and more extensive. For example, after traditional applications are containerized, they can not only improve the security and portability of traditional applications, but also save costs; continuous integration and continuous deployment (CI / CD) can greatly improve the delivery speed by accelerating application pipeline automation and application deployment through Docker; and applying containers to microservices can accelerate the modernization process of application architecture.

[0003] At present, R&D personnel within enterprises also use container technology to build, publish and run application platforms. After each R&D personnel applies for a container from the server, they can use the applied container and the corresponding cluster resources to perform daily operations. However, as the number of containers continues to increase, the scheduling and management of container cluster resources becomes more difficult. Therefore, it is necessary to study a method that can efficiently schedule and manage container cluster resources. Summary of the invention

[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the technical defect of low scheduling and management efficiency of container cluster resources in the prior art.

[0005] The present application provides a container resource scheduling method, the method comprising:

[0006] Get the container to be recycled returned by this node;

[0007] Saving the container to be recycled as an image, and generating an identification code corresponding to the image;

[0008] Recycling the image and its corresponding identification code into a database, and releasing the cluster resources occupied by the container to be recycled;

[0009] After the cluster resources occupied by the container to be recycled are released, the identification code is sent to the user who uses the container to be recycled, so that the user can request the container to be recycled using the identification code.

[0010] Optionally, before the step of obtaining the to-be-recycled container returned by the node, the step further includes:

[0011] Receive container application instructions sent by users;

[0012] Based on the container application instruction, a container is allocated to the user, and a corresponding resource occupation time is set for the allocated container.

[0013] Optionally, the method further comprises:

[0014] Acquire a user-port relationship table, wherein the user-port relationship table stores a plurality of user information and at least one container port bound to each user information;

[0015] Based on the user information carried in the container application instruction, searching the user port relationship table for a container port set corresponding to the user information;

[0016] Obtain a container data table and a container recycling data table, wherein the container data table stores container ports corresponding to containers running in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers;

[0017] Determine whether the container port set includes a target container port that does not exist in the container data table and the container recovery data table;

[0018] If at least one of the target container ports is included, one of the target container ports is selected to be bound to the container allocated to the user.

[0019] Optionally, the method further comprises:

[0020] If the target container port is not included, searching in the user port relationship table whether there is a container port corresponding to the port number according to the port number corresponding to the base port;

[0021] If so, the port number is incremented by 1, and the process returns to the step of searching in the user port relationship table whether there is a container port corresponding to the port number;

[0022] If not, the port number is bound to the container allocated to the user, and the bound port number and the user information corresponding to the user are saved as new entry information in the user-port relationship table.

[0023] Optionally, the step of obtaining the to-be-recycled container returned by the current node includes:

[0024] When it is detected that the actual occupation time of the container in the node is not less than the corresponding resource occupation time, and the user does not actively release the container, the container is regarded as a container to be recycled and is forcibly recycled.

[0025] Optionally, the step of obtaining the to-be-recycled container returned by the current node includes:

[0026] When it is detected that the user actively releases the container, the container to be recycled returned by this node is obtained.

[0027] Optionally, the method further comprises:

[0028] Comparing the actual occupation time of the to-be-recycled container with the corresponding resource occupation time;

[0029] If the actual occupation time of the to-be-recycled container is less than the resource occupation time;

[0030] The time reward amount of the container to be recycled is determined according to the actual occupation time of the container to be recycled and the resource occupation time, wherein the time reward amount is used to increase the original resource occupation time when the container to be recycled is retrieved.

[0031] Optionally, the method further comprises:

[0032] Determining a container port corresponding to the container to be recycled;

[0033] The container port and the identification code are added to a container recycling data table.

[0034] Optionally, the method further comprises:

[0035] receiving a container retrieval instruction sent by the user, wherein the container retrieval instruction includes the identification code;

[0036] An image corresponding to the identification code in the database is obtained, and a corresponding container is created based on the image.

[0037] Optionally, the method further comprises:

[0038] When the container corresponding to the identification code is retrieved, the container data table and the container recovery data table are updated according to the container port of the container.

[0039] Optionally, the method further comprises:

[0040] If a corresponding container cannot be created based on the image, determine whether the current cluster resources are sufficient;

[0041] If it is insufficient, a list of idle containers in the current cluster is determined according to the resource monitoring system, and the list of idle containers is sent to the user, so that the user can determine a container that can release cluster resources according to the list of idle containers.

[0042] Optionally, the step of determining the idle container list in the current cluster according to the resource monitoring system includes:

[0043] Obtain the running information corresponding to the containers in each node in the current cluster through the resource monitoring system;

[0044] The running information corresponding to the containers in each node is matched with the preset container idle conditions, and an idle container list is constructed based on the successfully matched containers.

[0045] The present application also provides a container resource scheduling device, including:

[0046] The container acquisition module is used to obtain the container to be recycled returned by this node;

[0047] A container saving module, used to save the container to be recycled as an image and generate an identification code corresponding to the image;

[0048] A container recycling module, used to recycle the image and its corresponding identification code into a database, and release the cluster resources occupied by the container to be recycled;

[0049] The container retrieval module is used to send the identification code to the user who uses the container to be recycled after the cluster resources occupied by the container to be recycled are released, so that the user can request the recycled container by using the identification code.

[0050] The present application also provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method described in any one of the above embodiments.

[0051] The present application also provides a computer device, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method described in any one of the above embodiments.

[0052] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0053] The container resource scheduling method, device, storage medium and computer equipment provided by the present application, when obtaining the container to be recycled returned by the current node, the server can first save the container to be recycled as an image and generate an identification code corresponding to the image, then recycle the image and its corresponding identification code to the database, and release the cluster resources occupied by the container to be recycled when it is used, so that other nodes in the cluster can use the released cluster resources to perform related operations such as container creation. In addition, the server can also send the identification code to the user who uses the container to be recycled, so that the user can use the identification code to request the recycled container, thereby greatly improving the scheduling and management efficiency of container cluster resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present application 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0055] Figure 1 A flowchart of a container resource scheduling method provided in an embodiment of the present application;

[0056] Figure 2 A schematic diagram of an application environment provided for an embodiment of the present application;

[0057] Figure 3 A schematic diagram of the structure of a container resource scheduling device provided in an embodiment of the present application;

[0058] Figure 4 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0060] At present, R&D personnel within enterprises also use container technology to build, publish and run application platforms. After each R&D personnel applies for a container from the server, they can use the applied container and the corresponding cluster resources to perform daily operations. However, as the number of containers continues to increase, the scheduling and management of container cluster resources becomes more difficult. Therefore, it is necessary to study a method that can efficiently schedule and manage container cluster resources.

[0061] Based on this, the present application proposes the following technical solutions, as shown below:

[0062] In one embodiment, Figure 1 As shown, Figure 1 A flowchart of a container resource scheduling method provided in an embodiment of the present application; the present application provides a container resource scheduling method, which may include:

[0063] S110: Obtain the to-be-recycled container returned by this node.

[0064] In this step, the server 120 can obtain the container to be recycled returned by this node and recycle the container to be recycled. The obtained container to be recycled can be a container actively released by the user, or a container that is forcibly recycled after the user reaches the upper limit of the container usage time, and there is no specific restriction.

[0065] Indicatively, if Figure 2 As shown, Figure 2 The application environment diagram provided for the embodiment of the present application, the server 120 in the present application is the server serving the client 110, and the service content is such as providing cluster resources to the client 110, saving the client 110 data, etc. The client 110 refers to the program corresponding to the server, which provides local services to the client. In addition to some applications that only run locally, they are generally installed on ordinary client computers and need to cooperate with the server 120 to run. After the development of the Internet, the more commonly used user terminals include web browsers such as the World Wide Web, email clients 110 when sending and receiving emails, and client 110 software for instant messaging, etc. For this type of application, there needs to be corresponding servers and service programs in the network to provide corresponding services, such as database services, email services, etc., so that a specific communication connection is established between the client 110 and the server 120 to ensure the normal operation of the application.

[0066] like Figure 2 As shown, the cluster in this application refers to a group of computers that provide a group of network resources to users as a whole. These individual computer systems are the nodes of the cluster. The nodes in the cluster are core components. Each node runs an operating system and corresponding software services, and resources are entities that can be controlled by a node. When a node fails or the container in the node is released, these resources can be taken over by other nodes in the cluster, such as disk partitions, file systems, IP addresses, application services, shared storage, etc.

[0067] Therefore, in the present application, the server 120 can obtain containers actively released by users in this node, or containers that are forcibly recycled after the user's container usage time quota reaches the upper limit, and after recycling the container, release the occupied cluster resources so that other nodes can take over and use them, thereby ensuring that cluster resources are used reasonably and efficiently.

[0068] S120: Save the container to be recycled as an image, and generate an identification code corresponding to the image.

[0069] In this step, after the container to be recycled returned by the node in the cluster is obtained through S110, the container to be recycled can be saved as an image, and an identification code corresponding to the image can be generated.

[0070] Specifically, when saving the container to be recycled as an image, you can use the docker commit command to save the container to be recycled as an image, such as the "docker commit pinyougou_nginx mynginx" command, where "pinyougou_nginx" represents the container name of the container to be recycled, and "mynginx" represents the image name of the new image generated after executing the command.

[0071] When generating an identification code corresponding to the image, a third-party identification code generation tool may be used to randomly generate an identification code, and the identification code is associated with the image to facilitate subsequent search.

[0072] The above-mentioned method of saving the container to be recycled as an image and the method of generating the identification code are only an example in the present application. The specific method can be selected according to the actual situation and is not limited here.

[0073] S130: Recycling the image and its corresponding identification code into the database, and releasing the cluster resources occupied by the container to be recycled.

[0074] In this step, after the container to be recycled is saved as an image through S120 and an identification code corresponding to the image is generated, the present application can recycle the image and its corresponding identification code into the database, and release the cluster resources occupied by the container to be recycled when it is used, so that other nodes in the cluster can use the released cluster resources to create new containers or perform other operations.

[0075] It can be understood that when the server 120 saves the container to be recycled as an image and generates an identification code corresponding to the image, in order to ensure that the container to be recycled is accurately restored and returned later, the image and its corresponding identification code can be saved in the database, so that when the server 120 receives the container retrieval instruction sent by the user later, the corresponding image can be searched in the database according to the identification code carried in the container retrieval instruction, and a corresponding container can be created based on the image.

[0076] After the image corresponding to the container to be recycled and its identification code are recycled to the database, the server 120 can then release the cluster resources occupied by the container to be recycled, such as releasing the GPU resources, CPU resources, memory, etc. in the node.

[0077] Furthermore, after the present application saves the container to be recycled as an image, a corresponding image tag can be generated, and the container information related to the container to be recycled, such as the user name, cluster resources, container port, identification code, and "recycled" status, can be added to the container recycling data table, so that the recycled containers can be managed through the container recycling data table. When the user wants to retrieve the previously recycled container afterwards, he can directly create it with one click through the CLI command.

[0078] S140: After the cluster resources occupied by the container to be recycled are released, the identification code is sent to the user who uses the container to be recycled, so that the user can use the identification code to request the container to be recycled.

[0079] In this step, after the image and its corresponding identification code are recycled into the database through S130 and the cluster resources occupied by the container to be recycled are released, the server 120 can send the identification code to the user who uses the container to be recycled so that the user can request the recycled container through the identification code.

[0080] For example, when the server 120 sends the identification code to the user who uses the container to be recycled, an interactive instruction can be created. The interactive instruction can be applied to the terminal or the web page, and the input variable of the interactive instruction can be the identification code obtained by the user. After the user enters the identification code and sends the interactive instruction to the server 120, the server 120 can query the image corresponding to the identification code through the database, and use the official creation instruction to create the corresponding container. After the container is created, it can be pushed to the original node and provided for the user to access.

[0081] Furthermore, after the user retrieves the container, the container status in the entry information corresponding to the identification code in the container recycling data table may be changed to "retrieved", or the entry information corresponding to the identification code in the container recycling data table may be directly deleted.

[0082] In the above embodiment, when the container to be recycled returned by this node is obtained, the server 120 can first save the container to be recycled as an image and generate an identification code corresponding to the image. Then, the image and its corresponding identification code can be recycled to the database, and the cluster resources occupied by the container to be recycled when in use can be released. In this way, other nodes in the cluster can use the released cluster resources to perform related operations such as container creation. In addition, the server 120 can also send the identification code to the user who uses the container to be recycled, so that the user can use the identification code to request the recycled container, thereby greatly improving the scheduling and management efficiency of container cluster resources.

[0083] In one embodiment, before the step of obtaining the to-be-recycled container returned by the node in the cluster in S110, the following may also be included:

[0084] S100: receiving a container application instruction sent by a user.

[0085] S101: allocating a container to the user based on the container application instruction, and setting a corresponding resource occupation time for the allocated container.

[0086] In this embodiment, when the server 120 receives a container application instruction sent by a user, a corresponding container can be allocated to the user according to the container application instruction, and a corresponding resource occupation time can be set for the allocated container, so that when the resource occupation time is reached, the container can be recycled and the cluster resources occupied by the container can be released.

[0087] It is understandable that when a user applies for a container, the server 120 allocates corresponding cluster resources to the container, such as GPU resources, CPU resources, memory, etc. If the user occupies these cluster resources for a long time without actually using them, the cluster resources occupied by the user will be idle, resulting in a waste of cluster resources.

[0088] When a user applies for a container, this application sets a corresponding resource occupation time for the container. When the actual occupation time of the container used by the user reaches the upper limit of the resource occupation time, the system will automatically recycle the container and release the corresponding cluster resources, thereby ensuring that the cluster resources are used reasonably and efficiently.

[0089] Specifically, the resource occupation time here can be set to allow the container applied by the user to occupy a maximum of Y hours of GPU resources every X days. For example, it is stipulated that the container applied by the user can occupy a maximum of 72 hours of GPU resources within 5 days. If the actual occupation time of the user reaches the 72-hour limit within 5 days and the user does not actively release it, the container applied by the user will be forcibly recycled. In addition, the user can also actively release it before the 72-hour limit is reached.

[0090] Furthermore, when allocating resource occupancy time to a user, it can be allocated according to the number of GPUs applied for by the user. For example, if a user applies for 2 GPUs, the resource occupancy time of the container applied for by the user will be halved based on the original resource occupancy time.

[0091] In one embodiment, the method may further include:

[0092] S102: Acquire a user-port relationship table, wherein the user-port relationship table stores a plurality of user information and at least one container port bound to each piece of user information.

[0093] S103: Based on the user information carried in the container application instruction, searching the user port relationship table for a container port set corresponding to the user information.

[0094] S104: Obtain a container data table and a container recycling data table, wherein the container data table stores container ports corresponding to containers running in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers.

[0095] S105: Determine whether the container port set includes a target container port that does not exist in the container data table and the container recycling data table.

[0096] S106: If at least one target container port is included, select one of the target container ports to bind to the container allocated to the user.

[0097] In this embodiment, when the user sends a container application instruction, and the server 120 creates a corresponding container in response to the container application instruction, the server 120 can also obtain a corresponding container port allocated to the container. The container port refers to a port in the TCP / IP protocol, and the port number can range from 0 to 65535.

[0098] Generally speaking, ports can be divided into three types: one is the well-known port, from 0 to 1023, which is tightly bound to some services, and the communication of these ports clearly indicates the protocol of a certain service; one is the registered port, from 1024 to 49151, which is loosely bound to some services; and there is a dynamic and / or private port, from 49152 to 65535. For example, machines usually allocate dynamic ports starting from 1024, and SUN's RPC port starts from 32768.

[0099] In this application, before the container recycling mechanism is introduced, network ports can be allocated to users sequentially starting from a base port (for example, 32000), that is, by looking up the container data table, the collection of container ports corresponding to the containers currently in use in the cluster is determined, and then the first unoccupied port in the network port is allocated to the container currently being applied for (for example: the currently occupied ports are 32000, 32001, 32002, 32004, 32006, then when a user applies for a new container, the port allocated to the container is 32003).

[0100] When the container recycling mechanism is introduced in this application, the port reservation design is developed. The specific design process is as follows:

[0101] (1) Create a new user port relationship table, which is used to record user information and bound container ports in the cluster. The same user is allowed to have multiple bound container ports, that is, the same user can appear in multiple rows in the user port relationship table. An example of the user port relationship table is as follows:

[0102] id user port 1 Ben 32000 2 Ada 32001 3 Ben 32002 4 Jerry 32003 5 Ada 32004 6 Ben 32005 7 Jerry 32006

[0103] User port relationship table

[0104] Among them, id in the user-port relationship table refers to the identification code, user refers to the user name, and port refers to the container port. Each container port has a corresponding user name and a corresponding identification code.

[0105] (2) When a user applies for a new container, the server 120 can obtain a pre-created user-port relationship table and query the user information in the user-port relationship table to obtain a currently bound container port set corresponding to the user information. The server 120 can then query the container ports in the container port set one by one in the container data table and the container recycling data table. If it is found that the target container port in the container port set is neither occupied by a container in the running state nor appears in the container port in the "recycled" state in the container recycling data table, the server 120 can directly allocate the target container port to the newly applied container. In addition, when there are multiple target container ports, one of them can be selected for allocation.

[0106] It can be understood that the user port relationship table in the present application stores information of multiple users in the cluster and at least one container port bound to each user information, the container data table stores container ports corresponding to running containers in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers.

[0107] When the query finds that the container port set contains a target container port that does not exist in the container data table and the container recycling data table, it indicates that the container port currently bound to the user information is not completely occupied. At this time, the unoccupied container port can be used as the target container port and bound to the user's newly applied container. This ensures that when a new container is created, there is no conflict with the port of the running container, and at the same time ensures that when the recycled container is retrieved, the corresponding port of the original container is not occupied.

[0108] In one embodiment, the method may further include:

[0109] S107: If the target container port is not included, searching the user port relationship table for a container port corresponding to the port number according to the port number corresponding to the base port.

[0110] S108: If it exists, the port number is increased by 1, and the process returns to the step of searching the user port relationship table for a container port corresponding to the port number.

[0111] S109: If it does not exist, the port number is bound to the container allocated to the user, and the bound port number and the user information corresponding to the user are saved as new entry information in the user-port relationship table.

[0112] In this embodiment, if the container port set bound to the user information when the user applies for a new container is all occupied, you can start from the base port (for example, 32000) and add 1 one by one to find the first port number that is not in the container port set, assign this port number to the newly applied container, and record the user and the container port as new entry information in the user port relationship table.

[0113] It is understandable that when all container ports in the container port set corresponding to the current user are occupied, since the current user cannot occupy the container ports bound by other users, the server 120 can re-allocate the corresponding container port to the container, thereby ensuring that the newly allocated port will not be occupied by other containers.

[0114] In one embodiment, the step of obtaining the to-be-recycled container returned by the node in S110 may include:

[0115] When it is detected that the actual occupation time of the container in the node is not less than the corresponding resource occupation time, and the user does not actively release the container, the container is regarded as a container to be recycled and is forcibly recycled.

[0116] In this embodiment, when it is detected that the actual occupation time of the container in the node is not less than the corresponding resource occupation time, and the user does not actively release the container, the server 120 may forcibly recycle the container as a container to be recycled.

[0117] For example, it is stipulated that the container applied for by the user can occupy GPU resources for a maximum of 72 hours within 5 days. If the actual usage time of the user reaches the 72-hour limit within 5 days and the user does not actively release it, the container applied for by the user will be forcibly recycled, thereby ensuring that cluster resources are used reasonably and efficiently.

[0118] In one embodiment, the step of obtaining the container to be recycled returned by the node in S110 may include: when it is detected that the user actively releases the container, obtaining the container to be recycled returned by the node.

[0119] In this embodiment, when the server 120 detects that the user actively releases the cluster resources corresponding to the container, it can obtain the container to be recycled returned by the node in the cluster when the user releases the cluster resources corresponding to the container, and recycle the container to be recycled.

[0120] In one embodiment, the method may further include:

[0121] S111: Compare the actual occupation time of the to-be-recycled container with the corresponding resource occupation time.

[0122] S112: If the actual occupation time of the to-be-recycled container is less than the resource occupation time.

[0123] S113: determining a time reward amount for the container to be recycled according to the actual occupation time of the container to be recycled and the resource occupation time, wherein the time reward amount is used to increase the original resource occupation time when the container to be recycled is retrieved.

[0124] In this embodiment, when the user actively releases the container, the actual occupation time of the container to be recycled can be obtained, and the actual occupation time can be compared with the resource occupation time of the container to be recycled to determine whether the actual occupation time of the container to be recycled is less than the resource occupation time. If it is less, the time reward amount of the container to be recycled is determined based on the actual occupation time and the resource occupation time, and when the container to be recycled is retrieved, the corresponding resource occupation time is recalculated based on the time reward amount.

[0125] Specifically, if within the resource occupation time corresponding to the current container to be recycled, the number of GPU, CPU, and memory hours used by the user to use the container is lower than the resource occupation time, then the server 120 can add the time saved by the user when using the container this time to the resource occupation time of the next time, so as to encourage the user to actively release the container.

[0126] Taking GPU as an example, when a 72-hour GPU resource usage limit is set within five days, the user actively releases the container within five days, and monitoring shows that the user's usage time is 40 hours. Then, when the user retrieves the container and allocates the corresponding resource usage time, the server 120 can allocate 72+(72-40) / 2=88 hours of resource usage time, thereby encouraging the user to close the container on his own.

[0127] Furthermore, the present application may set specific incentive measures based on actual conditions. For example, the incentive measures may be to add half of the remaining time from the previous time to the existing resource occupancy time when allocating resource occupancy time next time, or to add thirty percent of the remaining time from the previous time to the existing resource occupancy time, so as to form corresponding incentive measures.

[0128] Furthermore, the present application can also set an upper limit for the resource occupancy time. When the accumulated resource occupancy time of a user reaches the upper limit, the corresponding resource occupancy time will no longer be adjusted for the user, so as to avoid the container applied by the user being occupied for a long time, resulting in the inability to reasonably circulate resources in the cluster.

[0129] In one embodiment, the method may further include:

[0130] S151: Determine the container port corresponding to the container to be recycled.

[0131] S152: Add the container port and the identification code to a container recycling data table.

[0132] In this embodiment, after the container to be recycled is recycled, the container port corresponding to the container to be recycled can be determined first, and then the container port and the identification code can be added to the container recycling data table, so that the container port corresponding to the recycled container can be managed through the container recycling data table.

[0133] It can be understood that after the server 120 obtains the container to be recycled, it can obtain the container information corresponding to the container to be recycled, such as the user name, cluster resources, container port, identification code, etc., and then add the obtained user name, cluster resources, container port, identification code, and "recycled" status to the container recycling data table, so as to manage the recycled containers through the container recycling data table. When the user wants to retrieve the previously recycled container afterwards, he can directly create it with one click through the CLI command.

[0134] In one embodiment, the method may further include:

[0135] S161: Receive a container retrieval instruction sent by the user, where the container retrieval instruction includes the identification code.

[0136] S162: Acquire an image corresponding to the identification code in the database, and create a corresponding container based on the image.

[0137] In this embodiment, after the server 120 sends the identification code corresponding to the recycled container to the corresponding user, the user can send a container retrieval instruction through the client 110, and the client 110 sends the container retrieval instruction to the server 120, so that the server 120 creates a corresponding container according to the container retrieval instruction and returns it to the corresponding client 110.

[0138] Specifically, when the server 120 sends the identification code to the user who uses the container to be recycled, an interactive instruction can be created. The interactive instruction can be applied to the terminal or the web page, and the input variable of the interactive instruction can be the identification code obtained by the user. After the user enters the identification code through the client 110 and sends the interactive instruction to the server 120, the server 120 can query the image corresponding to the identification code through the database, and use the official creation instruction to create the corresponding container. After the container is created, it can be pushed to the original node and provided for the user to access.

[0139] In one embodiment, the method may further include:

[0140] S1631: When the container corresponding to the identification code is retrieved, the container data table and the container recovery data table are updated according to the container port of the container.

[0141] In this embodiment, when the container corresponding to the identification code is retrieved, the server 120 can add the container and the container port corresponding to the container in the container data table; in addition, the server 120 can also change the status of the container port corresponding to the container in the container recovery data table to "retrieved" or delete the entry information corresponding to the container.

[0142] In one embodiment, the method may further include:

[0143] S1641: If a corresponding container cannot be created based on the image, determine whether current cluster resources are sufficient.

[0144] S1642: If it is insufficient, determine an idle container list in the current cluster according to the resource monitoring system, and send the idle container list to the user, so that the user can determine a container that can release cluster resources according to the idle container list.

[0145] In this embodiment, when the server 120 cannot create a corresponding container based on the acquired image, it may be due to insufficient cluster resources, resulting in the inability to create a corresponding container in time after the image is taken out. Insufficient cluster resources may be the result of idle containers occupying resources not reaching the resource occupation time and therefore unable to be forcibly recycled or actively released.

[0146] Therefore, in this case, the server 120 can first determine whether the current cluster resources are sufficient. If not, the server 120 can determine the idle container list in the current cluster according to the resource monitoring system, and send the idle container list to the user so that the user can determine the container that can release cluster resources according to the idle container list.

[0147] In one embodiment, the step of determining the idle container list in the current cluster according to the resource monitoring system in S1642 may include:

[0148] S6421: Obtain operation information corresponding to the container in each node in the current cluster through the resource monitoring system.

[0149] S6422: Match the operation information corresponding to the container in each node with the preset container idle conditions respectively, and build an idle container list according to the successfully matched containers.

[0150] In this embodiment, when the server 120 determines that the current cluster resources are insufficient and determines the idle container list in the current cluster according to the resource monitoring system, it can first obtain the operation information corresponding to the container in each node in the current cluster through the resource monitoring system, and then match the operation information corresponding to the container in each node with the preset container idle condition, and build an idle container list based on the successfully matched containers.

[0151] Specifically, since users sometimes forget to actively recycle idle containers, and the resource occupancy time of the container does not reach the upper limit, the container cannot be recycled by the system in time. At this time, the server 120 can use the existing resource monitoring system (such as some resource monitoring tools that can monitor the GPU, CPU, memory usage, number of processes, etc. of the container applied by each user) to obtain the operation information of each container, and match the operation information corresponding to the container in each node with the preset container idle conditions, and then use the successfully matched containers as idle containers to build an idle container list, and provide the idle container list to the user.

[0152] For example, a user may send a specific CLI command to the server 120, wherein the parameter included in the CLI command is the cluster name, so as to query the container in each node in the current cluster that is most likely to be idle. The information returned by the server 120 is a table in the following format:

[0153] top user container GPU cpu memory duration team 1 Ben bentest 2 4 10 20 map 2 Ada adatest 1 4 20 30 infra 3 Jerry jerrytest 1 4 10 40 data ...

[0154] Idle container list

[0155] After the user obtains the idle container list, the user may communicate with the users corresponding to the idle containers listed in the idle container list to determine whether there are containers that can release cluster resources.

[0156] Among them, when the server 120 determines whether the container in each node is an idle container according to the preset container idle conditions, the preset idle container conditions may include that the GPU, CPU, and Memory utilization rates are lower than 0.1% in the past period of time, the size of the content read and written by the container is lower than 1kb in the past period of time, and the number of processes has not changed in the past period of time. If the above three idle container conditions are met at the same time, it is preliminarily determined to be an idle container and the idle container is included in the idle container list.

[0157] It should be noted that the idle containers in this application do not refer to absolute idleness, but relatively suspected idleness. After the user obtains the idle container list, further confirmation can be performed based on the user names listed in the idle container list in order to release the cluster resources occupied by the truly idle containers.

[0158] The container resource scheduling device provided in an embodiment of the present application is described below. The container resource scheduling device described below and the container resource scheduling method described above can be referred to each other.

[0159] In one embodiment, Figure 3 As shown, Figure 3 A schematic diagram of the structure of a container resource scheduling device provided in an embodiment of the present application; the present application also provides a container resource scheduling device, including a container acquisition module 210, a container storage module 220, a container recovery module 230, and a container retrieval module 240, which specifically include the following:

[0160] The container acquisition module 210 is used to acquire the to-be-recycled container returned by the node.

[0161] The container saving module 220 is used to save the container to be recycled as an image and generate an identification code corresponding to the image.

[0162] The container recycling module 230 is used to recycle the image and its corresponding identification code into a database, and release the cluster resources occupied by the container to be recycled.

[0163] The container retrieval module 240 is used to send the identification code to the user who uses the container to be recycled after the cluster resources occupied by the container to be recycled are released, so that the user can use the identification code to request the recycled container.

[0164] In the above embodiment, when the container to be recycled returned by this node is obtained, the server 120 can first save the container to be recycled as an image and generate an identification code corresponding to the image. Then, the image and its corresponding identification code can be recycled to the database, and the cluster resources occupied by the container to be recycled when in use can be released. In this way, other nodes in the cluster can use the released cluster resources to perform related operations such as container creation. In addition, the server 120 can also send the identification code to the user who uses the container to be recycled, so that the user can use the identification code to request the recycled container, thereby greatly improving the scheduling and management efficiency of container cluster resources.

[0165] In one embodiment, the device may further include:

[0166] The first instruction receiving module is used to receive a container application instruction sent by a user.

[0167] The duration allocation module is used to allocate a container to the user based on the container application instruction, and set a corresponding resource occupation duration for the allocated container.

[0168] In one embodiment, the device may further include:

[0169] The first acquisition module is used to acquire a user-port relationship table, in which a plurality of user information and at least one container port bound to each user information are stored.

[0170] The first search module is used to search the container port set corresponding to the user information in the user port relationship table based on the user information carried in the container application instruction.

[0171] The second acquisition module is used to acquire a container data table and a container recycling data table, wherein the container data table stores container ports corresponding to containers running in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers.

[0172] The target confirmation module is used to determine whether the container port set includes a target container port that does not exist in the container data table and the container recovery data table.

[0173] The first binding module is used to select one of the target container ports to bind to the container allocated to the user if at least one of the target container ports is included.

[0174] In one embodiment, the device may further include:

[0175] The second search module is used to search whether there is a container port corresponding to the port number in the user port relationship table according to the port number corresponding to the base port if the target container port is not included.

[0176] The execution module is returned to increase the port number by 1 if it exists, and returns to execute the step of searching in the user port relationship table whether there is a container port corresponding to the port number.

[0177] The second binding module is used to bind the port number with the container allocated to the user if it does not exist, and save the bound port number and the user information corresponding to the user as new entry information in the user-port relationship table.

[0178] In one embodiment, the container acquisition module 210 may include:

[0179] The forced recycling module is used to treat the container as a container to be recycled and forcibly recycle it when it is detected that the actual occupation time of the container in the node is not less than the corresponding resource occupation time and the user does not actively release the container.

[0180] In one embodiment, the container acquisition module 210 may include:

[0181] The active release module is used to obtain the container to be recycled returned by this node when it is detected that the user actively releases the container.

[0182] In one embodiment, the device may further include:

[0183] The comparison module is used to compare the actual occupation time of the to-be-recycled container with the corresponding resource occupation time.

[0184] The judgment module is used to determine if the actual occupation time of the to-be-recycled container is less than the resource occupation time.

[0185] The reward determination module is used to determine the time reward amount of the container to be recycled according to the actual occupation time of the container to be recycled and the resource occupation time, wherein the time reward amount is used to increase the original resource occupation time when the container to be recycled is retrieved.

[0186] In one embodiment, the device may further include:

[0187] The port confirmation module is used to determine the container port corresponding to the container to be recycled.

[0188] An adding module is used to add the container port and the identification code to a container recycling data table.

[0189] In one embodiment, the device may further include:

[0190] The second instruction receiving module is configured to receive a container retrieval instruction sent by the user, wherein the container retrieval instruction includes the identification code.

[0191] The container creation module is used to obtain the image corresponding to the identification code in the database and create a corresponding container based on the image.

[0192] In one embodiment, the device may further include:

[0193] The information updating module is used to update the container data table and the container recovery data table according to the container port of the container after the container corresponding to the identification code is retrieved.

[0194] In one embodiment, the device may further include:

[0195] The resource judgment module is used to determine whether the current cluster resources are sufficient if the corresponding container cannot be created based on the image.

[0196] The list confirmation module is used to determine the idle container list in the current cluster according to the resource monitoring system if it is insufficient, and send the idle container list to the user so that the user can determine the container that can release cluster resources according to the idle container list.

[0197] In one embodiment, the list confirmation module may include:

[0198] The information acquisition module is used to obtain the operation information corresponding to the container in each node in the current cluster through the resource monitoring system.

[0199] The matching module is used to match the operation information corresponding to the containers in each node with the preset container idle conditions, and to build an idle container list based on the successfully matched containers.

[0200] In one embodiment, the present application further provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method described in any one of the above embodiments.

[0201] In one embodiment, the present application further provides a computer device, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method described in any one of the above embodiments.

[0202] Indicatively, if Figure 4 As shown, Figure 4 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 4 , the computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions executable by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the container resource scheduling method of any of the above embodiments.

[0203] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.

[0204] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0205] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0206] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.

[0207] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A container resource scheduling method, characterized in that: The method comprises: Receive container application instructions sent by users; Based on the container application instruction, allocate a container to the user, and set a corresponding resource occupation time for the allocated container; Acquire a user-port relationship table, wherein the user-port relationship table stores a plurality of user information and at least one container port bound to each user information; Based on the user information carried in the container application instruction, searching the user port relationship table for a container port set corresponding to the user information; Obtain a container data table and a container recycling data table, wherein the container data table stores container ports corresponding to containers running in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers; Determine whether the container port set includes a target container port that does not exist in the container data table and the container recovery data table; If at least one of the target container ports is included, selecting one of the target container ports to bind to the container allocated to the user; If the target container port is not included, searching in the user port relationship table whether there is a container port corresponding to the port number according to the port number corresponding to the base port; If so, the port number is incremented by 1, and the process returns to the step of searching in the user port relationship table whether there is a container port corresponding to the port number; If not, binding the port number to the container allocated to the user, and saving the bound port number and the user information corresponding to the user as new entry information in the user-port relationship table; Get the container to be recycled returned by this node; Saving the container to be recycled as an image, and generating an identification code corresponding to the image; Recycling the image and its corresponding identification code into a database, and releasing the cluster resources occupied by the container to be recycled; After the cluster resources occupied by the container to be recycled are released, the identification code is sent to the user who uses the container to be recycled, so that the user can use the identification code to request the container to be recycled.

2. The container resource scheduling method according to claim 1, characterized in that: The step of obtaining the to-be-recycled container returned by the node includes: When it is detected that the actual occupation time of the container in the node is not less than the corresponding resource occupation time, and the user does not actively release the container, the container is regarded as a container to be recycled and is forcibly recycled.

3. The container resource scheduling method according to claim 1, characterized in that: The step of obtaining the to-be-recycled container returned by the node includes: When it is detected that the user actively releases the container, the container to be recycled returned by this node is obtained.

4. The container resource scheduling method according to claim 3, characterized in that: The method further comprises: Comparing the actual occupation time of the to-be-recycled container with the corresponding resource occupation time; If the actual occupation time of the to-be-recycled container is less than the resource occupation time; The time reward amount of the container to be recycled is determined according to the actual occupation time of the container to be recycled and the resource occupation time, wherein the time reward amount is used to increase the original resource occupation time when the container to be recycled is retrieved.

5. The container resource scheduling method according to claim 1, characterized in that: The method further comprises: Determining a container port corresponding to the container to be recycled; The container port and the identification code are added to a container recycling data table.

6. The container resource scheduling method according to any one of claims 1 to 5, characterized in that: The method further comprises: receiving a container retrieval instruction sent by the user, wherein the container retrieval instruction includes the identification code; An image corresponding to the identification code in the database is obtained, and a corresponding container is created based on the image.

7. The container resource scheduling method according to claim 6, characterized in that: The method further comprises: When the container corresponding to the identification code is retrieved, the container data table and the container recovery data table are updated according to the container port of the container.

8. The container resource scheduling method according to claim 6, characterized in that: The method further comprises: If a corresponding container cannot be created based on the image, determine whether the current cluster resources are sufficient; If it is insufficient, a list of idle containers in the current cluster is determined according to the resource monitoring system, and the list of idle containers is sent to the user, so that the user can determine a container that can release cluster resources according to the list of idle containers.

9. The container resource scheduling method according to claim 8, characterized in that: The step of determining the idle container list in the current cluster according to the resource monitoring system includes: Obtain the running information corresponding to the containers in each node in the current cluster through the resource monitoring system; The running information corresponding to the containers in each node is matched with the preset container idle conditions, and an idle container list is constructed based on the successfully matched containers.

10. A container resource scheduling device, characterized in that: include: A first instruction receiving module, used to receive a container application instruction sent by a user; A duration allocation module, configured to allocate a container to the user based on the container application instruction, and set a corresponding resource occupation duration for the allocated container; A first acquisition module is used to acquire a user-port relationship table, wherein the user-port relationship table stores a plurality of user information and at least one container port bound to each user information; A first search module, configured to search the user port relationship table for a container port set corresponding to the user information based on the user information carried in the container application instruction; A second acquisition module is used to acquire a container data table and a container recycling data table, wherein the container data table stores container ports corresponding to containers running in each node in the cluster, and the container recycling data table stores container ports corresponding to recycled containers; A target confirmation module, used to determine whether the container port set includes a target container port that does not exist in the container data table and the container recovery data table; A first binding module, configured to select one of the target container ports to bind to the container allocated to the user if at least one target container port is included; A second search module is used to search whether there is a container port corresponding to the port number in the user port relationship table according to the port number corresponding to the base port if the target container port is not included; Returning to the execution module, for if the port number exists, adding 1 to the port number, and returning to the step of searching in the user port relationship table whether there is a container port corresponding to the port number; A second binding module is used to bind the port number with the container allocated to the user if it does not exist, and save the bound port number and the user information corresponding to the user as new entry information in the user-port relationship table; The container acquisition module is used to obtain the container to be recycled returned by this node; A container saving module, used to save the container to be recycled as an image and generate an identification code corresponding to the image; A container recycling module, used to recycle the image and its corresponding identification code into a database, and release the cluster resources occupied by the container to be recycled; The container retrieval module is used to send the identification code to the user who uses the container to be recycled after the cluster resources occupied by the container to be recycled are released, so that the user can use the identification code to request the recycled container.

11. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method according to any one of claims 1 to 9.

12. A computer device, characterized in that: The computer device stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the container resource scheduling method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Service processing method and device based on container technology, and computer equipment

    CN110955492A