CN108279979B - Method and device for binding CPU for application program container - Google Patents

Method and device for binding CPU for application program container Download PDF

Info

Publication number
CN108279979B
CN108279979B CN201810054289.3A CN201810054289A CN108279979B CN 108279979 B CN108279979 B CN 108279979B CN 201810054289 A CN201810054289 A CN 201810054289A CN 108279979 B CN108279979 B CN 108279979B
Authority
CN
China
Prior art keywords
cpu
virtual core
physical
resource pool
shared resource
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.)
Active
Application number
CN201810054289.3A
Other languages
Chinese (zh)
Other versions
CN108279979A (en
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.)
Qingdao Hisense Media Network Technology Co Ltd
Original Assignee
Qingdao Hisense Media Network 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 Qingdao Hisense Media Network Technology Co Ltd filed Critical Qingdao Hisense Media Network Technology Co Ltd
Priority to CN201810054289.3A priority Critical patent/CN108279979B/en
Publication of CN108279979A publication Critical patent/CN108279979A/en
Application granted granted Critical
Publication of CN108279979B publication Critical patent/CN108279979B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources

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)
  • Stored Programmes (AREA)

Abstract

The invention provides a method and a device for binding a CPU for an application program container, wherein the method comprises the following steps: when the application program container runs, at least generating a scheduling instruction according to the CPU quota of the application program container; when the CPU quota is a non-integer value, scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction, wherein the virtual core is obtained by virtualizing a physical CPU; binding the virtual core with the application container. The embodiment of the invention utilizes a physical CPU virtualization technology to obtain the virtual core in a virtual mode and store the virtual core in the shared resource pool, different application program containers schedule the virtual core from the shared resource pool, and the virtual core is bound with the application program container with the CPU quota being a non-integer value, so that the binding flexibility of the application program container can be improved, and the utilization rate of the physical CPU can be improved.

Description

Method and device for binding CPU for application program container
Technical Field
The invention relates to the technical field of resource scheduling, in particular to a method and a device for binding a CPU for an application program container.
Background
Virtualization technology has become a widely recognized way of sharing container technology server resources, and container technology can provide great flexibility for system administrators in building container technology operating system instances on demand.
The container cloud Platform is a Platform As A Service (PAAS) Platform that performs cluster management and scheduling isolation by using a container as a bottom resource granularity, and a large number of application containers (for convenience of description, hereinafter referred to as containers) are confronted under the Platform for cluster management, for example: elastic expansion and contraction of the container, resource monitoring and scheduling and the like.
Under a container cloud platform, a CPU quota is configured when each container is created, and the quota is an integer or a non-integer (according to the actual CPU loss condition of the container, the CPU quota is set to be a non-integer, which belongs to a relatively common condition). When the container runs, the physical CPU matched with the CPU quota needs to be bound with the application container, otherwise, the process of controlling the container is randomly switched among different physical CPUs, and the performance of the host is lost (according to actual measurement, the performance loss can reach 15%). For an integer CPU quota, the CPU quota is directly bound to a physical CPU with the core number equal to the integer through a cgroup technology, and random switching on different physical CPUs can be avoided. However, when the CPU quota is a non-integer value, the CPU is also directly bound to the physical CPU, which lacks binding flexibility, and thus the physical CPU is easily used by the less than full core during the container operation, which is detrimental to the utilization rate of the physical CPU.
Disclosure of Invention
The invention provides a method for binding a CPU (central processing unit) for an application program container and a device for binding the CPU for the application program container, which aim to solve the problems that the existing method for binding the CPU quota to a physical CPU directly when the CPU quota is a non-integer value is lack of binding flexibility, so that the utilization rate of the physical CPU is damaged easily because the physical CPU is not fully used by cores when a container runs.
In order to solve the above problem, the present invention discloses a method for binding a CPU for an application container, wherein the method comprises:
when the application program container runs, at least generating a scheduling instruction according to the CPU quota of the application program container;
when the CPU quota is a non-integer value, scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction, wherein the virtual core is obtained by virtualizing a physical CPU;
binding the virtual core with the application container.
Preferably, the shared resource pool stores an information description table, where the information description table at least stores a physical number of the physical CPU, an integrity identifier for characterizing integrity of a virtual core group obtained virtually by the physical CPU in the shared resource pool, and a mapping relationship between logical numbers for uniquely identifying virtual cores in the virtual core group.
Preferably, the integrity flag comprises a first flag for characterizing that the virtual core group is incomplete in the shared resource pool;
when the CPU quota is a non-integer value, the step of scheduling, according to the scheduling instruction, the virtual core corresponding to the decimal value in the CPU quota from a shared resource pool includes:
determining a logical number group mapped with the first identifier from the information description table aiming at the decimal value;
selecting a target logic number with the number corresponding to the decimal value from a logic number group mapped with the first identifier;
and identifying the virtual core corresponding to the target logic number from the virtual core group.
Preferably, the integrity flag includes a second flag for characterizing that the virtual core group is complete in the shared resource pool;
the method further comprises the following steps:
when the CPU quota is larger than 1, selecting a target physical number of which the number corresponds to the integer value in the CPU quota from the physical numbers mapped with the second identifier;
identifying the physical CPU corresponding to the target physical number
Preferably, the step of scheduling, when the CPU quota is a non-integer value, a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction further includes:
if the number of the logic numbers in the logic number group mapped by the first identifier is smaller than the decimal value, determining the logic number group mapped by the second identifier from the information description table;
and selecting a target logic number from the logic number group mapped with the second identifier.
Preferably, after the step of binding the virtual core obtained virtually for the physical CPU and the application container, the method further includes:
and when the virtual core and the application program container are successfully bound, removing the virtual core and the corresponding mapping relation thereof from an information description table.
The invention also discloses a device for binding the CPU for the application program container, which comprises:
the scheduling instruction generating module is used for generating a scheduling instruction at least according to the CPU quota when the application program container runs;
the virtual core scheduling module is used for scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction when the CPU quota is a non-integer value, wherein the virtual core is obtained by virtualizing a physical CPU;
a binding module for binding the virtual core with the application container.
Preferably, the shared resource pool stores an information description table, where the information description table at least stores a physical number of the physical CPU, an integrity identifier for characterizing integrity of a virtual core group obtained virtually by the physical CPU in the shared resource pool, and a mapping relationship between logical numbers for uniquely identifying virtual cores in the virtual core group.
Preferably, the integrity flag comprises a first flag for characterizing that the virtual core group is incomplete in the shared resource pool;
the virtual core scheduling module comprises:
a first logic number group determination submodule, configured to determine, for the decimal value, a logic number group mapped to the first identifier from the information description table;
a first target logic number selection submodule, configured to select a target logic number whose number corresponds to the decimal value from the logic number group mapped to the first identifier;
and the logic number identification submodule is used for identifying the virtual core corresponding to the target logic number from the virtual core group.
Preferably, the integrity flag includes a second flag for characterizing that the virtual core group is complete in the shared resource pool;
the device further comprises:
a target physical number selecting module, configured to select, when the CPU quota is greater than 1, a target physical number whose number corresponds to an integer value in the CPU quota from the physical numbers mapped to the second identifier;
a target physical number identification module for identifying the physical CPU corresponding to the target physical number
Preferably, the virtual core scheduling module further includes:
a second logical number group determination submodule, configured to determine, if the number of logical numbers in the logical number group mapped to the first identifier is smaller than the decimal value, a logical number group mapped to the second identifier from the information description table;
and the second target logic number selection submodule is used for selecting a target logic number from the logic number group mapped with the second identifier.
Preferably, the apparatus further comprises:
and the removing module is used for removing the virtual core and the corresponding mapping relation thereof from the information description table when the virtual core and the application program container are successfully bound.
Compared with the prior art, the invention has the following advantages:
in the invention, the virtual partition of the physical CPU is realized virtually, so that a virtual core is maintained in a shared resource pool, different application program containers can schedule the virtual core from the shared resource pool, when the application program containers run, a scheduling instruction is generated at least by CPU quotas of the application program containers, the virtual cores corresponding to a decimal value in the CPU quotas are bound according to the scheduling instruction, and when the CPU quotas are non-integer values, the flexibility of binding the physical CPU for the application program containers is improved, so that the utilization rate of the physical CPU is improved.
Drawings
FIG. 1 is a flowchart illustrating steps of a method for establishing a shared resource pool according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps in an embodiment of a method for binding CPUs for application containers, in accordance with an embodiment of the present invention;
FIG. 3 is a block diagram of an apparatus for binding a CPU for an application container according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a service node according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
The embodiment of the invention can be applied to a container cloud platform, and the container cloud platform is a PAAS platform which takes a container as a bottom layer resource granularity for cluster management and scheduling isolation, wherein the cluster can be a service cluster which can comprise a plurality of service nodes. As an example, the service node may include a client node and/or a server node, which is not limited in this respect by the embodiments of the present invention.
The following description takes a service node as a server node as an example:
in the embodiment of the present invention, a proxy service (nodeogen) may be deployed on each server node, and in practice, the proxy service may be similar to a kubernet (kubernet is a container cluster management system of Google open source, which provides functions such as application deployment, maintenance, and extension mechanisms, and can conveniently manage kubbeelet services in a cross-machine operation containerization application) framework.
In the embodiment of the present invention, a shared resource pool (freecpucool) corresponding to each server node may be established through a proxy service, where the shared resource pool may include a virtual core (i.e., vcpure, hereinafter referred to as a virtual core) for scheduling, and further, the vcpure is obtained virtually by a physical cpu (cpu) under the server node.
In a preferred embodiment of the present invention, referring to fig. 1, a flowchart of steps of a method for establishing a shared resource pool according to the embodiment of the present invention is shown, and according to fig. 1, the shared resource pool may be generated by the following steps:
step 101, respectively virtualizing each local physical CPU into a virtual core group, and respectively setting a logic number for uniquely identifying each virtual core in the virtual core group;
in a specific implementation, after the proxy service is started, information of all physical cpus (cpus) on the server node can be acquired through a system command.
In one embodiment, the system command may comprise an lscpu command.
As a preferred example of an embodiment of the present invention, the information of the physical CPU may include, but is not limited to, a physical number for uniquely identifying the physical CPU.
In implementation, the physical number of the physical CPU may be represented by a CPU core number, and in implementation, the CPU core number may be represented as c-N, where N is a serial number of the CPU core, and a value of N is an integer greater than or equal to a value 0 and smaller than the number of the CPU core.
In the embodiment of the present invention, the proxy service may virtualize each cpu core in the server node into a virtual core group according to actual needs, and each virtual core group may include a plurality of virtual cores, that is, vccore, and then set a logic number for uniquely identifying the virtual core for each vccore.
In implementation, the logic number of the virtual core may be represented by a vpucore number, for example, the vpucore number may be represented as c-N-vM, where M is a serial number of the vpucore in the present cpucore. For example, if the cpu core is divided into 10 vccore, then M takes on an integer from 0 to 9).
It should be noted that, in the embodiment of the present invention, the number of vcpuccore in each virtual core group may be determined according to actual requirements, and in the above example, the number is determined to be 10, and it is considered that all the numbers of the decimal part are numerical values smaller than 1, but the embodiment of the present invention is not limited thereto.
In the embodiment of the present invention, an integrity flag for characterizing the integrity of each virtual core group in the shared resource pool may be set for each virtual core group. As an example, the integrity flag may include a first flag characterizing that the virtual core group is incomplete in the shared resource pool, and a second flag characterizing that the virtual core group is complete in the shared resource pool.
Specifically, the first flag may be represented by a false value, and the second flag may be represented by a true value, where the true value is used to indicate that the virtual core group is fully available, and the false value is used to indicate that only a part of the virtual core group is available.
As an example, a True value may be represented as True or a value of 1, and a False value may be represented as False or a value of 0.
102, generating a mapping relation between the physical number and the logic number according to the physical number for uniquely identifying the physical CPU;
and 103, storing the mapping relation in an information description table.
The information description table is stored in a shared resource pool, the shared resource pool further comprises virtual cores obtained by virtualizing a physical CPU by adopting a virtualization technology, and any virtual core can be used for scheduling different application program containers from the shared resource pool together so as to be bound with the application program containers.
After the service agent obtains all the cpucores and the corresponding vcucores in the server node, a mapping relation between physical numbers of all the cpucores and logical numbers of the corresponding vcucores can be generated, and the mapping relation is stored in an information description table of a shared resource pool freecpuool for scheduling.
In a specific implementation, the mapping relationship may include a physical number of the CPU core and a corresponding logical number of the vccpu core, and may further store an integrity identifier for characterizing integrity of a virtual core group obtained by the physical CPU in the shared resource pool. That is, the information description table stores at least the mapping relationship among the aforementioned physical number, integrity flag, and logical number.
As an example, the information description table of freecpmpool may be represented as shown in table 1, but it should be understood that the information of freecpmpool in the embodiment of the present invention is not limited thereto:
Figure GDA0002690633030000071
Figure GDA0002690633030000081
TABLE 1
Based on the above shared resource pool, referring to fig. 2, a flowchart of steps of an embodiment of a method for binding a CPU for an application container according to the embodiment of the present invention is shown, where the embodiment of the present invention may include the following steps:
step 201, when an application program container runs, a scheduling instruction is generated at least by a CPU quota of the application program container;
in a specific implementation, when an application container runs, a scheduling instruction may be generated at least by its CPU quota, and sent to a proxy service agent, where the application container corresponds to an application instance containing a runtime environment.
As an example, the run instruction may include a CPU quota required by the application container runtime.
Step 202, when the CPU quota is a non-integer value, scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction;
step 203, binding the virtual core with the application container.
In practice, the CPU quota may be configured as an integer value or a non-integer value according to the actual CPU consumption condition of the application program, and the non-integer value may be a non-integer value larger than the value 1 or a non-integer value smaller than the value 1.
In a preferred embodiment of the present invention, for a case that the CPU quota is an integer value, or for an integer value in a non-integer that the CPU quota is greater than a value 1, the following two cases are collectively referred to as an integer value, and the present invention may include the following steps:
selecting a target physical number of which the number corresponds to an integer value in the CPU quota from physical numbers of physical CPUs mapped with the second identifier; and identifying the physical CPU corresponding to the target physical number.
In a specific implementation, for an integer value or an integer value in a non-integer value of the CPU quota, the nodagent may determine a physical CPU corresponding to the integer value from an information description table of the shared resource pool through a CGroup function of an operating system (CGroup is a Linux kernel function that packetizes any process.
Specifically, the integrity identifier may be determined as a mapping relationship corresponding to the second identifier from the information description table, then the physical numbers of the mapped physical CPUs are obtained from the corresponding mapping relationship, the target physical numbers corresponding to the integer values are selected from the physical numbers, the target physical numbers are identified, the corresponding physical CPUs may be determined, and the corresponding CPU cores are bound to the application program container, so as to complete the allocation of the CPU matching to the integer values.
For example, assume that the CPU quota of the current application container is 3. The node agent first searches the cpucore numbers of 3 second identifiers (True identifiers) from the freecpucool in the table 1 to serve as target cpucore numbers, and assuming that the target cpucore numbers are c-0, c-1 and c-2, the node agent binds the physical CPUs corresponding to the 3 acquired target cpucore numbers to the container through the CGroup function of the operating system.
When the binding is realized, taking a Linux system as an example, executing a command on an operating system through a CGroup function is as follows:
echo 0-2>/sys/fs/cgroup/cpuset/cpuset.cpus。
in this embodiment of the present invention, if the CPU quota is a non-integer value, for the decimal value of the CPU quota of the non-integer value, the proxy service may select a number of virtual cores corresponding to the decimal value from the shared resource pool, and bind the application container and the number of vcpucucores corresponding to the decimal value.
In a preferred embodiment of the present invention, step 202 may further include the following sub-steps:
a substep S11, determining a logical number group mapped with the first identifier from the information description table for the decimal value;
substep S12, selecting a target logic number whose number corresponds to the decimal value from the logic number group mapped with the first identifier;
and a substep S13, identifying a virtual core corresponding to the target logical number from the virtual core group.
In the embodiment of the present invention, in order to fully utilize all the cpus, the embodiment of the present invention may preferentially select a quota corresponding to the small value to which the vcucore is allocated from the incomplete cpus. Specifically, a mapping relationship corresponding to the integrity identifier as the first identifier may be determined from the information description table, then the mapped logical number group is obtained from the corresponding mapping relationship, the target logical number corresponding to the decimal value is selected from the mapped logical number group, the target logical number is identified in the virtual core group, the corresponding virtual core may be determined, and the corresponding virtual core is bound to the application container, so as to complete the allocation of the CPU quota on the decimal value.
For example, if the CPU quota of the current application container is 0.X, the nodagent searches for a mapping relationship whose integrity identifier is the first identifier from freecpucol, and it is assumed that a physical number of a cpucore included in a certain searched mapping relationship is c-3, and if the number of virtual cores available in a corresponding virtual core group in the freecpucol by c-3 is greater than X, X logical numbers may be selected from the logical numbers of the available virtual cores as target logical numbers, and a virtual core corresponding to the X target logical numbers is identified from the virtual core group. In a specific implementation, when a virtual core and an application container are bound, a physical CPU corresponding to the virtual core and the application container may be bound at the same time, for example, in the above example, if the physical CPUs corresponding to X virtual cores are c-3, then a node agent binds to c-3 for the application container through a cgroup function of an operating system, and when the implementation is performed, taking a Linux system as an example, a binding command executed on the operating system is as follows:
echo 3>/sys/fs/cgroup/cpuset/cpuset.cpus
in a preferred embodiment of the present invention, if the number of the logical numbers in the logical number group of the first identifier map is smaller than the decimal value, step 202 may further include the following sub-steps:
substep S14, if the number of the logical numbers in the logical number group of the first identifier mapping is smaller than the decimal value, determining the logical number group mapped with the second identifier from the information description table;
and a substep S15, selecting a target logical number from the logical number group mapped with the second identifier.
In a specific implementation, if the number of the logical numbers in the logical number group mapped with the first identifier is smaller than the decimal value, the following two meanings may be included:
one layer is: if a plurality of first identifications exist in the information description table, the number of logic numbers in the mapping logic number group mapped with the first identification in the mapping relation corresponding to each first identification is smaller than a decimal value.
The other layer is: and if a plurality of first identifications exist in the information description table, determining that the sum of the number of the logic numbers in the logic number group is smaller than a decimal value in the mapping relation corresponding to all the first identifications.
Any layer that is meant by two layers as described above is possible to those skilled in the art and the embodiments of the present invention are not limited in this respect.
If the number of the logic numbers in the logic number group mapped by the first identifier is smaller than the decimal value, a logic number group mapped by the second identifier can be determined from the information description table, and the logic number corresponding to the decimal value is selected from the logic number group mapped by the second identifier as the target logic number.
It should be noted that, when the first flag does not exist in the information description table, the sub-step S14 and the sub-step S15 may be adopted.
In practice, when some or all of the vcpuccore corresponding to the logical number in the logical number group corresponding to the second identifier is bound to the application container, the second identifier in the information expression table may be updated to the first identifier. In one embodiment, in order to prevent subsequent repeated allocation of a cpu core or a vccore bound to a container, the embodiment of the present invention may further include the following steps:
and when the virtual core and the application program container are successfully bound, removing the virtual core and the corresponding mapping relation thereof from the information description table.
For example, for an integer value of CPU quota, assume the integer value is 3. The Nodeagent selects the numbers of the cpucore as c-0, c-1 and c-2 from the freecpucol in the table 1 to bind with the application container, so that the cpucore numbers as c-0, c-1 and c-2 can be removed from the freecpucol, and the updated freecpucol information description table is shown in the table 2:
Figure GDA0002690633030000111
TABLE 2
As another example, for a small value of CPU quota, assume that the CPU quota of the current container is 0.4. The Nodeagent selects 4 vccore numbers of c-3-v0, c-3-v1, c-3-v2 and c-3-v3 from the freecpucol in the above table 2 to bind with the container, so that c-3-v0, c-3-v1, c-3-v2 and c-3-v3 can be removed from the freecpucol, and the integrity flag of c-3 can be set to a false value because the virtual core group of c-3 is incomplete, so that an updated freecpucol information description table is shown in table 3:
Figure GDA0002690633030000121
TABLE 3
For another example, when there is another CPU quota of 0.3, assuming that 6 vcpupore logic numbers remain in the mapping relationship corresponding to c-3, then 3 vcpupore logic numbers of c-3-v4, c-3-v5, and c-3-v6 may be selected from the mapping relationship again and allocated to the current container, and then c-3-v4, c-3-v5, and c-3-v6 may be removed from freecpore, and the updated freecpore information description table is obtained as shown in table 4:
Figure GDA0002690633030000122
Figure GDA0002690633030000131
TABLE 4
It should be noted that, for a CPU core and/or a vccore that has been allocated to a container, in addition to the above-mentioned manner of deleting the allocated CPU core and/or vccore from the freecpucool, a person skilled in the art may also use other manners to mark that the CPU core and/or vccore has been used, for example, a flag bit used for characterizing that a physical CPU or a virtual core has been bound is added in the information description table, where a use state of the physical CPU or the virtual core to which the flag bit is added is unavailable, which is not limited in this embodiment of the present invention. In the embodiment of the present invention, when a scheduling instruction for a CPU quota of an application container is obtained, for a non-integer value of the CPU quota, a virtual core corresponding to a decimal value in the CPU quota can be scheduled from a shared resource pool according to the scheduling instruction, and the virtual core is bound to the application container, where the virtual core is obtained by virtualizing a physical CPU, so that the corresponding virtual core can be allocated to the decimal value of the CPU quota, and while a scenario of binding the decimal value of the CPU quota is satisfied, each virtual core can be used by a full core, thereby improving a utilization rate of the CPU core.
For example, a web server program actually needs a quota of 0.6CPU, and if the solution of the embodiment of the present invention is not adopted, the container is scheduled to run on a server having 32 CPU cores, and it is assumed that the 32 CPU cores are numbered 0 to 31. At this time, the container can only use 0.6CPU cores at maximum according to a quota during operation, but the 0.6CPU cores used occupy any 1 of 0-31 CPU cores randomly, which results in random scheduling and context switching on 32 CPU cores, causing performance loss, and when the container is deployed and operated on a 32-core server, the performance is about 850QPS/s, if the scheme of the embodiment of the present invention is adopted, only 6 virtual cores need to be allocated to the container, the performance is improved to about 1000QPS/s, the performance is improved by about 17%, and if the 0.6CPU is limited to 1CPU for binding processing, although the same performance can be obtained, the CPU resources are wasted by more than 60%.
For simplicity of explanation, the foregoing method embodiments are described as a series of acts or combinations, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts or acts described, as some steps may occur in other orders or concurrently with other steps in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Referring to fig. 3, a block diagram of an embodiment of an apparatus for binding a CPU for an application container according to an embodiment of the present invention is shown, where the apparatus includes the following modules:
a scheduling instruction generating module 301, configured to generate a scheduling instruction at least according to a CPU quota when the application container runs;
a virtual core scheduling module 302, configured to schedule, when the CPU quota is a non-integer value, a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction, where the virtual core is obtained by virtualizing a physical CPU;
a binding module 303, configured to bind the virtual core with the application container.
In a preferred embodiment of the present invention, an information description table is stored in the shared resource pool, where the information description table at least stores a physical number of the physical CPU, an integrity identifier for characterizing integrity of a virtual core group obtained by virtualization of the physical CPU in the shared resource pool, and a mapping relationship between logical numbers for uniquely identifying virtual cores in the virtual core group.
In a preferred embodiment of the present invention, the integrity flag includes a first flag for characterizing that the virtual core group is incomplete in the shared resource pool;
the virtual core scheduling module 302 may include the following sub-modules:
a first logic number group determination submodule, configured to determine, for the decimal value, a logic number group mapped to the first identifier from the information description table;
a first target logic number selection submodule, configured to select a target logic number whose number corresponds to the decimal value from the logic number group mapped to the first identifier;
and the logic number identification submodule is used for identifying the virtual core corresponding to the target logic number from the virtual core group.
In a preferred embodiment of the present invention, the integrity flag includes a second flag used for characterizing that the virtual core group is complete in the shared resource pool;
the device further comprises:
a target physical number selecting module, configured to select, when the CPU quota is greater than 1, a target physical number whose number corresponds to an integer value in the CPU quota from the physical numbers mapped to the second identifier;
a target physical number identification module for identifying the physical CPU corresponding to the target physical number
In a preferred embodiment of the present invention, the virtual core scheduling module 302 may further include the following sub-modules:
a second logical number group determination submodule, configured to determine, if the number of logical numbers in the logical number group mapped to the first identifier is smaller than the decimal value, a logical number group mapped to the second identifier from the information description table;
and the second target logic number selection submodule is used for selecting a target logic number from the logic number group mapped with the second identifier.
In a preferred embodiment of the present invention, the apparatus may further include the following modules:
the removing module is used for removing the virtual core and the corresponding mapping relation thereof from an information description table when the virtual core and the application program container are successfully bound;
alternatively, the first and second electrodes may be,
and the flag bit identification module is used for adding a flag bit for representing that the virtual core is bound in an information description table.
Referring to fig. 4, a schematic structural diagram of a service node according to an embodiment of the present invention is shown, where a proxy service 401 (proxy) is deployed on the service node 40, and the proxy service 401 virtualizes a physical CPU402 (i.e., a physical CPU core) on the service node 40 by using a virtualization technology to obtain a virtual core group consisting of a plurality of virtual cores 403.
The set of virtual cores may be stored in a shared pool of shared resources 404, and any virtual core 403 may be scheduled from the shared pool of shared resources 404 for different application containers in common to bind with the application container.
In a specific implementation, the shared resource pool 404 may be stored in a memory, and the shared resource pool 404 may further include an information description table 405, where the information description table 405 may be configured to record a mapping relationship between a physical number of the physical CPU402, an integrity identifier used for characterizing the integrity of the virtual core group in the shared resource pool 404, and a logical number used for uniquely identifying the virtual core 403 in the virtual core group.
Although not shown, the service node may further include a Radio Frequency (RF) circuit, an input unit, a display unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a power supply, and the like. And will not be described in detail herein.
In the embodiment of the present invention, when the application container 406 runs, the scheduling instruction is generated at least by the CPU quota thereof, and the virtual core 403 corresponding to the decimal value in the CPU quota is bound according to the scheduling instruction, so that when the CPU quota is a non-integer value, the flexibility of binding the physical CPU for the application container 406 is improved, and further, the utilization rate of the physical CPU is improved.
The embodiments in the present description are all described in a progressive manner, and the emphasis of each embodiment is to be described different from the other embodiments, and the same and similar parts among the embodiments can be referred to each other.
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 apparatus 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 apparatus. 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 apparatus that comprises the element.
The method and the device for binding the CPU for the application container 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 (8)

1. A method for binding a CPU for an application container, the method comprising:
when the application program container runs, at least generating a scheduling instruction according to the CPU quota of the application program container;
when the CPU quota is a non-integer value, scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction, wherein the virtual core is obtained by virtualizing a physical CPU;
binding the virtual core with the application container;
the shared resource pool stores an information description table, and the information description table at least stores the mapping relationship between the following data: the physical number of the physical CPU, the integrity identifier used for representing the integrity of the virtual core group obtained by the physical CPU in the shared resource pool, and the logic number used for uniquely identifying the virtual core in the virtual core group.
2. The method of claim 1, wherein the integrity flag comprises a first flag characterizing that the virtual core group is incomplete in the shared resource pool;
when the CPU quota is a non-integer value, the step of scheduling, according to the scheduling instruction, the virtual core corresponding to the decimal value in the CPU quota from a shared resource pool includes:
determining a logical number group mapped with the first identifier from the information description table aiming at the decimal value;
selecting a target logic number with the number corresponding to the decimal value from a logic number group mapped with the first identifier;
and identifying the virtual core corresponding to the target logic number from the virtual core group.
3. The method according to claim 1 or 2, wherein the integrity flag comprises a second flag for characterizing the integrity of the virtual core group in the shared resource pool;
the method further comprises the following steps:
when the CPU quota is larger than 1, selecting a target physical number of which the number corresponds to the integer value in the CPU quota from the physical numbers mapped with the second identifier;
and identifying the physical CPU corresponding to the target physical number.
4. The method according to claim 3, wherein the step of scheduling, when the CPU quota is a non-integer value, the virtual core corresponding to the decimal value in the CPU quota from a shared resource pool according to the scheduling instruction further includes:
if the number of the logic numbers in the logic number group mapped by the first identifier is smaller than the decimal value, determining the logic number group mapped by the second identifier from the information description table;
and selecting a target logic number from the logic number group mapped with the second identifier.
5. The method according to claim 1 or 4, further comprising, after the step of binding the virtual core obtained virtually for the physical CPU with the application container:
and when the virtual core and the application program container are successfully bound, removing the virtual core and the corresponding mapping relation thereof from an information description table.
6. An apparatus for binding a CPU for an application container, the apparatus comprising:
the scheduling instruction generating module is used for generating a scheduling instruction at least according to the CPU quota when the application program container runs;
the virtual core scheduling module is used for scheduling a virtual core corresponding to a decimal value in the CPU quota from a shared resource pool according to the scheduling instruction when the CPU quota is a non-integer value, wherein the virtual core is obtained by virtualizing a physical CPU;
a binding module for binding the virtual core with the application container;
the shared resource pool stores an information description table, and the information description table at least stores the mapping relationship between the following data: the physical number of the physical CPU, the integrity identifier used for representing the integrity of the virtual core group obtained by the physical CPU in the shared resource pool, and the logic number used for uniquely identifying the virtual core in the virtual core group.
7. The apparatus of claim 6, wherein the integrity flag comprises a first flag characterizing that the virtual core group is incomplete in the shared resource pool;
the virtual core scheduling module comprises:
a first logic number group determination submodule, configured to determine, for the decimal value, a logic number group mapped to the first identifier from the information description table;
a first target logic number selection submodule, configured to select a target logic number whose number corresponds to the decimal value from the logic number group mapped to the first identifier;
and the logic number identification submodule is used for identifying the virtual core corresponding to the target logic number from the virtual core group.
8. The apparatus according to claim 6 or 7, wherein the integrity flag comprises a second flag for characterizing the integrity of the virtual core group in the shared resource pool;
the device further comprises:
a target physical number selecting module, configured to select, when the CPU quota is greater than 1, a target physical number whose number corresponds to an integer value in the CPU quota from the physical numbers mapped to the second identifier;
and the target physical number identification module is used for identifying the physical CPU corresponding to the target physical number.
CN201810054289.3A 2018-01-19 2018-01-19 Method and device for binding CPU for application program container Active CN108279979B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810054289.3A CN108279979B (en) 2018-01-19 2018-01-19 Method and device for binding CPU for application program container

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810054289.3A CN108279979B (en) 2018-01-19 2018-01-19 Method and device for binding CPU for application program container

Publications (2)

Publication Number Publication Date
CN108279979A CN108279979A (en) 2018-07-13
CN108279979B true CN108279979B (en) 2021-02-19

Family

ID=62804106

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810054289.3A Active CN108279979B (en) 2018-01-19 2018-01-19 Method and device for binding CPU for application program container

Country Status (1)

Country Link
CN (1) CN108279979B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110597639B (en) * 2019-09-23 2021-07-30 腾讯科技(深圳)有限公司 CPU distribution control method, device, server and storage medium
CN112748850B (en) 2019-10-29 2024-04-19 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for storage management
CN111124687B (en) * 2019-12-30 2022-04-22 浪潮电子信息产业股份有限公司 CPU resource reservation method, device and related equipment
CN111694658A (en) * 2020-04-30 2020-09-22 北京城市网邻信息技术有限公司 CPU resource allocation method, device, electronic equipment and storage medium
CN112052068A (en) * 2020-08-17 2020-12-08 烽火通信科技股份有限公司 Method and device for binding CPU (central processing unit) of Kubernetes container platform
CN112039963B (en) * 2020-08-21 2023-04-07 广州虎牙科技有限公司 Processor binding method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103870314A (en) * 2014-03-06 2014-06-18 中国科学院信息工程研究所 Method and system for simultaneously operating different types of virtual machines by single node
CN102158884B (en) * 2010-02-11 2016-05-11 中兴通讯股份有限公司 A kind of method and system of carrying out Physical Resource Block binding configuration
CN105700961A (en) * 2016-02-29 2016-06-22 华为技术有限公司 Business container creation method and device
CN105893138A (en) * 2014-12-19 2016-08-24 伊姆西公司 Resource management method and device based on quota
CN105912403A (en) * 2016-04-14 2016-08-31 青岛海信传媒网络技术有限公司 Resource management method and device of Docker container
US9703589B2 (en) * 2013-08-26 2017-07-11 Vmware, Inc. Networking stack of virtualization software configured to support latency sensitive virtual machines

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102158884B (en) * 2010-02-11 2016-05-11 中兴通讯股份有限公司 A kind of method and system of carrying out Physical Resource Block binding configuration
US9703589B2 (en) * 2013-08-26 2017-07-11 Vmware, Inc. Networking stack of virtualization software configured to support latency sensitive virtual machines
CN103870314A (en) * 2014-03-06 2014-06-18 中国科学院信息工程研究所 Method and system for simultaneously operating different types of virtual machines by single node
CN105893138A (en) * 2014-12-19 2016-08-24 伊姆西公司 Resource management method and device based on quota
CN105700961A (en) * 2016-02-29 2016-06-22 华为技术有限公司 Business container creation method and device
CN105912403A (en) * 2016-04-14 2016-08-31 青岛海信传媒网络技术有限公司 Resource management method and device of Docker container

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于容器虚拟化技术研究;汪恺,等;;《计算机技术与发展》;20150831;第25卷(第8期);138-141 *
虚拟机处理器核数与物理cpu的关系;nmingwei,;《https://blog.csdn.net/nmingwei/article/details/45690871》;20150513;1 *

Also Published As

Publication number Publication date
CN108279979A (en) 2018-07-13

Similar Documents

Publication Publication Date Title
CN108279979B (en) Method and device for binding CPU for application program container
US10409628B2 (en) Managing virtual machine instances utilizing an offload device
US10701139B2 (en) Life cycle management method and apparatus
US10768972B2 (en) Managing virtual machine instances utilizing a virtual offload device
CN109684065B (en) Resource scheduling method, device and system
CN108293041B (en) Distributed system, resource container allocation method, resource manager and application controller
US11392400B2 (en) Enhanced migration of clusters based on data accessibility
US9329889B2 (en) Rapid creation and reconfiguration of virtual machines on hosts
US10025615B2 (en) Dynamic guest virtual machine identifier allocation
US8484654B2 (en) Determining suitable network interface for partition deployment/re-deployment in a cloud environment
US9158567B2 (en) System and method for reconfigurable network services using modified network configuration with modified bandwith capacity in dynamic virtualization environments
CN109313564B (en) Server computer management system for highly available virtual desktops supporting multiple different tenants
KR102361929B1 (en) Capacity Management in Provider Networks Using Dynamic Host Device Instance Model Reconfiguration
US20130185404A1 (en) Efficient port management for a distributed network address translation
WO2012039053A1 (en) Method of managing computer system operations, computer system and computer-readable medium storing program
US11343141B2 (en) Methods and apparatus to migrate physical server hosts between virtual standard switches and virtual distributed switches in a network
US9858096B2 (en) Communication device migration method of extension function and communication system
US8352702B2 (en) Data processing system memory allocation
US20170063627A1 (en) Allocation of virtual clusters in a large-scale processing environment
US11301299B2 (en) Data based scheduling for horizontally scalable clusters
US10496444B2 (en) Computer and control method for computer
CN108667750B (en) Virtual resource management method and device
CN110447019B (en) Memory allocation manager and method for managing memory allocation performed thereby
US9923865B1 (en) Network address management
CN112948201B (en) Automatic operation and maintenance method and system

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
GR01 Patent grant
GR01 Patent grant