CN118535274A - A method and device for setting process priority in a container - Google Patents
A method and device for setting process priority in a container Download PDFInfo
- Publication number
- CN118535274A CN118535274A CN202310158192.8A CN202310158192A CN118535274A CN 118535274 A CN118535274 A CN 118535274A CN 202310158192 A CN202310158192 A CN 202310158192A CN 118535274 A CN118535274 A CN 118535274A
- Authority
- CN
- China
- Prior art keywords
- container
- priority
- request
- setting
- present application
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45562—Creating, deleting, cloning virtual machine instances
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45575—Starting, stopping, suspending or resuming virtual machine instances
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5021—Priority
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请实施例提供了一种容器内进程优先级设置方法及装置,该方法包括:接收容器编排系统或容器运行时的客户端下发的容器请求,根据容器请求和预先建立的优先级作为系统资源与容器的映射关系对容器内进程的优先级进行设置。通过本申请实施例可以解决相关技术中对进程优先级的设置不能较好兼容容器生态的问题,通过将优先级纳入容器生态中的系统资源管理,实现了对容器内进程优先级的静态设置和动态调整,并且能够很好的兼容容器生态。
The embodiment of the present application provides a method and device for setting the priority of a process in a container, the method comprising: receiving a container request sent by a container orchestration system or a client during 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. The embodiment of the present application can solve the problem that the setting of process priority in the related technology is not well compatible with the container ecosystem. By incorporating the priority into the system resource management in the container ecosystem, the static setting and dynamic adjustment of the process priority in the container are realized, and it can be well compatible with the container ecosystem.
Description
技术领域Technical Field
本申请涉及云计算领域,具体而言,涉及一种容器内进程优先级设置方法及装置。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
容器是一种轻量级的虚拟化技术。使用容器可以来运行从小型微服务或软件进程到大型应用程序的所有内容。容器包含所有必要的可执行文件、二进制代码、库和配置文件。但是容器不包含操作系统映像,因此,它们更轻便且可移植性更好,资源开销也很小。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.
在现有技术中,容器生态可以管控与编排的资源主要有中央处理器(centralprocessing unit,简称CPU),内存、网络、磁盘输入/输出(Input/Output,简称I/O)等。但是,对于容器内进程在兼容容器生态的情况下实现优先级设置,目前在业界还处于空白。一般而言容器内进程的优先级继承自容器运行时,因此对于多个容器来说其容器内进程优先级是相同的,这会带来一些问题:不同容器承载的业务往往是不同的,现有容器生态没有根据业务的不同做划分;对于某些容器来说,可能需要更高的优先级以快速响应业务的需求,但是由于容器进程间优先级相同,其响应速度往往不能满足要求。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.
目前各种操作系统都提供了一些工具对系统上的进程进行优先级设置,比如Linux操作系统上的taskset命令行工具。但是方法也存在一些问题:增加系统的管理复杂性,直接使用命令行进行设置无法与容器生态关联起来;容器之间优先级的高低在脱离容器生态的情况下需要额外工具获取;没有办法在容器生态中对优先级做有效管理。总的来说,使用操作系统上自带的工具对容器内进程的优先级进行设置在技术上可行,但是从兼容容器生态的角度来说此种方法管理复杂、需要额外增加管理组件,并且缺乏灵活性。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 level of priority between containers requires additional tools to obtain when it is separated from 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.
综上,针对相关技术中对进程优先级的设置不能较好兼容容器生态的问题,还没有很好的解决方法。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
本申请实施例提供了一种容器内进程优先级设置方法及装置,以至少解决相关技术中对进程优先级的设置不能较好兼容容器生态的问题。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.
根据本申请的一个实施例,提供了一种容器内进程优先级设置方法,应用于容器运行时,该方法包括:接收容器编排系统或容器运行时的客户端下发的容器请求;根据容器请求和预先建立的优先级作为系统资源与容器的映射关系对容器内进程的优先级进行设置。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.
在本申请的一个实施例中,在接收容器编排系统或容器运行时的客户端下发的容器请求之前,该方法还包括:提供优先级管理接口和优先级管理数据结构;接收容器编排系统或容器运行时的客户端根据优先级管理接口和优先级管理数据结构下发的优先级管理请求;根据优先级管理请求建立优先级与容器的映射关系;通过管理系统资源的方式对优先级进行管理。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.
在本申请的一个实施例中,在根据优先级管理请求建立容器与优先级的映射关系之后,该方法还包括:根据映射关系将容器内进程的优先级发送给容器编排系统或容器运行时的客户端。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.
在本申请的一个实施例中,根据容器请求和预先建立的容器与优先级的映射关系对容器内进程的优先级进行设置,包括:确定容器请求的请求内容,其中,请求内容包括创建容器、更新容器及进入容器;根据请求内容对容器内进程的优先级进行设置。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.
在本申请的一个实施例中,根据请求内容对容器内进程的优先级进行设置,包括:在请求内容为创建容器的情况下,启动新容器;从容器请求中获取优先级参数,或者,从容器镜像中获取优先级指令;根据优先级参数或优先级指令设置新容器内进程的优先级。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.
在本申请的一个实施例中,根据请求内容对容器内进程的优先级进行设置,包括:在请求内容为更新容器的情况下,从容器请求中获取优先级参数;根据优先级参数更新容器内进程的优先级。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.
在本申请的一个实施例中,根据请求内容对容器内进程的优先级进行设置,包括:在请求内容为进入容器的情况下,进入容器,并在容器内启动新进程,其中,新进程继承容器内原有进程的优先级。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.
在本申请的一个实施例中,该方法还包括:请求内容还包括查询容器;在请求内容为查询容器的情况下,获取容器内进程的优先级;将容器内进程的优先级返回给容器编排系统或容器运行时的客户端。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.
根据本申请的又一个实施例,还提供了一种计算机可读的存储介质,该存储介质中存储有计算机程序,其中,该计算机程序被处理器运行时执行上述任一项方法实施例中的步骤。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.
根据本申请的又一个实施例,还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行该计算机程序以执行上述任一项方法实施例中的步骤。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.
通过本申请实施例,将优先级作为资源纳入容器运行时的管理,可以解决相关技术中对进程优先级的设置不能较好兼容容器生态的问题,以兼容容器生态的方式灵活有效的设置容器内进程的优先级,以此完善容器生态的资源管理,并且可以保障关键业务的响应速度。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
图1是本申请实施例的容器内进程优先级设置方法的硬件结构框图;FIG1 is a hardware structure block diagram of a method for setting process priority in a container according to an embodiment of the present application;
图2是根据本申请实施例的容器内进程优先级设置方法的流程图;FIG2 is a flow chart of a method for setting process priority in a container according to an embodiment of the present application;
图3是根据本申请实施例的将优先级纳入容器运行时资源管理的结构示意图;FIG3 is a schematic diagram of a structure for incorporating priority into container runtime resource management according to an embodiment of the present application;
图4是根据本申请实施例设置容器内进程优先级的系统结构示意图;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 application;
图5是本申请一实施例中根据创建容器请求设置容器内进程优先级的方法流程图;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 one embodiment of the present application;
图6是本申请一实施例中根据更新容器请求设置容器内进程优先级的方法流程图;FIG6 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;
图7是本申请一实施例中根据进入容器请求设置容器内进程优先级的方法流程图;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 one embodiment of the present application;
图8是本申请一实施例中根据查询容器请求获取容器内进程优先级的方法流程图。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 application.
具体实施方式DETAILED DESCRIPTION
下文中将参考附图并结合实施例来详细说明本申请的实施例。The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。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.
本申请实施例中所提供的方法实施例可以在移动终端、计算机终端或者类似的运算装置中执行。以运行在计算机终端上为例,图1是本申请实施例的容器内进程优先级设置方法的硬件结构框图,如图1所示,硬件单板可以包括一个或多个(图1中仅示出一个)处理器12(处理器12可以包括但不限于微处理器MCU或可编程逻辑器件等的处理装置)和用于存储数据的存储器14,其中,上述移动终端还可以包括用于通信功能的传输设备16以及输入输出设备18。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述移动终端的结构造成限定。例如,移动终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。The method embodiment provided in the embodiment 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, FIG. 1 is a hardware structure block diagram of the process priority setting method in the container of the embodiment of the present application. As shown in FIG. 1, the hardware board may include one or more (only one is shown in FIG. 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 of ordinary skill in the art that the structure shown in FIG. 1 is only for illustration, and it 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 FIG. 1, or have a configuration different from that shown in FIG. 1.
存储器14可用于存储计算机程序,例如,应用软件的软件程序以及模块,如本申请实施例中的容器内进程优先级设置方法对应的计算机程序,处理器12通过运行存储在存储器14内的计算机程序,从而执行各种功能应用以及容器内进程优先级设置方法,即实现上述的方法。存储器14可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器14可进一步包括相对于处理器12远程设置的存储器,这些远程存储器可以通过网络连接至移动终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。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.
传输设备16用于经由一个网络接收或者发送数据。上述的网络具体实例可包括通信供应商提供的无线网络。在一个实例中,传输设备16包括一个网络适配器(NetworkInterface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输设备16可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。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 (RF) module, which is used to communicate with the Internet wirelessly.
本申请实施例还可以应用在ARM/X86/PowerPC/MIPS等架构硬件服务器上,运行实时性及非实时性的服务器操作系统,或者,运行实时性及非实时性的虚拟机操作系统中。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.
在本实施例中提供了一种容器内进程优先级设置方法,应用于容器运行(Container Runtime)时,图2是根据本申请实施例的容器内进程优先级设置方法的流程图,如图2所示,该流程包括如下步骤:In this embodiment, a method for setting the priority of a process in a container is provided. When applied to container runtime, FIG2 is a flow chart of the method for setting the priority of a process in a container according to an embodiment of the present application. As shown in FIG2, the process includes the following steps:
步骤S202,接收容器编排系统或容器运行时的客户端下发的容器请求;Step S202, receiving a container request sent by a container orchestration system or a container runtime client;
步骤S204,根据容器请求和预先建立的优先级作为系统资源与容器的映射关系对容器内进程的优先级进行设置。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.
通过上述步骤S202至步骤S204,将优先级纳入容器生态中的系统资源管理,在容器编排系统或者容器运行时客户端的管理下,根据业务重要性灵活有效地将优先级设置到容器内进程,解决相关技术中对进程优先级的设置不能较好兼容容器生态的问题。既可以静态的设置容器内进程优先级也可以根据业务运行情况动态设置容器内进程优先级,并且能够很好的兼容容器生态。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.
本实施例中的容器编排系统是指用于自动部署、扩缩和管理容器化应用程序的所有系统,容器运行时的客户端是指使用客户端工具对容器进行管理的应用。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.
在一可选的实施例中,在步骤S202之前,该方法还可以包括以下步骤:提供优先级管理接口和优先级管理数据结构,接收容器编排系统或容器运行时的客户端根据优先级管理接口和优先级管理数据结构下发的优先级管理请求;根据优先级管理请求建立优先级与容器的映射关系,通过管理系统资源的方式对优先级进行管理。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.
本实施例中的容器编排系统或容器运行时的客户端与容器进行时之间通过优先级管理接口和优先级管理数据结构进行与优先级管理有关的信息交互。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.
进一步的,在通过管理系统资源的方式对优先级进行管理之后,还可以根据映射关系将容器内进程的优先级发送给容器编排系统或容器运行时的客户端。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.
在本实施例中,步骤S204具体可以包括以下步骤:In this embodiment, step S204 may specifically include the following steps:
步骤S2042,确定容器请求的请求内容,该请求内容包括创建容器、更新容器及进入容器;Step S2042, determining the request content of the container request, the request content includes creating a container, updating a container and entering a container;
步骤S2044,根据请求内容对容器内进程的优先级进行设置。Step S2044: setting the priority of the process in the container according to the request content.
在一实施例中,步骤S2044具体可以包括:在请求内容为创建容器的情况下,启动新容器;从容器请求中获取优先级参数,或者,从容器镜像中获取优先级指令;根据优先级参数或优先级指令设置新容器内进程的优先级。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.
本实施例中的创建容器请求可以携带或不携带优先级参数,在创建容器请求不携带优先级参数时,需要从容器镜像中获取优先级指令。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.
本实施例中的容器镜像包含打包的应用程序及其依赖关系,以及有关启动时所运行的进程的信息,其中包括优先级指令。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.
在另一实施例中,步骤S2044具体可以包括:在请求内容为更新容器的情况下,从容器请求中获取优先级参数;根据优先级参数更新容器内进程的优先级。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.
在本实施例中,在请求内容为更新容器的情况下,还需要判断容器请求中是否携带有优先级参数,在判断结果为是的情况下,使用该优先级参数更新容器内进程的优先级。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.
在另一实施例中,步骤S2044具体可以包括:在请求内容为进入容器的情况下,进入容器,并在容器内启动新进程。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.
具体的,容器内新进程可以继承容器内原有进程的优先级。在容器内各个进程优先级一致的情况下,无需针对每一进程单独设置优先级。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.
在本实施例中,进入容器请求中也可以携带有优先级参数设置容器内进程的优先级。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.
在又一实施例中,步骤S2044具体还可以包括:在请求内容为查询容器的情况下,获取容器内进程的优先级,其中,请求内容还包括查询容器;将容器内进程的优先级返回给容器编排系统或容器运行时的客户端。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.
通过上述步骤S2042和步骤S2044,可以判断容器请求的具体内容并根据判断结果对容器内进程的优先级进行对应的操作。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.
本申请实施例将优先级视为一种系统资源,在容器编排系统或者容器运行时客户端的管理下根据业务重要性灵活有效将优先级设置到容器内进程,具体包括: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:
容器编排系统或者容器运行时客户端工具在启动容器时携带优先级参数设置容器内进程的优先级;若未携带优先级参数,则容器内进程继承父进程的优先级;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;
容器编排系统或者容器运行时客户端工具下发进入容器请求,进入容器后若需启动新进程,那么新进程继承容器内原有进程的优先级;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.
容器编排系统或者容器运行时客户端工具在容器启动后根据需要,动态更新容器内所有进程的优先级;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;
通过容器镜像内置的优先级指令设置容器内进程的优先级;Set the priority of the process in the container through the priority instructions built into the container image;
容器编排系统和容器运行时客户端工具可以实时查询容器内进程的优先级。Container orchestration systems and container runtime client tools can query the priorities of processes within containers in real time.
本申请实施例给予容器运行时更多的功能性,以适应不同的业务场景,并且所有的优先级设置方法均兼容容器生态,能提高容器内关键业务的响应速度。本申请实施例既可以静态的设置优先级也可以根据业务运行情况动态设置优先级。容器运行时或者容器编排系统可以实时查询容器内进程的优先级,也可以根据情况重新调整容器内进程的优先级。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.
图3是根据本申请实施例的将优先级纳入容器运行时资源管理的装置结构示意图,如图3所示,资源管理的装置结构主要包括:FIG3 is a schematic diagram of a device structure for incorporating priority into container runtime resource management according to an embodiment of the present application. As shown in FIG3 , the device structure for resource management mainly includes:
管理接口32、数据结构34及资源管理模块36。Management interface 32 , data structure 34 and resource management module 36 .
在本实施例中,管理接口32和数据结构34为容器编排系统/容器运行时的客户端与容器运行时之间的管理接口以及数据结构,具体可以是上述实施例中的优先级管理接口和优先级管理数据结构。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.
在本实施例中,资源管理模块36位于容器运行时内部,主要用于对容器对应的系统资源进行管理,通过资源管理模块36可以将优先级作为资源纳入管理;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 managed as a resource through the resource management module 36;
具体的,除优先级以外,资源管理模块36还可以管理以下系统资源:中央处理器(central processing unit,简称CPU)、内存、磁盘输入/输出(Input/Output,简称I/O)、网络I/O等。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.
在本实施例中,还可以通过以下步骤来将优先级纳入管理:In this embodiment, the priority can also be managed by the following steps:
步骤S302,容器编排系统/容器运行时客户端以及容器运行时提供管理优先级的接口以及相关数据结构;Step S302: The container orchestration system/container runtime client and the container runtime provide an interface and related data structure for managing priority;
步骤S304,容器编排系统、容器运行时客户端工具根据步骤S302中的接口以及数据结构下发请求给容器运行时;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;
步骤S306,容器运行时根据步骤S304中的请求建立优先级与容器的映射关系,并将优先级纳入到容器运行时的资源管理模块中;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;
步骤S308,容器编排系统或者容器运行时客户端工具根据步骤S306中建立的映射关系查询容器内进程的优先级。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.
进一步的,步骤S304中的请求可以是优先级管理请求。Further, the request in step S304 may be a priority management request.
图4是根据本申请实施例设置容器内进程优先级的系统结构示意图,如图4所示,该系统结构主要包括: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 application. As shown in FIG4 , the system structure mainly includes:
容器编排系统41,容器运行时客户端42,容器运行时43,容器44以及容器镜像45。Container orchestration system 41, container runtime client 42, container runtime 43, container 44 and container image 45.
容器编排系统41,用于自动部署、扩缩和管理容器化应用程序,包括但不限制于Kubernetes系统。The container orchestration system 41 is used to automatically deploy, scale, and manage containerized applications, including but not limited to the Kubernetes system.
容器运行时客户端42,用于使用客户端工具对容器进行管理,包括但不限制于Docker Swarm工具。The container runtime client 42 is used to manage containers using client tools, including but not limited to the Docker Swarm tool.
容器运行时43,用于管理容器整个生命周期,其提供的功能包括但不限于:容器镜像格式管理、容器镜像构建、容器镜像管理、容器实例管理、运行容器。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.
容器44是由容器运行时43创建的实例,其包含在环境中运行所需的所有要素。A container 44 is an instance created by the container runtime 43 that contains all the elements required to run in an environment.
容器镜像45包含打包的应用程序及其依赖关系,以及有关启动时所运行的进程的信息。A container image 45 contains a packaged application and its dependencies, as well as information about the processes that run when it is started.
本实施例通过容器运行时可以对容器内进程进行优先级设置,进入容器后新启动的进程也可以继承容器内原有进程的优先级,即在现有容器生态的基础上,实现了对容器内进程的灵活设置。In this embodiment, the priority of the process in the container can be set when the container is running. 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.
图5是本申请一实施例中根据创建容器请求设置容器内进程优先级的方法流程图,如图5所示,该方法包括以下步骤: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 an embodiment of the present application. As shown in FIG5 , the method includes the following steps:
步骤S501,容器运行时接收来自容器编排系统/容器运行时客户端的创建容器请求;Step S501, the container runtime receives a container creation request from the container orchestration system/container runtime client;
步骤S502,容器运行时判断请求是否为启动容器;Step S502, when the container is running, it is determined whether the request is to start a container;
步骤S503,检查请求中是否携带优先级参数/优先级指令;Step S503, checking whether the request carries a priority parameter/priority instruction;
步骤S504,根据检查设置容器内进程优先级。Step S504, setting the priority of the process in the container according to the inspection.
在本实施例中,步骤S503具体可以是检查请求中是否携带优先级参数,或者检查容器镜像中是否存在优先级指令。通过本实施例可以实现对新启动容器内进程的静态设置。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.
图6是本申请一实施例中根据更新容器请求设置容器内进程优先级的方法流程图,如图6所示,该方法包括以下步骤:FIG6 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. As shown in FIG6 , the method includes the following steps:
步骤S601,容器运行时接收来自容器编排系统/容器运行时客户端的更新容器请求;Step S601, the container runtime receives a container update request from the container orchestration system/container runtime client;
步骤S602,容器运行时判断请求是否为更新容器;Step S602, the container runtime determines whether the request is to update the container;
步骤S603,检查请求中是否携带优先级参数;Step S603, checking whether the request carries a priority parameter;
步骤S604,根据检查更新容器内进程优先级。Step S604: Update the process priority in the container according to the check.
通过本实施例可以实现对已有容器内原进程的动态调整。This embodiment can realize dynamic adjustment of the original process in the existing container.
图7是本申请一实施例中根据进入容器请求设置容器内进程优先级的方法流程图,如图7所示,该方法包括以下步骤:FIG. 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. As shown in FIG. 7 , the method includes the following steps:
步骤S701,容器运行时接收来自容器编排系统/容器运行时客户端的进入容器请求;Step S701, the container runtime receives a container entry request from the container orchestration system/container runtime client;
步骤S702,容器运行时判断请求是否为进入容器;Step S702, when the container is running, it is determined whether the request is to enter the container;
步骤S703,进入容器后新启动的进程继承容器内原有进程优先级。Step S703: After entering the container, the newly started process inherits the priority of the original process in the container.
图8是本申请一实施例中根据查询容器请求获取容器内进程优先级的方法流程图,如图8所示,该方法包括以下步骤: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 application. As shown in FIG8 , the method includes the following steps:
步骤S801,容器运行时接收来自容器编排系统/容器运行时客户端的进入容器请求;Step S801, the container runtime receives a container entry request from the container orchestration system/container runtime client;
步骤S802,容器运行时判断请求是否为查询容器内进程优先级;Step S802, when the container is running, it is determined whether the request is to query the priority of the process in the container;
步骤S803,获取容器内进程优先级并返回结果给容器编排系统/容器运行时客户端。Step S803: Obtain the process priority in the container and return the result to the container orchestration system/container runtime client.
通过本申请实施例,可以使优先级设置兼容容器生态,通过现有的容器编排系统或容器运行时客户端工具对容器内部进程的优先级参数进行设置,并且实现了对容器内进程优先级更加灵活的调整和获取,进而保障了关键业务的响应速度。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.
本申请的实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,其中,该计算机程序被处理器运行时执行上述任一项方法实施例中的步骤。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.
在一个示例性实施例中,上述计算机可读存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。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.
本申请的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。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.
在一个示例性实施例中,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。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.
本实施例中的具体示例可以参考上述实施例及示例性实施方式中所描述的示例,本实施例在此不再赘述。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.
显然,本领域的技术人员应该明白,上述的本申请的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本申请不限制于任何特定的硬件和软件结合。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.
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。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 (10)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310158192.8A CN118535274A (en) | 2023-02-23 | 2023-02-23 | A method and device for setting process priority in a container |
| PCT/CN2023/143716 WO2024174737A1 (en) | 2023-02-23 | 2023-12-30 | Method and apparatus for setting process priority level in container |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310158192.8A CN118535274A (en) | 2023-02-23 | 2023-02-23 | A method and device for setting process priority in a container |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118535274A true CN118535274A (en) | 2024-08-23 |
Family
ID=92383140
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310158192.8A Pending CN118535274A (en) | 2023-02-23 | 2023-02-23 | A method and device for setting process priority in a container |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118535274A (en) |
| WO (1) | WO2024174737A1 (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119597420A (en) * | 2024-11-13 | 2025-03-11 | 广州翼辉信息技术有限公司 | Thread priority control method, device, computer equipment, readable storage medium and program product |
Family Cites Families (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7500091B2 (en) * | 2005-11-30 | 2009-03-03 | Microsoft Corporation | Delay start-up of applications |
| US8706798B1 (en) * | 2013-06-28 | 2014-04-22 | Pepperdata, Inc. | Systems, methods, and devices for dynamic resource monitoring and allocation in a cluster system |
| CN105183565B (en) * | 2015-09-30 | 2018-12-07 | 华为技术有限公司 | Computer, method for controlling quality of service and device |
| US10831540B2 (en) * | 2018-02-27 | 2020-11-10 | Portworx, Inc. | Hyper-convergence with scheduler extensions for software-defined container storage solutions |
| JP7363167B2 (en) * | 2019-07-31 | 2023-10-18 | 日本電気株式会社 | Container daemon, information processing device, container virtualization system, packet distribution method and program |
| US20210184977A1 (en) * | 2019-12-16 | 2021-06-17 | Citrix Systems, Inc. | Cpu and priority based early drop packet processing systems and methods |
| KR102491362B1 (en) * | 2021-02-01 | 2023-01-26 | 주식회사 드림에이스 | Method and device for controlling device based on vehicle virtual structure |
| CN114491507A (en) * | 2022-01-13 | 2022-05-13 | 南京翼辉信息技术有限公司 | Design method for realizing lightweight safety container based on embedded real-time operating system |
| CN115688094B (en) * | 2022-09-13 | 2023-09-15 | 国科础石(重庆)软件有限公司 | Method and device for realizing security level of container vehicle-mounted application and electronic equipment |
-
2023
- 2023-02-23 CN CN202310158192.8A patent/CN118535274A/en active Pending
- 2023-12-30 WO PCT/CN2023/143716 patent/WO2024174737A1/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119597420A (en) * | 2024-11-13 | 2025-03-11 | 广州翼辉信息技术有限公司 | Thread priority control method, device, computer equipment, readable storage medium and program product |
Also Published As
| Publication number | Publication date |
|---|---|
| WO2024174737A1 (en) | 2024-08-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108369534B (en) | Code execution request routing | |
| US9529613B2 (en) | Methods and apparatus to reclaim resources in virtual computing environments | |
| CN110489126B (en) | Compiling task execution method and device, storage medium and electronic device | |
| CN108572845B (en) | Upgrade method and related system of distributed microservice cluster | |
| CN110908753B (en) | Intelligent fusion cloud desktop server, client and system | |
| CN111984269B (en) | Method for providing application construction service and application construction platform | |
| WO2022037612A1 (en) | Method for providing application construction service, and application construction platform, application deployment method and system | |
| CN107111507A (en) | Threading as a service | |
| US20240111549A1 (en) | Method and apparatus for constructing android running environment | |
| CN110659104B (en) | Service monitoring method and related equipment | |
| WO2018113571A1 (en) | Virtualized network element management method and device, and computer storage medium | |
| CN114546588A (en) | Task deployment method, device, storage medium, and electronic device | |
| CN115695470A (en) | A device-cloud collaboration system, method, and device for an Internet of Things platform and an edge gateway | |
| CN117112122A (en) | Cluster deployment method and device | |
| WO2025124172A1 (en) | Method and apparatus for component deployment and updating, computer device, and storage medium | |
| WO2024174737A1 (en) | Method and apparatus for setting process priority level in container | |
| CN113741952A (en) | Software package management method, device, equipment and medium | |
| CN105933136B (en) | A kind of resource regulating method and system | |
| JP2021184235A5 (en) | ||
| CN107220101B (en) | Container creation method and device | |
| CN111526168A (en) | Scheduling management method and device for network function virtualization NFV architecture | |
| CN119668885B (en) | Method, device, equipment and storage medium for operating development file | |
| US20250298597A1 (en) | Application Deployment Based on Image Fingerprint | |
| CN115951908A (en) | Image preloading method and related device | |
| CN120578452A (en) | Compatibility checking method, apparatus, computer-readable storage medium, and program product |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |