Method and device for setting priority of processes in container

By establishing a mapping relationship between priorities and containers in the container orchestration system or container runtime, the process priority within the container is dynamically set, which solves the problem of process priority setting within the container and container ecological compatibility, and improves business response speed and resource management. flexibility.

CN118535274APending Publication Date: 2024-08-23ZTE CORP
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310158192.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-23
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In the existing technology, the process priority setting within the container cannot be effectively compatible with the container ecosystem, resulting in insufficient response speed for services carried by different containers, complex management, and lack of flexibility.

Method used

By receiving client requests from the container orchestration system or container runtime, it provides a priority management interface and data structure, establishes a mapping relationship between priorities and containers, and dynamically sets the priority of processes within the container to achieve flexible management of container resources.

Benefits of technology

It solves the problem of process priority setting in the container and the compatibility of the container ecosystem, improves the response speed of key services in the container, simplifies resource management, and achieves flexible and effective priority setting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535274A
    Figure CN118535274A
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for setting the priority of processes in a container, and the method comprises the steps: receiving a container request issued by a client when a container arrangement system or a container runs, and setting the priority of the processes in the container according to the container request and a pre-established priority as a mapping relation between system resources and the container. Through the embodiment of the invention, the problem that the setting of the process priority cannot be well compatible with the container ecology in the related technology can be solved, the static setting and the dynamic adjustment of the process priority in the container are realized through the system resource management of bringing the priority into the container ecology, and the container ecology can be well compatible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing, and in particular to a method and device for setting process priority within a container. Background Art

[0002] Containers are a lightweight virtualization technology. Containers can be used to run everything from small microservices or software processes to large applications. Containers contain all the necessary executables, binary code, libraries, and configuration files. However, containers do not contain operating system images, so they are more lightweight and portable, and have little resource overhead.

[0003] In the prior art, the resources that can be managed and orchestrated by the container ecosystem mainly include the central processing unit (CPU), memory, network, disk input / output (I / O), etc. However, there is currently a gap in the industry in terms of setting the priority of processes within the container while being compatible with the container ecosystem. Generally speaking, the priority of processes within a container is inherited from the container runtime, so the priority of processes within the container is the same for multiple containers, which brings some problems: the businesses carried by different containers are often different, and the existing container ecosystem is not divided according to different businesses; for some containers, a higher priority may be required to quickly respond to business needs, but because the priorities between container processes are the same, their response speed often cannot meet the requirements.

[0004] Currently, various operating systems provide some tools to set the priority of processes on the system, such as the taskset command line tool on the Linux operating system. However, there are also some problems with this method: it increases the management complexity of the system, and the direct use of the command line to set it cannot be associated with the container ecosystem; the priority between containers requires additional tools to obtain when it is out of the container ecosystem; there is no way to effectively manage the priority in the container ecosystem. In general, it is technically feasible to use the tools that come with the operating system to set the priority of the process in the container, but from the perspective of compatibility with the container ecosystem, this method is complex to manage, requires additional management components, and lacks flexibility.

[0005] In summary, there is no good solution to the problem that the setting of process priority in related technologies is not well compatible with the container ecosystem. Summary of the invention

[0006] The embodiments of the present application provide a method and device for setting process priority in a container, so as to at least solve the problem that the setting of process priority in the related art is not well compatible with the container ecosystem.

[0007] According to an embodiment of the present application, a method for setting the priority of a process in a container is provided, which is applied to container runtime, and the method includes: receiving a container request sent by a container orchestration system or a client during container runtime; setting the priority of the process in the container according to the container request and a pre-established priority as a mapping relationship between system resources and containers.

[0008] In one embodiment of the present application, before receiving a container request issued by a container orchestration system or a container runtime client, the method further includes: providing a priority management interface and a priority management data structure; receiving a priority management request issued by a container orchestration system or a container runtime client according to the priority management interface and the priority management data structure; establishing a mapping relationship between priority and container according to the priority management request; and managing priority by managing system resources.

[0009] In one embodiment of the present application, after establishing a mapping relationship between the container and the priority according to the priority management request, the method further includes: sending the priority of the process in the container to the container orchestration system or the client of the container runtime according to the mapping relationship.

[0010] In one embodiment of the present application, the priority of a process in a container is set according to a container request and a pre-established mapping relationship between the container and the priority, including: determining the request content of the container request, wherein the request content includes creating a container, updating a container, and entering a container; and setting the priority of the process in the container according to the request content.

[0011] In one embodiment of the present application, the priority of the process in the container is set according to the request content, including: when the request content is to create a container, starting a new container; obtaining a priority parameter from the container request, or obtaining a priority instruction from the container image; setting the priority of the process in the new container according to the priority parameter or the priority instruction.

[0012] In one embodiment of the present application, the priority of the process in the container is set according to the request content, including: when the request content is to update the container, obtaining a priority parameter from the container request; and updating the priority of the process in the container according to the priority parameter.

[0013] In one embodiment of the present application, the priority of the process in the container is set according to the request content, including: when the request content is to enter the container, enter the container and start a new process in the container, wherein the new process inherits the priority of the original process in the container.

[0014] In one embodiment of the present application, the method further includes: the request content also includes querying the container; when the request content is querying the container, obtaining the priority of the process in the container; and returning the priority of the process in the container to the container orchestration system or the client of the container runtime.

[0015] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps of any of the above method embodiments when executed by a processor.

[0016] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0017] Through the embodiments of the present application, priority is incorporated into the management of the container runtime as a resource, which can solve the problem that the setting of process priority in related technologies is not well compatible with the container ecosystem. The priority of the process in the container can be flexibly and effectively set in a way that is compatible with the container ecosystem, thereby improving the resource management of the container ecosystem and ensuring the response speed of key businesses. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a hardware structure block diagram of the method for setting the priority of a process in a container according to an embodiment of the present application;

[0019] Figure 2 is a flowchart of a method for setting process priority in a container according to an embodiment of the present application;

[0020] Figure 3 It is a structural diagram of incorporating priority into container runtime resource management according to an embodiment of the present application;

[0021] Figure 4 is a schematic diagram of a system structure for setting the priority of a process in a container according to an embodiment of the present application;

[0022] Figure 5 is a flow chart of a method for setting the priority of a process in a container according to a request to create a container in an embodiment of the present application;

[0023] Figure 6 is a flow chart of a method for setting the priority of a process in a container according to an update container request in an embodiment of the present application;

[0024] Figure 7 is a flow chart of a method for setting the priority of a process in a container according to a request to enter a container in an embodiment of the present application;

[0025] Figure 8This is a flow chart of a method for obtaining the priority of a process in a container according to a query container request in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0028] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 : is a hardware structure block diagram of the method for setting the priority of a process in a container according to an embodiment of the present application, such as Figure 1 As shown, the hardware board may include one or more ( Figure 1 Only one is shown in the figure) a processor 12 (the processor 12 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device) and a memory 14 for storing data, wherein the mobile terminal may also include a transmission device 16 for communication functions and an input and output device 18. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0029] The memory 14 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for setting the priority of processes in a container in the embodiment of the present application. The processor 12 executes various functional applications and the method for setting the priority of processes in a container by running the computer program stored in the memory 14, that is, implementing the above method. The memory 14 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 14 may further include a memory remotely arranged relative to the processor 12, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0030] The transmission device 16 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider. In one example, the transmission device 16 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 16 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0031] The embodiments of the present application can also be applied to hardware servers of architectures such as ARM / X86 / PowerPC / MIPS, running real-time and non-real-time server operating systems, or running real-time and non-real-time virtual machine operating systems.

[0032] In this embodiment, a method for setting the priority of a process in a container is provided, which is applied to the container runtime. Figure 2 is a flowchart of a method for setting process priority in a container according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:

[0033] Step S202, receiving a container request sent by a container orchestration system or a container runtime client;

[0034] Step S204: setting the priority of the process in the container according to the container request and the pre-established priority as a mapping relationship between system resources and the container.

[0035] Through the above steps S202 to S204, the priority is incorporated into the system resource management in the container ecosystem. Under the management of the container orchestration system or the container runtime client, the priority is flexibly and effectively set to the process in the container according to the business importance, solving the problem that the setting of process priority in related technologies is not well compatible with the container ecosystem. The priority of the process in the container can be set statically or dynamically according to the business operation status, and it can be well compatible with the container ecosystem.

[0036] The container orchestration system in this embodiment refers to all systems used to automatically deploy, scale, and manage containerized applications, and the client of the container runtime refers to an application that uses client tools to manage containers.

[0037] In an optional embodiment, before step S202, the method may further include the following steps: providing a priority management interface and a priority management data structure, receiving a priority management request issued by a container orchestration system or a client at container runtime according to the priority management interface and the priority management data structure; establishing a mapping relationship between priority and container according to the priority management request, and managing the priority by managing system resources.

[0038] In this embodiment, the container orchestration system or the client of the container runtime exchanges information related to priority management with the container runtime through the priority management interface and the priority management data structure.

[0039] Furthermore, after the priority is managed by managing system resources, the priority of the process in the container can be sent to the container orchestration system or the client of the container runtime according to the mapping relationship.

[0040] In this embodiment, step S204 may specifically include the following steps:

[0041] Step S2042, determining the request content of the container request, the request content includes creating a container, updating a container and entering a container;

[0042] Step S2044: setting the priority of the process in the container according to the request content.

[0043] In one embodiment, step S2044 may specifically include: when the request content is to create a container, starting a new container; obtaining a priority parameter from the container request, or obtaining a priority instruction from the container image; and setting the priority of the process in the new container according to the priority parameter or the priority instruction.

[0044] The request to create a container in this embodiment may or may not carry a priority parameter. When the request to create a container does not carry a priority parameter, a priority instruction needs to be obtained from the container image.

[0045] The container image in this embodiment contains the packaged application and its dependencies, as well as information about the processes running at startup, including priority instructions.

[0046] In another embodiment, step S2044 may specifically include: when the request content is to update the container, obtaining a priority parameter from the container request; and updating the priority of the process in the container according to the priority parameter.

[0047] In this embodiment, when the request content is to update the container, it is also necessary to determine whether the container request carries a priority parameter. If the determination result is yes, the priority parameter is used to update the priority of the process in the container.

[0048] In another embodiment, step S2044 may specifically include: when the request content is to enter a container, entering the container, and starting a new process in the container.

[0049] Specifically, a new process in a container can inherit the priority of the original process in the container. If the priorities of various processes in the container are consistent, there is no need to set the priority for each process separately.

[0050] In this embodiment, the request to enter the container may also carry a priority parameter to set the priority of the process in the container.

[0051] In another embodiment, step S2044 may further specifically include: when the request content is to query the container, obtaining the priority of the process in the container, wherein the request content also includes querying the container; returning the priority of the process in the container to the container orchestration system or the client of the container runtime.

[0052] Through the above steps S2042 and S2044, the specific content of the container request can be determined and corresponding operations can be performed on the priority of the process in the container according to the determination result.

[0053] The embodiment of the present application regards priority as a system resource, and flexibly and effectively sets the priority to the process in the container according to the business importance under the management of the container orchestration system or the container runtime client, specifically including:

[0054] The container orchestration system or container runtime client tool carries a priority parameter when starting a container to set the priority of the process in the container; if no priority parameter is carried, the process in the container inherits the priority of the parent process;

[0055] The container orchestration system or container runtime client tool sends a request to enter the container. If a new process needs to be started after entering the container, the new process inherits the priority of the original process in the container.

[0056] After the container is started, the container orchestration system or container runtime client tool dynamically updates the priorities of all processes in the container as needed;

[0057] Set the priority of the process in the container through the priority instructions built into the container image;

[0058] Container orchestration systems and container runtime client tools can query the priorities of processes within containers in real time.

[0059] The embodiments of the present application give the container runtime more functionality to adapt to different business scenarios, and all priority setting methods are compatible with the container ecosystem, which can improve the response speed of key services in the container. The embodiments of the present application can set priorities statically or dynamically according to the business operation situation. The container runtime or container orchestration system can query the priority of the process in the container in real time, and can also readjust the priority of the process in the container according to the situation.

[0060] Figure 3 is a schematic diagram of a device structure for incorporating priority into container runtime resource management according to an embodiment of the present application, such as Figure 3 As shown, the device structure of resource management mainly includes:

[0061] Management interface 32 , data structure 34 and resource management module 36 .

[0062] In this embodiment, the management interface 32 and the data structure 34 are the management interface and data structure between the client of the container orchestration system / container runtime and the container runtime, and specifically may be the priority management interface and priority management data structure in the above embodiment.

[0063] In this embodiment, the resource management module 36 is located inside the container runtime and is mainly used to manage the system resources corresponding to the container. The priority can be included in the management as a resource through the resource management module 36;

[0064] Specifically, in addition to the priority, the resource management module 36 can also manage the following system resources: central processing unit (CPU), memory, disk input / output (I / O), network I / O, etc.

[0065] In this embodiment, the priority can also be managed by the following steps:

[0066] Step S302: The container orchestration system / container runtime client and the container runtime provide an interface and related data structure for managing priority;

[0067] Step S304: The container orchestration system and the container runtime client tool send a request to the container runtime according to the interface and data structure in step S302;

[0068] Step S306, the container runtime establishes a mapping relationship between the priority and the container according to the request in step S304, and incorporates the priority into the resource management module of the container runtime;

[0069] Step S308: The container orchestration system or the container runtime client tool queries the priority of the process in the container according to the mapping relationship established in step S306.

[0070] Further, the request in step S304 may be a priority management request.

[0071] Figure 4 is a schematic diagram of a system structure for setting the priority of a process in a container according to an embodiment of the present application, such as Figure 4 As shown, the system structure mainly includes:

[0072] Container orchestration system 41, container runtime client 42, container runtime 43, container 44 and container image 45.

[0073] The container orchestration system 41 is used to automatically deploy, scale, and manage containerized applications, including but not limited to the Kubernetes system.

[0074] The container runtime client 42 is used to manage containers using client tools, including but not limited to Docker Swarm tools.

[0075] The container runtime 43 is used to manage the entire life cycle of the container. The functions it provides include but are not limited to: container image format management, container image building, container image management, container instance management, and running containers.

[0076] A container 44 is an instance created by the container runtime 43 that contains all the elements required to run in an environment.

[0077] A container image 45 contains a packaged application and its dependencies, as well as information about the processes that run when it is started.

[0078] In this embodiment, the priority of the process in the container can be set during the container runtime. The newly started process after entering the container can also inherit the priority of the original process in the container. That is, based on the existing container ecology, flexible setting of the process in the container is achieved.

[0079] Figure 5 : is a flow chart of a method for setting the priority of a process in a container according to a container creation request in an embodiment of the present application, such as Figure 5 As shown, the method comprises the following steps:

[0080] Step S501, the container runtime receives a container creation request from the container orchestration system / container runtime client;

[0081] Step S502, the container runtime determines whether the request is to start a container;

[0082] Step S503, checking whether the request carries a priority parameter / priority instruction;

[0083] Step S504: setting the priority of the process in the container according to the check.

[0084] In this embodiment, step S503 may specifically be to check whether the request carries a priority parameter, or to check whether there is a priority instruction in the container image. This embodiment can realize static setting of the process in the newly started container.

[0085] Figure 6 is a flow chart of a method for setting the priority of a process in a container according to an update container request in an embodiment of the present application, such as Figure 6 As shown, the method comprises the following steps:

