CN111694658A - CPU resource allocation method, device, electronic equipment and storage medium - Google Patents

CPU resource allocation method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111694658A
CN111694658A CN202010366772.2A CN202010366772A CN111694658A CN 111694658 A CN111694658 A CN 111694658A CN 202010366772 A CN202010366772 A CN 202010366772A CN 111694658 A CN111694658 A CN 111694658A
Authority
CN
China
Prior art keywords
cpu
container
idle
cores
creating
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
Application number
CN202010366772.2A
Other languages
Chinese (zh)
Inventor
刘畅
蒋久栋
李自善
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Urban Network Neighbor Information Technology Co Ltd
Original Assignee
Beijing Urban Network Neighbor Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Urban Network Neighbor Information Technology Co Ltd filed Critical Beijing Urban Network Neighbor Information Technology Co Ltd
Priority to CN202010366772.2A priority Critical patent/CN111694658A/en
Publication of CN111694658A publication Critical patent/CN111694658A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

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 invention provides a CPU resource allocation method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving a container creating instruction sent by a main node, wherein the container creating instruction comprises the number of CPU cores needing to be bound; according to the container creating instruction, creating a container and creating a resource control group corresponding to the container, wherein the resource control group comprises a CPU (Central processing Unit) affinity directory; and creating a control group file corresponding to the container under the CPU affinity directory, determining the number of idle CPU cores of the CPU cores, and binding the container and the idle CPU cores, so that the container runs on the bound idle CPU cores. The invention realizes that the container is bound to the independent CPU core, and the service in the container is not influenced by other services, thereby improving the stability of the service.

Description

CPU resource allocation method, device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of cloud platforms, in particular to a CPU resource allocation method and device, electronic equipment and a storage medium.
Background
At present, the cloud platform manages multiple clusters through a container arrangement tool, the container arrangement tool integrates computer cluster resources (including CPUs, memories, network bandwidths and the like) and supplies the computer cluster resources to tenants according to needs, and dynamic resource requirements of the tenants can be met in the aspect of resource management, so that the cost of the tenants on infrastructure and system maintenance is reduced. However, when managing the dynamic demands of the tenant CPU resources, the container orchestration tool adjusts the resource quotas according to the current CPU resource usage of the nodes. This method is based on the adjustment in the event that a resource alarm has occurred, and there is a problem that the application program temporarily exits because the resource exceeds the limit.
Current container orchestration tools are based on upper and lower bounds on demand for a given resource. Fig. 1 is a schematic diagram of CPU resource allocation in the prior art, and as shown in fig. 1, 2 CPU cores are set for a certain container, and the upper limit of the number of CPU cores is set to 4, and the overall functions of these parameters are that a container arrangement tool issues to the container, the container issues to linux cgroup, and finally, an operating system kernel controls resource limitation of these processes. That is, on an actual host, linux does not place all processes of the container on separate CPU cores, but makes them occupy 2 CPU cores on an overall scale by random allocation (if each CPU is evenly allocated in fig. 1, then each CPU allocates 1/16 cores).
The number of the CPU cores allocated by the container arrangement tool cannot ensure that the container runs completely on the designated CPU core, nor can avoid that the processes in other containers do not run on the CPU core occupied by the container arrangement tool, so that the CPU core designated by the container arrangement tool is not completely and completely independent at present, and the problem that the application program temporarily exits due to the fact that the CPU resource exceeds the quota still exists, and the stability of the service is poor.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are proposed to provide a CPU resource allocation method, apparatus, electronic device and storage medium that overcome or at least partially solve the above problems.
According to a first aspect of the present invention, there is provided a CPU resource allocation method, including:
receiving a container creating instruction sent by a main node, wherein the container creating instruction comprises the number of CPU cores needing to be bound;
according to the container creating instruction, creating a container and creating a resource control group corresponding to the container, wherein the resource control group comprises a CPU (Central processing Unit) affinity directory;
and creating a control group file corresponding to the container under the CPU affinity directory, determining the number of idle CPU cores of the CPU cores, and binding the container and the idle CPU cores, so that the container runs on the bound idle CPU cores.
Optionally, the determining the number of idle CPU cores of the CPU cores includes:
polling all CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
Optionally, the binding the container and the idle CPU core includes:
and writing the identifier of the idle CPU core into a CPU affinity file under the CPU affinity directory.
Optionally, before creating the container according to the container creation instruction, the method further includes:
NUMA is turned off.
Optionally, the method further includes:
mounting a resource visibility file;
and responding to a CPU information viewing instruction aiming at the container, and displaying the information of the CPU core bound by the container.
Optionally, the CPU affinity directory is a cpsets directory.
Optionally, after the binding the container and the idle CPU core, the method further includes:
and determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
Optionally, after the binding the container and the idle CPU core, the method further includes:
and sending the identifier of the idle CPU core to the main node.
According to a second aspect of the present invention, there is provided a CPU resource allocation apparatus comprising:
the instruction receiving module is used for receiving a container creating instruction sent by the main node, wherein the container creating instruction comprises the number of CPU cores to be bound;
the container creating module is used for creating a container according to the container creating instruction and creating a resource control group corresponding to the container, wherein the resource control group comprises a CPU (Central processing Unit) affinity directory;
and the CPU binding module is used for creating a control group file corresponding to the container under the CPU affinity directory, determining the number of the idle CPU cores of the CPU cores, and binding the container and the idle CPU cores so that the container runs on the bound idle CPU cores.
Optionally, the CPU binding module includes:
and the idle CPU determining unit is used for polling all the CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
Optionally, the CPU binding module includes:
and the CPU recording unit is used for writing the identifier of the idle CPU core into a CPU affinity file in the CPU affinity directory.
Optionally, the apparatus further comprises:
a NUMA closing module, configured to close NUMA before creating the container according to the container creation instruction.
Optionally, the apparatus further comprises:
the visibility file mounting module is used for mounting the resource visibility file;
and the container information display module is used for responding to the CPU information viewing instruction aiming at the container and displaying the information of the CPU core bound by the container.
Optionally, the CPU affinity directory is a cpsets directory.
Optionally, the apparatus further comprises:
and the testing module is used for determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
Optionally, the apparatus further comprises:
and the CPU binding information sending module is used for sending the identifier of the idle CPU core to the main node after the container and the idle CPU core are bound.
According to a third aspect of the present invention, there is also provided a server, a processor, a memory and a computer program stored on the memory and operable on the processor, the computer program, when executed by the processor, implementing the CPU resource allocation method according to the first aspect.
According to a fourth aspect of the present invention, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the CPU resource allocation method according to the first aspect.
According to the CPU resource allocation method, the device, the electronic equipment and the storage medium, the container is created according to the container creation instruction sent by the main node, the resource control group corresponding to the container is created, the control group file corresponding to the container is created under the CPU affinity directory of the resource control group, the idle CPU cores with the number of the CPU cores are determined, and the container and the idle CPU cores are bound, so that the container is bound to the independent CPU cores, services in the container cannot be influenced by other services, and the stability of the services is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention.
FIG. 1 is a schematic diagram of CPU resource allocation in the prior art;
FIG. 2 is a schematic diagram of CPU resource allocation in an embodiment of the present invention;
FIG. 3 is a flowchart illustrating steps of a method for allocating CPU resources according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a directory in which control group files corresponding to containers are located in an embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating differences between display information when a resource visibility file exists and a resource visibility file does not exist in a node of a physical machine executing a CPU information viewing instruction according to an embodiment of the present invention;
fig. 6 is a block diagram of a CPU resource allocation apparatus according to an embodiment of the present invention;
fig. 7 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
By adopting the CPU resource allocation manner in the prior art, for a part of resource-intensive services, the problem that an application program temporarily exits due to the fact that resources exceed a limit is more serious, and therefore a tenant needs a manner that can provide a stable operating environment, for example, a certain container needs to allocate 2-core CPU resources, then all processes of the container will run on 2 specified CPU cores, that is, the service process will not affect other services, and will not be affected by other services, so that the operating environment of the container is closer to the use environment of using a physical machine, that is, the CPU resource allocation effect shown in fig. 2 is achieved, and the container can monopolize 2 CPU cores bound to the container. In order to implement that a container runs on a specified CPU core, the following technical solutions are provided in the embodiments of the present invention.
First, a cluster is newly created as a core-bound cluster in which each container can bind a designated CPU core or cores. In the binding cluster, a physical machine node is determined to serve as a main node, and a container arranging tool is installed in the main node and used for scheduling and managing containers in the physical machine node in the binding cluster. Besides the bound core cluster, a non-bound core cluster can be provided, and the non-bound core cluster adopts a CPU resource allocation mode in the prior art to allocate CPU resources, namely, the container and the CPU core are not bound, and the CPU core is determined at random. Among other things, container orchestration provides an abstraction layer for developers and infrastructure teams to handle large-scale containerized deployments. The features provided by the container orchestration tool vary among many providers, however common features include preparation, discovery, resource management, monitoring, and deployment.
The tenant can input a service creation request through the management platform, and when the fact that the service to be created by the service creation request needs to be bound with CPU resources is determined through auditing, the management platform sends the service creation request to a master node in the binding cluster, wherein the service creation request comprises the number of CPU cores needing to be bound. The master node receives the service creation request; according to the service creation request, determining physical machine nodes which meet the number of the CPU cores in the cluster, namely screening the physical machine nodes in the cluster, so as to determine the physical machine nodes of which the number of the CPU cores in an idle state is equal to or greater than the number of the CPU cores; and sending a container creating instruction to the physical machine node to indicate the physical machine node to create a container, creating a resource control group corresponding to the container, creating a control group file corresponding to the container under a CPU affinity directory of the resource control group, and binding the container and the idle CPU cores with the number of the CPU cores.
Fig. 3 is a flowchart of steps of a CPU resource allocation method provided in an embodiment of the present invention, which may be executed by a physical machine node in a cluster, where the physical machine node may be a slave physical machine node, and as shown in fig. 3, the method may include:
step 301, receiving a container creation instruction sent by a master node, where the container creation instruction includes the number of CPU cores that need to be bound.
The master node is a physical machine node in the cluster, which is provided with a container arrangement tool, and is used for scheduling and managing containers in all the physical machine nodes in the cluster. The cluster is a core binding cluster. In the core-bound cluster, the number of CPUs requested by the container is equal to the upper limit, and the container is guaranteed to be bound on a specified number of CPU cores.
After receiving the service creation request, the master node determines that the physical machine node has idle CPU cores of the number of the CPU cores required to be bound in the service creation request by screening the physical machine nodes of the cluster, and sends a container creation instruction to the physical machine node. The container creating instruction comprises the number of CPU cores to be bound by the container to be created.
Step 302, according to the container creation instruction, creating a container, and creating a resource control group corresponding to the container, where the resource control group includes a CPU affinity directory.
According to the container creating instruction, a container (Docker) is created, and a resource control group (cgroup) corresponding to the container is created under a resource control group (cgroup) of an operating system (such as centros 7), wherein the resource control group corresponding to the container comprises a CPU affinity directory and a CPU directory. The CPU affinity directory is a cpsets directory. Under the CPU group, there are CPU, CPU acc, and cpuset 3 directories (subsystem), where CPU is a partition for CPU usage, and cpuset is for CPU affinity, etc. The settings on the CPU resources can be considered from 2 dimensions: CPU usage percentage and CPU core number. The former is configured using a cpu subsystem, and the latter is configured using a cpu set subsystem.
Step 303, creating a control group file corresponding to the container under the CPU affinity directory, determining the number of idle CPU cores of the CPU cores, and binding the container and the idle CPU cores, so that the container runs on the bound idle CPU cores.
The service is pulled from the master node, and the resource related to the service is placed in the resource control group, that is, the control group file corresponding to the container is stored in the CPU directory, and the same control group file is stored in the CPU affinity directory at the same time, as shown in fig. 4, the same control group file corresponding to the container is stored in both the CPU directory and the CPU affinity (guset) directory. And determining the CPU cores in an idle state as idle CPU cores, wherein the number of the idle CPU cores is the number of the CPU cores needing to be bound in the container creation request, and after the idle CPU cores meeting the requirements are determined, binding the container and the idle CPU cores, so that the container runs in the bound CPU cores, namely, CPU resource binding is realized, the CPU cores cannot be occupied by services in other containers, and the services in the container cannot occupy other CPU cores. The CPU resource binding refers to running on a specified CPU core aiming at all processes in each container on the host.
It should be noted that the container control group file may be in different directories depending on the container version. For example, the classic container orchestration tool kubernets, container control group files at docker18 version are distributed under the kubbeppods directory (complete directory is/systems/fs/cgroup/cpu/kubbeppods /), container control group files at docker12 version are distributed under the kubbeppods.
In an embodiment of the present invention, the determining the number of idle CPU cores of the CPU core number includes:
polling all CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
Polling is carried out on the CPU core of the physical machine node by a polling method, namely if the serial number of the CPU core included in one physical machine node is started from 0, polling is started from the CPU core No. 0 by the polling method, the CPU core in an idle state is determined to be used as an idle CPU core, and polling is stopped when the number of the idle CPU cores reaches the number of the CPU cores needing to be bound by a container, so that the idle CPU cores of the number of the CPU cores are determined. For example, if a physical machine node includes 32 CPU cores, and the numbers are 0 to 31, respectively, and the number of CPU cores to be bound by a container is 3, polling is started from CPU core No. 0 by a polling method, a CPU core in an idle state is determined as an idle CPU core, and polling is stopped when the number of idle CPU cores reaches 3, thereby determining 3 idle CPU cores. If the state of the CPU core No. 0 is determined not to be in an idle state by polling, other containers are bound, the state of the CPU core No. 1 is determined, 3 CPU cores in the idle state are determined by polling to be used as the CPU cores to be bound by the containers, and after the CPU core No. 1, the CPU core No. 3 and the CPU core No. 6 are determined to be in the idle state by polling to the CPU core No. 6, the polling can be stopped if 3 idle CPU cores are determined.
In an embodiment of the present invention, the binding the container with the idle CPU core includes:
and writing the identifier of the idle CPU core into a CPU affinity file under the CPU affinity directory.
The CPU affinity file is a CPU set file and is used for recording the identifier of the CPU core bound by the container.
The CPU affinity directory comprises a CPU affinity file, after the number of the idle CPU cores is determined, the identification of the idle CPU cores is written into the CPU affinity file, so that the binding of the container and the CPU cores is realized by creating a control group file corresponding to the container in the CPU affinity directory and recording the identification of the CPU cores bound by the container in the affinity file in the CPU affinity directory.
After the container is created, a container identifier corresponding to the container is generated, after the control group file corresponding to the container is created, the container identifier is included in the control group file, and the information of the CPU core bound by the container can be viewed through the container identifier.
In the method for allocating CPU resources provided in this embodiment, a container creation instruction sent by a host node is received, a container is created according to the container creation instruction, a resource control group corresponding to the container is created, a control group file corresponding to the container is created under a CPU affinity directory of the resource control group, idle CPU cores in the number of CPU cores are determined, and the container and the idle CPU cores are bound, so that the container is bound to an independent CPU core, a service in the container is not affected by other services, and therefore, the stability of the service is improved, and a contradiction between actual requirements that a current container arrangement tool does not support CPU resource binding but a part of resource-intensive services need CPU resource binding is solved. By adding the core binding cluster capable of binding the CPU resource and the non-core binding cluster capable of randomly distributing the CPU resource, the demands of different tenants can be met, and the diversification of cloud platform services is increased from the side.
On the basis of the above technical solution, before creating a container according to the container creating instruction, the method further includes: NUMA is turned off.
Among them, NUMA (Non Uniform Memory Access Architecture) technology enables a plurality of servers to operate as a single system, while retaining the advantage of a small system that is convenient for programming and management.
In the embodiment of the present invention, to avoid a conflict between the CPU affinity defined by the NUMA and the CPU affinity determined by binding the CPU core through the container in the embodiment of the present invention, before the container is created, the NUMA is closed, thereby ensuring that the subsequent container and the CPU core can be successfully bound.
On the basis of the technical scheme, the method further comprises the following steps:
mounting a resource visibility file;
and responding to a CPU information viewing instruction aiming at the container, and displaying the information of the CPU core bound by the container.
When the physical machine node does not mount the resource visibility file, due to the reason of the container, after the container is bound with the CPU core through the embodiment of the invention, if the CPU information viewing instruction (/ proc/CPU info instruction) is used in the container, only the CPU core information of the host can be displayed, which brings trouble to monitoring. Fig. 5 is a schematic diagram illustrating a difference between display information when a resource visibility file exists in a node of a physical machine and a CPU information viewing instruction is executed without the resource visibility file in the embodiment of the present invention, where as shown in fig. 5, when a resource visibility file exists in a host, CPU information related to a container is displayed when the CPU information viewing instruction is executed, and when a resource visibility file does not exist in the host, CPU information of the host is displayed when the CPU information viewing instruction is executed. Thus, by mounting the resource visibility file, the isolation between containers is enhanced.
On the basis of the above technical solution, after the binding the container and the idle CPU core, the method further includes:
and determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
After the container is bound with the determined idle CPU core, in order to determine whether the binding is successful, a pressure test may be performed on the container, in the process of performing the pressure test, a utilization rate of the idle CPU core is determined, that is, the utilization rate of the CPU core bound by the container is determined, and if the utilization rate is greater than or equal to a preset utilization rate threshold, it is determined that the container and the idle CPU core are successfully compiled.
On the basis of the above technical solution, after the binding the container and the idle CPU core, the method further includes: and sending the identifier of the idle CPU core to the main node.
After the container is bound with the determined idle CPU core, the identifier of the CPU core bound by the container is sent to the main node, so that the main node can manage the container.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Fig. 6 is a block diagram of a CPU resource allocation apparatus according to an embodiment of the present invention, and as shown in fig. 6, the CPU resource allocation apparatus may include:
an instruction receiving module 601, configured to receive a container creation instruction sent by a master node, where the container creation instruction includes the number of CPU cores that need to be bound;
a container creating module 602, configured to create a container according to the container creating instruction, and create a resource control group corresponding to the container, where the resource control group includes a CPU affinity directory;
a CPU binding module 603, configured to create a control group file corresponding to the container in the CPU affinity directory, determine an idle CPU core of the number of CPU cores, and bind the container and the idle CPU core, so that the container runs on the bound idle CPU core.
Optionally, the CPU binding module includes:
and the idle CPU determining unit is used for polling all the CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
Optionally, the CPU binding module includes:
and the CPU recording unit is used for writing the identifier of the idle CPU core into a CPU affinity file in the CPU affinity directory.
Optionally, the apparatus further comprises:
a NUMA closing module, configured to close NUMA before creating the container according to the container creation instruction.
Optionally, the apparatus further comprises:
the visibility file mounting module is used for mounting the resource visibility file;
and the container information display module is used for responding to the CPU information viewing instruction aiming at the container and displaying the information of the CPU core bound by the container.
Optionally, the CPU affinity directory is a cpsets directory.
Optionally, the apparatus further comprises:
and the testing module is used for determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
Optionally, the apparatus further comprises:
and the CPU binding information sending module is used for sending the identifier of the idle CPU core to the main node after the container and the idle CPU core are bound.
In the CPU resource allocation apparatus provided in this embodiment, by receiving a container creation instruction sent by a host node, creating a container according to the container creation instruction, creating a resource control group corresponding to the container, creating a control group file corresponding to the container under a CPU affinity directory of the resource control group, determining idle CPU cores in the number of CPU cores, and binding the container and the idle CPU cores, the container is bound to an independent CPU core, and a service in the container is not affected by other services, so that stability of the service is improved
Fig. 7 is a block diagram of an electronic device according to an embodiment of the present invention. As shown in fig. 7, the electronic device 700 may include one or more processors 701 and one or more memories 702 coupled to the processors 701. The electronic device 700 may also include an input interface 703 and an output interface 704 for communicating with another apparatus or system. Program code executed by the CPU of processor 701 may be stored in memory 702.
The processor 701 in the electronic device 700 calls the program code stored in the memory 702 to execute the CPU resource allocation method in the above-described embodiment.
The above elements in the above electronic device may be connected to each other by a bus, such as one of a data bus, an address bus, a control bus, an expansion bus, and a local bus, or any combination thereof.
There is also provided, in accordance with an embodiment of the present invention, a computer-readable storage medium having a computer program stored thereon, where the storage medium may be a Read-Only Memory (ROM) or a Read-write medium, such as a hard disk or a flash Memory. The computer program realizes the CPU resource allocation method of the foregoing embodiments when executed by a processor.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The CPU resource allocation method, apparatus, electronic device and storage medium provided by the present invention are introduced in detail, and a specific example is applied in the present document to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (18)

1. A CPU resource allocation method is characterized by comprising the following steps:
receiving a container creating instruction sent by a main node, wherein the container creating instruction comprises the number of CPU cores needing to be bound;
according to the container creating instruction, creating a container and creating a resource control group corresponding to the container, wherein the resource control group comprises a CPU (Central processing Unit) affinity directory;
and creating a control group file corresponding to the container under the CPU affinity directory, determining the number of idle CPU cores of the CPU cores, and binding the container and the idle CPU cores, so that the container runs on the bound idle CPU cores.
2. The method of claim 1, wherein determining the number of idle CPU cores of the CPU core comprises:
polling all CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
3. The method of claim 1, wherein binding the container with the idle CPU core comprises:
and writing the identifier of the idle CPU core into a CPU affinity file under the CPU affinity directory.
4. The method according to claim 1, before creating a container according to the container creation instruction, further comprising:
and closing the non-uniform memory access architecture NUMA.
5. The method of claim 1, further comprising:
mounting a resource visibility file;
and responding to a CPU information viewing instruction aiming at the container, and displaying the information of the CPU core bound by the container.
6. The method of claim 1, wherein the CPU affinity directory is a cpuiset directory.
7. The method of claim 1, after said binding said container to said idle CPU core, further comprising:
and determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
8. The method of claim 1, after said binding said container to said idle CPU core, further comprising:
and sending the identifier of the idle CPU core to the main node.
9. An apparatus for allocating CPU resources, comprising:
the instruction receiving module is used for receiving a container creating instruction sent by the main node, wherein the container creating instruction comprises the number of CPU cores to be bound;
the container creating module is used for creating a container according to the container creating instruction and creating a resource control group corresponding to the container, wherein the resource control group comprises a CPU (Central processing Unit) affinity directory;
and the CPU binding module is used for creating a control group file corresponding to the container under the CPU affinity directory, determining the number of the idle CPU cores of the CPU cores, and binding the container and the idle CPU cores so that the container runs on the bound idle CPU cores.
10. The apparatus of claim 9, wherein the CPU binding module comprises:
and the idle CPU determining unit is used for polling all the CPU cores by adopting a polling method, determining the CPU cores in an idle state as idle CPU cores, and stopping polling when the number of the idle CPU cores reaches the number of the CPU cores.
11. The apparatus of claim 9, wherein the CPU binding module comprises:
and the CPU recording unit is used for writing the identifier of the idle CPU core into a CPU affinity file in the CPU affinity directory.
12. The apparatus of claim 9, further comprising:
a NUMA closing module, configured to close NUMA before creating the container according to the container creation instruction.
13. The apparatus of claim 9, further comprising:
the visibility file mounting module is used for mounting the resource visibility file;
and the container information display module is used for responding to the CPU information viewing instruction aiming at the container and displaying the information of the CPU core bound by the container.
14. The apparatus of claim 9, wherein the CPU affinity directory is a CPU set directory.
15. The apparatus of claim 9, further comprising:
and the testing module is used for determining the utilization rate of the idle CPU core based on the pressure test of the container, and determining that the container and the idle CPU core are successfully bound when the utilization rate is greater than or equal to a preset utilization rate threshold value.
16. The apparatus of claim 9, further comprising:
and the CPU binding information sending module is used for sending the identifier of the idle CPU core to the main node after the container and the idle CPU core are bound.
17. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the CPU resource allocation method of any one of claims 1-8.
18. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, implements the CPU resource allocation method of any one of claims 1-8.
CN202010366772.2A 2020-04-30 2020-04-30 CPU resource allocation method, device, electronic equipment and storage medium Pending CN111694658A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010366772.2A CN111694658A (en) 2020-04-30 2020-04-30 CPU resource allocation method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010366772.2A CN111694658A (en) 2020-04-30 2020-04-30 CPU resource allocation method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111694658A true CN111694658A (en) 2020-09-22

Family

ID=72476993

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010366772.2A Pending CN111694658A (en) 2020-04-30 2020-04-30 CPU resource allocation method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111694658A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112667364A (en) * 2021-01-05 2021-04-16 烽火通信科技股份有限公司 Virtual mixed deployment method, device, equipment and storage medium for bound core and non-bound core
CN112699172A (en) * 2021-01-06 2021-04-23 中车青岛四方机车车辆股份有限公司 Data processing method and device for railway vehicle
CN113114715A (en) * 2021-02-24 2021-07-13 网宿科技股份有限公司 Scheduling method based on edge calculation and edge equipment cluster
CN113407305A (en) * 2021-05-31 2021-09-17 北京达佳互联信息技术有限公司 Task deployment method and device, electronic equipment and storage medium
CN115129458A (en) * 2022-09-02 2022-09-30 腾讯科技(深圳)有限公司 Container-based process scheduling method, device, equipment and storage medium
CN116431357A (en) * 2023-06-13 2023-07-14 阿里巴巴(中国)有限公司 Kernel allocation method, allocation component, working node and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105933137A (en) * 2015-12-21 2016-09-07 中国银联股份有限公司 Resource management method, device and system
CN108279979A (en) * 2018-01-19 2018-07-13 聚好看科技股份有限公司 A kind of method and device for binding CPU for Application Container

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105933137A (en) * 2015-12-21 2016-09-07 中国银联股份有限公司 Resource management method, device and system
CN108279979A (en) * 2018-01-19 2018-07-13 聚好看科技股份有限公司 A kind of method and device for binding CPU for Application Container

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孟磊等: "软件质量与测试", 西安电子科技大学出版社, pages: 91 - 92 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112667364A (en) * 2021-01-05 2021-04-16 烽火通信科技股份有限公司 Virtual mixed deployment method, device, equipment and storage medium for bound core and non-bound core
CN112699172A (en) * 2021-01-06 2021-04-23 中车青岛四方机车车辆股份有限公司 Data processing method and device for railway vehicle
CN113114715A (en) * 2021-02-24 2021-07-13 网宿科技股份有限公司 Scheduling method based on edge calculation and edge equipment cluster
CN113114715B (en) * 2021-02-24 2024-01-23 网宿科技股份有限公司 Scheduling method based on edge calculation and edge equipment cluster
CN113407305A (en) * 2021-05-31 2021-09-17 北京达佳互联信息技术有限公司 Task deployment method and device, electronic equipment and storage medium
CN115129458A (en) * 2022-09-02 2022-09-30 腾讯科技(深圳)有限公司 Container-based process scheduling method, device, equipment and storage medium
CN116431357A (en) * 2023-06-13 2023-07-14 阿里巴巴(中国)有限公司 Kernel allocation method, allocation component, working node and storage medium
CN116431357B (en) * 2023-06-13 2023-12-01 阿里巴巴(中国)有限公司 Kernel allocation method, allocation component, working node and storage medium

Similar Documents

Publication Publication Date Title
CN111694658A (en) CPU resource allocation method, device, electronic equipment and storage medium
CN109936604B (en) Resource scheduling method, device and system
EP3469478B1 (en) Server computer management system for supporting highly available virtual desktops of multiple different tenants
CN110941481A (en) Resource scheduling method, device and system
US10154089B2 (en) Distributed system and data operation method thereof
US8185905B2 (en) Resource allocation in computing systems according to permissible flexibilities in the recommended resource requirements
CN107018091B (en) Resource request scheduling method and device
CN104750555B (en) Process management method and device in a kind of Android program
US20170017511A1 (en) Method for memory management in virtual machines, and corresponding system and computer program product
CN110389843B (en) Service scheduling method, device, equipment and readable storage medium
CN106790092B (en) Remote procedure call server control system and method
CN107168777B (en) Method and device for scheduling resources in distributed system
CN109726008B (en) Resource allocation method and equipment
CN112052068A (en) Method and device for binding CPU (central processing unit) of Kubernetes container platform
CN109960569B (en) Virtualization processing method and device
CN113037794A (en) Computing resource allocation scheduling method, device and system
CN109992373B (en) Resource scheduling method, information management method and device and task deployment system
CN111464589A (en) Intelligent contract processing method, computer equipment and storage medium
CN113674131A (en) Hardware accelerator equipment management method and device, electronic equipment and storage medium
CN111611074A (en) Method and device for scheduling cluster resources
CN112559138B (en) Resource scheduling system and method
US20220206836A1 (en) Method and Apparatus for Processing Virtual Machine Migration, Method and Apparatus for Generating Virtual Machine Migration Strategy, Device and Storage Medium
CN111600771B (en) Network resource detection system and method
CN112527490B (en) Node resource management and control method and device, electronic equipment and storage medium
CN113783712A (en) Default gateway management method, gateway manager, server and storage medium

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