Method and apparatus for setting process priority level in container
By issuing requests in the container orchestration system or the container runtime client, the process priority in the container is set according to the pre-established priority mapping relationship, which solves the problem of process priority setting in the container and the compatibility of the container ecosystem, and improves business response. Speed and management flexibility.
Patent Information
- Application Number
- PCT/CN2023/143716
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-23
- Filing Date
- 2023-12-30
- Publication Date
- 2024-08-29
AI Technical Summary
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, high management complexity, and lack of flexibility.
Requests are sent through the container orchestration system or the container runtime client, and the priority of the process in the container is set according to the pre-established priority mapping relationship. It is incorporated into system resource management, supports static and dynamic settings, and is compatible with the container ecosystem.
It realizes flexible management of process priorities within the container, improves the response speed of key services within the container, simplifies management complexity, and meets different business needs.
Smart Images

Figure CN2023143716_29082024_PF_FP_ABST
Abstract
Description
Method and device for setting process priority in a container
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This disclosure is based on Chinese patent application CN202310158192.8, filed on February 23, 2023, entitled “A method and device for setting process priority in a container”, and claims the priority of the patent application, and all the contents disclosed therein are incorporated into this disclosure by reference. Technical Field
[0003] The present disclosure relates to the field of cloud computing, and in particular to a method and device for setting process priority within a container. Background Art
[0004] Containers are a lightweight virtualization technology. They can be used to run everything from small microservices or software processes to large applications. Containers contain all necessary executable files, binary code, libraries, and configuration files. However, containers do not include an operating system image, making them more portable and requiring minimal resource overhead.
[0005] In the existing technology, 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 priorities for processes within containers 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.
[0006] Currently, various operating systems provide tools for setting process priorities on the system, such as the taskset command-line tool on Linux. However, this approach also presents several issues: it increases system management complexity, and direct command-line settings cannot be integrated with the container ecosystem; determining the priorities of containers outside of the container ecosystem requires additional tools; and there is no way to effectively manage priorities within the container ecosystem. In general, using native operating system tools to set the priorities of processes within a container is technically feasible, but from the perspective of compatibility with the container ecosystem, this approach is complex to manage, requires additional management components, and lacks flexibility.
[0007] In summary, there is no good solution to the problem that the setting of process priorities in related technologies is not well compatible with the container ecosystem.
[0008] Summary of the Invention
[0009] The embodiments of the present disclosure provide a method and apparatus for setting process priorities within a container, so as to at least solve the problem in related technologies that the setting of process priorities is not well compatible with the container ecosystem.
[0010] According to one embodiment of the present disclosure, a method for setting the priority of a process in a container is provided, which is applied to a container runtime. The method includes: receiving a container request issued by a container orchestration system or a client of the container runtime; and 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.
[0011] According to another embodiment of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.
[0012] According to another embodiment of the present disclosure, 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] FIG1 is a block diagram of the hardware structure of a method for setting process priority within a container according to an embodiment of the present disclosure;
[0014] FIG2 is a flowchart of a method for setting process priority within a container according to an embodiment of the present disclosure;
[0015] FIG3 is a schematic diagram of a structure for incorporating priorities into container runtime resource management according to an embodiment of the present disclosure;
[0016] FIG4 is a schematic diagram of a system structure for setting process priorities within a container according to an embodiment of the present disclosure;
[0017] FIG5 is a flow chart of a method for setting the priority of a process in a container according to a container creation request in one embodiment of the present disclosure;
[0018] FIG6 is a flow chart of a method for setting the priority of a process in a container according to a container update request in one embodiment of the present disclosure;
[0019] FIG7 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 one embodiment of the present disclosure;
[0020] FIG8 is a flowchart of a method for obtaining the priority of a process in a container according to a query container request in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0023] The method embodiments provided in the embodiments of the present disclosure 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 disclosure. As shown in Figure 1, the hardware board may include one or more (only one is shown in Figure 1) processors 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 above-mentioned mobile terminal may also include a transmission device 16 and an input and output device 18 for communication functions. It can be understood by those skilled in the art that the structure shown in Figure 1 is only for illustration and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may also include more or fewer components than those shown in Figure 1, or have a configuration different from that shown in Figure 1.
[0024] 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 disclosure. 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-mentioned 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 located 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.
[0025] The transmission device 16 is used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by a communications provider. In one embodiment, the transmission device 16 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 16 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0026] The disclosed embodiments can also be applied to hardware servers with 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.
[0027] In this embodiment, a method for setting process priority within a container is provided. When applied to container runtime, FIG2 is a flow chart of the method for setting process priority within a container according to an embodiment of the present disclosure. As shown in FIG2 , the flow chart includes the following steps:
[0028] Step S202: receiving a container request sent by a container orchestration system or a container runtime client;
[0029] 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.
[0030] Through steps S202 to S204 above, priorities are incorporated into system resource management within the container ecosystem. Under the management of the container orchestration system or container runtime client, priorities can be flexibly and effectively set for processes within the container based on business importance, resolving the issue in related technologies where process priority settings are not well compatible with the container ecosystem. Priorities for processes within the container can be set both statically and dynamically based on business operations, ensuring good compatibility with the container ecosystem.
[0031] 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.
[0032] In an exemplary 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.
[0033] In this embodiment, the container orchestration system or the container runtime client and the container runtime exchange information related to priority management through the priority management interface and the priority management data structure.
[0034] 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.
[0035] In this embodiment, step S204 may specifically include the following steps:
[0036] Step S2042: Determine the content of the container request, which includes creating a container, updating a container, and entering a container.
[0037] Step S2044: Set the priority of the process in the container according to the request content.
[0038] 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.
[0039] The container creation request in this embodiment may or may not carry a priority parameter. When the container creation request does not carry a priority parameter, a priority instruction needs to be obtained from the container image.
[0040] 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.
[0041] 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.
[0042] 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 judgment result is yes, the priority parameter is used to update the priority of the process in the container.
[0043] 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.
[0044] Specifically, new processes within a container can inherit the priority of existing processes within the container. If the priorities of all processes within the container are consistent, there is no need to set the priority for each process individually.
[0045] In this embodiment, the container entry request may also carry a priority parameter to set the priority of the process in the container.
[0046] 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; and returning the priority of the process in the container to the container orchestration system or the client of the container runtime.
[0047] 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.
[0048] The embodiments of the present disclosure treat priority as a system resource and flexibly and effectively set priorities for processes within a container based on business importance under the management of a container orchestration system or a container runtime client. Specifically, the priorities include:
[0049] The container orchestration system or container runtime client tool carries a priority parameter when starting a container to set the priority of the process within the container; if no priority parameter is carried, the process within the container inherits the priority of the parent process;
[0050] The container orchestration system or container runtime client tool sends a request to enter the container. After entering the container, if a new process needs to be started, the new process inherits the priority of the original process in the container.
[0051] 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;
[0052] Set the priority of the process in the container through the priority instructions built into the container image;
[0053] Container orchestration systems and container runtime client tools can query the priorities of processes within containers in real time.
[0054] The disclosed embodiments 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 businesses in the container. The disclosed embodiments can set priorities statically or dynamically based on business operation conditions. 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.
[0055] Through the embodiments of the present disclosure, by incorporating priority as a resource into the management of the container runtime, the problem in related technologies that the setting of process priority is not well compatible with the container ecosystem can be solved. The priority of the process in the container can be flexibly and effectively set in a manner that is compatible with the container ecosystem, thereby improving the resource management of the container ecosystem and ensuring the response speed of key businesses.
[0056] FIG3 is a schematic diagram of an apparatus structure for incorporating priority into container runtime resource management according to an embodiment of the present disclosure. As shown in FIG3 , the apparatus structure for resource management mainly includes:
[0057] Management interface 32 , data structure 34 and resource management module 36 .
[0058] 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 can specifically be the priority management interface and priority management data structure in the above embodiment.
[0059] 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;
[0060] Specifically, in addition to 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.
[0061] In this embodiment, priority can also be included in management through the following steps:
[0062] Step S302: The container orchestration system / container runtime client and the container runtime provide an interface and related data structures for managing priority.
[0063] 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;
[0064] 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;
[0065] In 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.
[0066] Furthermore, the request in step S304 may be a priority management request.
[0067] FIG4 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 disclosure. As shown in FIG4 , the system structure mainly includes:
[0068] Container orchestration system 41 , container runtime client 42 , container runtime 43 , container 44 , and container image 45 .
[0069] A container orchestration system 41 is used to automatically deploy, scale, and manage containerized applications, including but not limited to the Kubernetes system.
[0070] The container runtime client 42 is used to manage containers using client tools, including but not limited to Docker Swarm tools.
[0071] 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.
[0072] A container 44 is an instance created by the container runtime 43 that contains all the elements required to run in an environment.
[0073] A container image 45 contains a packaged application and its dependencies, as well as information about the processes that run when it is started.
[0074] This embodiment can set the priority of the process in the container 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.
[0075] FIG5 is a flow chart of a method for setting the priority of a process in a container according to a container creation request in one embodiment of the present disclosure. As shown in FIG5 , the method includes the following steps:
[0076] Step S501: The container runtime receives a container creation request from the container orchestration system / container runtime client;
[0077] Step S502: The container runtime determines whether the request is to start a container;
[0078] Step S503, checking whether the request carries a priority parameter / priority instruction;
[0079] Step S504: Set the priority of the process in the container according to the check.
[0080] In this embodiment, step S503 may specifically be to check whether the request carries a priority parameter, or to check whether a priority instruction exists in the container image. This embodiment can implement static settings for processes in newly started containers.
[0081] FIG6 is a flow chart of a method for setting the priority of a process in a container according to a container update request in an embodiment of the present disclosure. As shown in FIG6 , the method includes the following steps:
[0082] Step S601: The container runtime receives a container update request from the container orchestration system / container runtime client;
[0083] Step S602: The container runtime determines whether the request is to update the container;
[0084] Step S603, checking whether the request carries a priority parameter;
[0085] Step S604: Update the priority of the process in the container based on the check.
[0086] This embodiment can realize dynamic adjustment of the original process in the existing container.
[0087] FIG7 is a flow chart of a method for setting the priority of a process in a container according to a container entry request in an embodiment of the present disclosure. As shown in FIG7 , the method includes the following steps:
[0088] Step S701: The container runtime receives a container entry request from the container orchestration system / container runtime client;
[0089] Step S702: The container runtime determines whether the request is to enter the container;
[0090] Step S703: After entering the container, the newly started process inherits the priority of the original process in the container.
[0091] FIG8 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 disclosure. As shown in FIG8 , the method includes the following steps:
[0092] Step S801: The container runtime receives a container entry request from the container orchestration system / container runtime client;
[0093] Step S802: The container runtime determines whether the request is to query the priority of the process in the container;
[0094] Step S803: Obtain the priority of the process in the container and return the result to the container orchestration system / container runtime client.
[0095] Through the embodiments of the present disclosure, priority settings 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 inside the container can be achieved, thereby ensuring the response speed of key businesses.
[0096] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.
[0097] 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.
[0098] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0099] 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.
[0100] 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 here.
[0101] Obviously, those skilled in the art should understand that the modules or steps of the present disclosure described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, 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 performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any particular combination of hardware and software.
[0102] The foregoing is merely an exemplary embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that the present disclosure is susceptible to various modifications and variations. Any modifications, equivalent substitutions, improvements, and the like made within the principles of the present disclosure shall be included within the scope of protection of the present disclosure.
Claims
1. A method for setting process priority in a container, applied when the container is running, the method comprising: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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
Patent Citations
Delay start-up of applications
CN101317171A
Computer and service quality control method and device
CN105183565A
Design method for realizing lightweight security container based on embedded real-time operating system
CN114491507A
Container vehicle-mounted application security level implementation method and device and electronic equipment
CN115688094A
Container daemon, information processing device, container-type virtualization system, packet distribution method, and program
JP2021027398A