[0086] Step S601, the container runtime receives a container update request from the container orchestration system / container runtime client;

[0087] Step S602, the container runtime determines whether the request is to update the container;

[0088] Step S603, checking whether the request carries a priority parameter;

[0089] Step S604: Update the process priority in the container according to the check.

[0090] This embodiment can realize dynamic adjustment of the original process in the existing container.

[0091] Figure 7 : is a flow chart of a method for setting the priority of a process in a container according to a request to enter a container in an embodiment of the present application, such as Figure 7 As shown, the method comprises the following steps:

[0092] Step S701, the container runtime receives a container entry request from the container orchestration system / container runtime client;

[0093] Step S702, when the container is running, it is determined whether the request is to enter the container;

[0094] Step S703: After entering the container, the newly started process inherits the priority of the original process in the container.

[0095] Figure 8 FIG. 1 is a flow chart of a method for obtaining the priority of a process in a container according to a query container request in an embodiment of the present application. Figure 8 As shown, the method comprises the following steps:

[0096] Step S801, the container runtime receives a container entry request from the container orchestration system / container runtime client;

[0097] Step S802, when the container is running, it is determined whether the request is to query the priority of the process in the container;

[0098] Step S803: Obtain the process priority in the container and return the result to the container orchestration system / container runtime client.

[0099] Through the embodiments of the present application, the priority setting can be made compatible with the container ecosystem, and the priority parameters of the process inside the container can be set through the existing container orchestration system or container runtime client tools, and more flexible adjustment and acquisition of the priority of the process in the container can be achieved, thereby ensuring the response speed of key services.

[0100] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program executes the steps of any of the above method embodiments when executed by a processor.

[0101] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0102] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0103] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0104] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0105] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0106] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for setting process priority in a container, characterized in that: Applied to container runtime, the method includes: Receive container requests from the container orchestration system or the container runtime client; The priority of the process in the container is set according to the container request and the pre-established priority as a mapping relationship between system resources and containers.

2. The method according to claim 1, characterized in that Before receiving a container request sent by a container orchestration system or a container runtime client, the method further includes: Provide priority management interface and priority management data structure; Receiving a priority management request issued by the container orchestration system or the container runtime client according to the priority management interface and the priority management data structure; Establishing a mapping relationship between priorities and containers according to the priority management request; The priorities are managed by managing system resources.

3. The method according to claim 2, characterized in that After establishing a mapping relationship between a container and a priority according to the priority management request, the method further includes: The priority of the process in the container is sent to the container orchestration system or a client when the container is running according to the mapping relationship.

4. The method according to claim 1, characterized in that: The priority of the process in the container is set according to the container request and a pre-established mapping relationship between the container and the priority, including: Determining the request content of the container request, wherein the request content includes creating a container, updating a container, and entering a container; The priority of the process in the container is set according to the request content.

5. The method according to claim 4, characterized in that Setting the priority of the process in the container according to the request content includes: When the request content is to create a container, start a new container; Obtaining a priority parameter from the container request, or obtaining a priority instruction from a container image; The priority of the process in the new container is set according to the priority parameter or the priority instruction.

6. The method according to claim 4, characterized in that The priority of the process in the container is set according to the request content, including: When the request content is to update a container, obtaining a priority parameter from the container request; The priority of the process in the container is updated according to the priority parameter.

7. The method according to claim 4, characterized in that The priority of the process in the container is set according to the request content, including: When the request content is to enter a container, the container is entered, and a new process is started in the container, wherein the new process inherits the priority of the original process in the container.

8. The method according to claim 4, characterized in that The method further comprises: The request content also includes a query container; When the request content is to query a container, obtaining the priority of the process in the container; The priority of the process in the container is returned to the container orchestration system or the client of the container runtime.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program executes the method described in any one of claims 1 to 8 when executed by a processor.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Thread priority control method and device, computer equipment, readable storage medium and program product

    CN119597420A

  • Thread priority control methods, devices, computer equipment, readable storage media, and program products

    CN119597420B