CN110069338B - Resource control method, device and equipment and computer readable storage medium - Google Patents

Resource control method, device and equipment and computer readable storage medium Download PDF

Info

Publication number
CN110069338B
CN110069338B CN201810067256.2A CN201810067256A CN110069338B CN 110069338 B CN110069338 B CN 110069338B CN 201810067256 A CN201810067256 A CN 201810067256A CN 110069338 B CN110069338 B CN 110069338B
Authority
CN
China
Prior art keywords
controlled service
parameter value
controlled
resource
resource control
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
CN201810067256.2A
Other languages
Chinese (zh)
Other versions
CN110069338A (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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN201810067256.2A priority Critical patent/CN110069338B/en
Priority to PCT/CN2019/070271 priority patent/WO2019144788A1/en
Publication of CN110069338A publication Critical patent/CN110069338A/en
Application granted granted Critical
Publication of CN110069338B publication Critical patent/CN110069338B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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]
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/503Resource availability

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a resource control method, a device, equipment and a computer readable storage medium, wherein the method comprises the following steps: acquiring a resource proportion parameter value of controlled service allocation; converting the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service; and dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service. The invention converts the resource proportion parameter value allocated by the controlled service into the resource control parameter value, and dynamically controls the resources occupied by the controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.

Description

Resource control method, device and equipment and computer readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, and a device for controlling resources, and a computer readable storage medium.
Background
When multiple distributed systems or multiple non-distributed systems run on the same physical cluster and the same hardware environment, various resources, such as: disk, network, CPU, memory, etc., the great pressure of preemption and competition. Some systems may monopolize cluster physical resources, resulting in other systems being blocked from running.
For resource control of multiple distributed systems and non-distributed systems in the same operating environment, no effective solution has been proposed in the industry.
Disclosure of Invention
Accordingly, an object of the present invention is to provide a method, apparatus and device for controlling resources, and a computer readable storage medium, so as to solve the problem of cluster resource utilization conflict when a plurality of distributed systems and non-distributed systems operate in the same cluster.
The technical scheme adopted by the invention for solving the technical problems is as follows:
according to an aspect of the present invention, there is provided a resource control method, the method comprising the steps of:
acquiring a resource proportion parameter value of controlled service allocation;
converting the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service;
and dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service.
According to another aspect of the present invention, there is provided a resource control apparatus, the apparatus including an acquisition module, a conversion module, and a dynamic control module;
the acquisition module is used for acquiring the resource proportion parameter value allocated by the controlled service;
the conversion module is used for converting the resource proportion parameter value distributed by the controlled service into a resource control parameter value of the controlled service;
and the dynamic control module is used for dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service.
According to another aspect of the present invention, there is provided a resource control apparatus, the apparatus comprising: the resource control system comprises a memory, a processor and a resource control program stored in the memory and capable of running on the processor, wherein the resource control program realizes the steps of the resource control method when being executed by the processor.
According to another aspect of the present invention, there is provided a computer-readable storage medium having stored thereon a resource control program which, when executed by a processor, implements the steps of the resource control method described above.
The embodiment of the invention discloses a resource control method, a device, equipment and a computer readable storage medium, which are used for converting a resource proportion parameter value allocated by a controlled service into a resource control parameter value and dynamically controlling resources occupied by a controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.
Drawings
FIG. 1 is a flow chart of a resource control method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a dynamic control flow in a resource control method according to a first embodiment of the present invention;
FIG. 3 is a flow chart of another method for controlling resources according to the first embodiment of the present invention;
FIG. 4 is a schematic diagram of a resource control device according to a second embodiment of the present invention;
FIG. 5 is a schematic diagram of another configuration of a resource control device according to a second embodiment of the present invention;
FIG. 6 is a schematic diagram of a dynamic control module in a resource control device according to a second embodiment of the present invention;
fig. 7 is a schematic diagram of a resource control device according to a third embodiment of the present invention;
FIG. 8 is a schematic diagram of a configuration interface of a resource controller according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a resource controller according to an embodiment of the present invention;
FIG. 10 is a schematic diagram illustrating a control effect structure of a CPU subsystem according to an embodiment of the present invention;
fig. 11 is a schematic diagram of a cpu subsystem control effect structure according to an embodiment of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
In order to make the technical problems, technical schemes and beneficial effects to be solved more clear and obvious, the invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
First embodiment
As shown in fig. 1, a first embodiment of the present invention provides a resource control method, which includes the steps of:
s11, acquiring a resource proportion parameter value allocated by the controlled service.
In this embodiment, the resource controller collects resources from each controlled host in the cluster, including the number of CPU cores, the number of physical memories, and the like of the host; in a virtualized environment, the resource controller may also obtain the resource configuration of the host from each virtualized host.
In this embodiment, the resources include, but are not limited to, a CPU (Central Processing Unit ), a memory, a network, a disk IO (Input/Output), and the like.
In this embodiment, the resource controller provides a configuration interface that allocates a percentage of the available resources to each of the controlled systems, with the percentage of the available resources for all of the controlled systems totaling 100%.
As an example, please refer to fig. 8, fig. 8 is a schematic diagram of a configuration interface structure of a resource controller. The configuration interface configures the controlled service 1, and available resources comprise a CPU, a memory, a network and a disk IO.
S12, converting the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service.
In this embodiment, the step of converting the resource proportion parameter value allocated by the controlled service into the resource control parameter value of the controlled service includes the steps of:
and converting the resource proportion parameter value allocated by the controlled service into the resource control parameter value of the controlled service according to the soft control mode or the hard control mode.
As an example, please refer to fig. 8 again, the soft limit is the soft control mode, and the hard limit is the hard control mode.
In this embodiment, the resource Control parameter value of the controlled service may be a Cgroup (Control Groups) parameter value or a memory Control parameter.
As an example, assuming that the resource proportion parameter value allocated by the controlled service is x%, the resource proportion parameter value allocated by the controlled service is converted into the resource control parameter value of the controlled service as follows:
1) CPU resource control
Soft control mode: the integer value of the available relative shared CPU time between controlled services is controlled by using the CPU.shares parameter of the CPU subsystem, and the conversion algorithm is as follows: cpu.shares=max (20, rounded (x% ×1024)).
Hard control mode: the number of CPU cores and the number of memory nodes available to a process are limited by using the parameters of the CPU and the parameters of the CPU are required to be set simultaneously. The conversion algorithm is as follows: cpu=x% (number of host logic CPU cores-number of reserved CPU cores) (rounding), default reservation of 1 CPU core; the CPU core number calculated by the parameter result can be represented by ID, and the ID are separated. cpu.mes=number of memory nodes accessible to the host. The cpu set.mes parameter value is obtained by cat/proc/zoneinfo|grep Node. In particular, this option of cpu set. Mes is mainly directed to machine use of NUMA (Non Uniform Memory Access Architecture, non-uniform memory access architecture), SMP (Symmetric Multi-Processing) machines have only 1 memory node.
2) Disk IO resource control
Soft control mode: the relative proportions of Cgroup default available access blocks IO may be specified using the blkio.weight of the Cgroup's blkio subsystem. The conversion algorithm is as follows: blkio.weight=max (100, rounded (x% ×1000)).
Hard control mode: the byte upper limit of the device read/write data per second in the Cgroup is specified by the bandwidth value blkio.
blkio.throttle.read_bps_device=READ_BPS*(1-factor)*x%
blkio.throttle.write_bps_device=WRITE_BPS*(1-factor)*x%
READ_BPS is the maximum byte number of READ data per second of all mounted disks of the current host, and WRITE_BPS is the maximum byte number of WRITE data per second of all mounted disks of the current host; the factor is a reserved internal case, defaulting to 0.2, which is a relatively secure value, and reserves a portion of memory resources for use by the operating system.
3) Network resource control
Hard control mode: limiting process bandwidth with the net_cls subsystem, the net_cls marks network packets with Class identifiers (Class IDs), allowing Linux traffic control program TC to identify packets generated from a particular Cgroup and assign different priorities to packets in different cgroups.
net_cls.clside=0 xAAAABBBB in 16 scale, AAAA is major number, BBBB is minor number, wherein major: minor is handle id of class, each class is assigned an id for identification.
Parameters of the flow control program TC are configured:
tc qdisc add dev DEV [ parent qdisc-id|root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ], where qdisc-id is the major: minor in net_cls
qdisc specific parameters the rate parameter is used to set the controlled service bandwidth value.
rate = number of bytes per second swallowed by the controlled service network.
4) Memory resource control
For the control of the memory resources, the memory resources are controlled by utilizing the self-resource control capability of the system, such as the maximum heap memory (-Xmx) of Java, the maximum out-of-stack memory quantity (-XX: maxDIRECTEMORySize) distributed by Java processes and the like, and the memory control parameters are directly written into the start script of the controlled service.
In order to prevent excessive memory occupation of the application system process, memory resources of the server are reserved.
Default physical memory of controlled service allocation = (total physical memory-uncontrolled service physical memory) × (1-factor) × x%.
The total physical memory is the total physical memory of the current host, the uncontrolled service physical memory is the physical memory occupied by the processes which are not managed by the resource control on the host, the factor is the reserved memory proportion, the default is 0.3, the value is a relatively safe value, and a part of memory is reserved for the operating system to use.
S13, dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service.
Referring to fig. 3, in one embodiment, before dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service, the method further includes the steps of:
and S130, adjusting the resource control parameter value of the controlled service.
In this embodiment, the pre-assigned Cgroup parameter value or memory control parameter of a certain controlled host node or a certain service may be adjusted individually according to the situation.
Referring to fig. 2, in one embodiment, the dynamic control of the resources occupied by the controlled service process according to the resource control parameter value of the controlled service includes the steps of:
s131, the resource control parameter value of the controlled service is written into the designated file of the controlled host.
Referring to fig. 9, in this embodiment, the resource controller first creates mount points of the file system as root directories of the Cgroup subsystem tree at each controlled host node. For example: mkdir/cgroup; wherein/Cgroup is a mounting directory of Cgroup.
Next, the point is mounted to the plurality of subsystems as follows:
the mount-t cpu-o cpu/; mounting a cpu subsystem;
the mount-t group-o group cpu set/cpu/; mounting a CPU subsystem;
the mount-t cgroup-o blkio/cgroup/; mounting a blkio subsystem;
the mount-t cgroup-o net_cls/cgroup/; mounting a net_cls subsystem;
thus, the related subsystem of Cgroup is automatically mounted to a hierarchy of hierarchy, and the following directory structure is automatically generated:
/cgroup/cpu/;
/cgroup/cpuset/;
/cgroup/blkio/;
/cgroup/net_cls。
then, the resource controller respectively creates subdirectories for the controlled services, and the mounted directory/subsystem name/controlled service name of the mkdir Cgroup;
the directory results are as follows:
a/cgroup/cpu/controlled service name;
a/cgroup/cpu/controlled service name;
a/cgroup/blkio/controlled service name;
/cgroup/net_cls/controlled service name.
Finally, the resource controller writes the Cgroup parameters into the files of the mounting catalog/subsystem name/controlled service name/control item of the Cgroup one by one, and additionally writes the memory resource control parameters into the configuration file of the controlled service;
the values of the parameters of the shared are written into the mounting catalog/cpu/controlled service name/cpu/shared of the Cgroup;
the value of the parameters of the CPU is written into the mounting catalog/CPU/controlled service name/CPU of the Cgroup;
the parameter value of CPU.mes is written into the mounting catalog/CPU/controlled service name/CPU/mes of Cgroup;
writing the blkio.weight parameter value into the mounting catalog/blkio/controlled service name/blkio.weight of the Cgroup;
writing a blkio.color_bps_device parameter value into a mounting directory/blkio/controlled service name/blkio.color_bps_device of the Cgroup;
writing a blkio.color_bps_device parameter value into a mounting directory/blkio/controlled service name/blkio.color_bps_device of the Cgroup;
the net_cls.classified parameter value is written into the mounting catalog/blkio/controlled service name/net_cls.classified of Cgroup;
the following commands are invoked to set the parameters configuring the flow control program TC: tc qdisc add dev DEV [ parent qdisc-id|root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ];
for the control of the memory resource, the memory resource is controlled by utilizing the self-resource control capability of the system, such as the maximum heap memory (-Xmx) of Java, the maximum out-of-stack memory quantity (-XX: maxDirectMemorySize) distributed by Java process and the like, and the memory control parameters of the process JVM are directly written into the JVM control items corresponding to the starting script of the controlled service.
S132, restarting the controlled service process.
S133, acquiring the process identification and all associated sub-thread identifications of the controlled service after being started, and writing the process identification and all associated sub-thread identifications of the controlled service into a task file of the controlled host.
As shown in fig. 9, the process identifier and all associated sub-thread identifiers thereof are written into a task file of the controlled host, and the task content is a list of all controlled process IDs.
The group/cpu/controlled service name/task;
the group/cpu set/controlled service name/task;
the group/blkio/controlled service names/tasks;
/cgroup/net_cls/controlled service name/tasks.
S134, dynamically controlling the resources occupied by the controlled service process.
Referring to fig. 3 again, in one embodiment, after dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service, the method further includes the steps of:
s14, collecting and displaying resources occupied by the controlled service process.
For example, please refer to fig. 10-11:
FIG. 10 is a hard control scheme for CPU usage of a single process group with a CPU subsystem, YARN is set to 50% and the overall CPU resource ceiling occupied by YARN process group is not more than 50%, which is a hard limiting case.
Fig. 11 is a block diagram of a CPU, in which CPU time resources are elastically allocated according to a weight ratio by using CPU. Shares of a CPU subsystem, and when a host encounters a CPU contention condition, CPU time slices are allocated according to a weight ratio, and when a CPU is idle, a process group consuming the CPU can fully occupy the remaining CPU time, thereby fully utilizing the resources.
YARN and Spark services were according to 30%: as can be seen from fig. 11, when the system only operates by yacn, yacn occupies more than 45% of CPU time, after Spark service is started, yacn and Spark service occupy resources, cbroup allocates CPU according to the ratio of 1:1, and the ratio is also 1:1, so that flexible soft control is achieved.
The resource control method of the embodiment of the invention converts the resource proportion parameter value allocated by the controlled service into the resource control parameter value and dynamically controls the resources occupied by the controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.
Second embodiment
As shown in fig. 4, a second embodiment of the present invention provides a resource control device, which includes an acquisition module 21, a conversion module 22, and a dynamic control module 23;
the obtaining module 21 is configured to obtain a resource proportion parameter value of the controlled service allocation.
In this embodiment, the resource controller collects resources from each controlled host in the cluster, including the number of CPU cores, the number of physical memories, and the like of the host; in a virtualized environment, the resource controller may also obtain the resource configuration of the host from each virtualized host.
In this embodiment, the resources include, but are not limited to, a CPU (Central Processing Unit ), a memory, a network, a disk IO (Input/Output), and the like.
In this embodiment, the resource controller provides a configuration interface that allocates a percentage of the available resources to each of the controlled systems, with the percentage of the available resources for all of the controlled systems totaling 100%.
As an example, please refer to fig. 8, fig. 8 is a schematic diagram of a configuration interface structure of a resource controller. The configuration interface configures the controlled service 1, and available resources comprise a CPU, a memory, a network and a disk IO.
The conversion module 22 is configured to convert the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service.
In this embodiment, the conversion module 22 may convert the resource proportion parameter value allocated by the controlled service into the resource control parameter value of the controlled service according to the soft control mode or the hard control mode.
As an example, please refer to fig. 8 again, the soft limit is the soft control mode, and the hard limit is the hard control mode.
In this embodiment, the resource Control parameter value of the controlled service may be a Cgroup (Control Groups) parameter value or a memory Control parameter.
As an example, assuming that the resource proportion parameter value allocated by the controlled service is x%, the resource proportion parameter value allocated by the controlled service is converted into the resource control parameter value of the controlled service as follows:
1) CPU resource control
Soft control mode: utilizing cpu.shares parameter of CPU subsystem to control integer value of available relative shared CPU time between controlled services, converting algorithm is as follows: cpu.shares=max (20, rounded (x% ×1024)).
Hard control mode: the number of CPU cores and the number of memory nodes available to a process are limited by using the parameters of the CPU and the parameters of the CPU are required to be set simultaneously. The conversion algorithm is as follows: cpu=x% (number of host logic CPU cores-number of reserved CPU cores) (rounding), default reservation of 1 CPU core; the CPU core number calculated by the parameter result can be represented by ID, and the ID are separated. cpu.mes=number of memory nodes accessible to the host. The cpu set.mes parameter value is obtained by cat/proc/zoneinfo|grep Node. In particular, this option of cpu set. Mes is mainly directed to machine use of NUMA (Non Uniform Memory Access Architecture, non-uniform memory access architecture), SMP (Symmetric Multi-Processing) machines have only 1 memory node.
2) Disk IO resource control
Soft control mode: the relative proportions of Cgroup default available access blocks IO may be specified using the blkio.weight of the Cgroup's blkio subsystem. The conversion algorithm is as follows: blkio.weight=max (100, rounded (x% ×1000)).
Hard control mode: the byte upper limit of the device read/write data per second in the Cgroup is specified by the bandwidth value blkio.
blkio.throttle.read_bps_device=READ_BPS*(1-factor)*x%
blkio.throttle.write_bps_device=WRITE_BPS*(1-factor)*x%
READ_BPS is the maximum byte number of READ data per second of all mounted disks of the current host, and WRITE_BPS is the maximum byte number of WRITE data per second of all mounted disks of the current host; the factor is a reserved internal case, defaulting to 0.2, which is a relatively secure value, and reserves a portion of memory resources for use by the operating system.
3) Network resource control
Hard control mode: limiting process bandwidth with the net_cls subsystem, the net_cls marks network packets with Class identifiers (Class IDs), allowing Linux traffic control program TC to identify packets generated from a particular Cgroup and assign different priorities to packets in different cgroups.
net_cls.clside=0 xAAAABBBB in 16 scale, AAAA is major number, BBBB is minor number, wherein major: minor is handle id of class, each class is assigned an id for identification.
Parameters of the flow control program TC are configured:
tc qdisc add dev DEV [ parent qdisc-id|root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ], where qdisc-id is the major: minor in net_cls
qdisc specific parameters the rate parameter is used to set the controlled service bandwidth value.
rate = number of bytes per second swallowed by the controlled service network.
4) Memory resource control
For the control of the memory resources, the memory resources are controlled by utilizing the self-resource control capability of the system, such as the maximum heap memory (-Xmx) of Java, the maximum out-of-stack memory quantity (-XX: maxDIRECTEMORySize) distributed by Java processes and the like, and the memory control parameters are directly written into the start script of the controlled service.
In order to prevent excessive memory occupation of the application system process, memory resources of the server are reserved.
Default physical memory of controlled service allocation = (total physical memory-uncontrolled service physical memory) × (1-factor) × x%.
The total physical memory is the total physical memory of the current host, the uncontrolled service physical memory is the physical memory occupied by the processes which are not managed by the resource control on the host, the factor is the reserved memory proportion, the default is 0.3, the value is a relatively safe value, and a part of memory is reserved for the operating system to use.
The dynamic control module 23 is configured to dynamically control resources occupied by the controlled service process according to the resource control parameter value of the controlled service.
Referring to fig. 5, in one embodiment, the apparatus further includes an adjustment module 24;
the adjusting module 24 is configured to adjust a value of a resource control parameter of the controlled service.
In this embodiment, the pre-assigned Cgroup parameter value or memory control parameter of a certain controlled host node or a certain service may be adjusted individually according to the situation.
Referring to fig. 6, in one embodiment, the dynamic control module 23 includes a first writing unit 231, a restarting unit 232, a second writing unit 233, and a control unit 234;
the first writing unit 231 is configured to write a resource control parameter value of the controlled service into a specified file of the controlled host.
Referring to fig. 9, in this embodiment, the resource controller first creates mount points of the file system as root directories of the Cgroup subsystem tree at each controlled host node. For example: mkdir/cgroup; wherein/Cgroup is a mounting directory of Cgroup.
Next, the point is mounted to the plurality of subsystems as follows:
the mount-t cpu-o cpu/; mounting a cpu subsystem;
the mount-t group-o group cpu set/cpu/; mounting a CPU subsystem;
the mount-t cgroup-o blkio/cgroup/; mounting a blkio subsystem;
the mount-t cgroup-o net_cls/cgroup/; mounting a net_cls subsystem;
thus, the related subsystem of Cgroup is automatically mounted to a hierarchy of hierarchy, and the following directory structure is automatically generated:
/cgroup/cpu/;
/cgroup/cpuset/;
/cgroup/blkio/;
/cgroup/net_cls。
then, the resource controller respectively creates subdirectories for the controlled services, and the mounted directory/subsystem name/controlled service name of the mkdir Cgroup;
the directory results are as follows:
a/cgroup/cpu/controlled service name;
a/cgroup/cpu/controlled service name;
a/cgroup/blkio/controlled service name;
/cgroup/net_cls/controlled service name.
Finally, the resource controller writes the Cgroup parameters into the files of the mounting catalog/subsystem name/controlled service name/control item of the Cgroup one by one, and additionally writes the memory resource control parameters into the configuration file of the controlled service;
the values of the parameters of the shared are written into the mounting catalog/cpu/controlled service name/cpu/shared of the Cgroup;
the value of the parameters of the CPU is written into the mounting catalog/CPU/controlled service name/CPU of the Cgroup;
the parameter value of CPU.mes is written into the mounting catalog/CPU/controlled service name/CPU/mes of Cgroup;
writing the blkio.weight parameter value into the mounting catalog/blkio/controlled service name/blkio.weight of the Cgroup;
writing a blkio.color_bps_device parameter value into a mounting directory/blkio/controlled service name/blkio.color_bps_device of the Cgroup;
writing a blkio.color_bps_device parameter value into a mounting directory/blkio/controlled service name/blkio.color_bps_device of the Cgroup;
the net_cls.classified parameter value is written into the mounting catalog/blkio/controlled service name/net_cls.classified of Cgroup;
the following commands are invoked to set the parameters configuring the flow control program TC: tc qdisc add dev DEV [ parent qdisc-id|root ] [ handle qdisc-id ] qdisc [ qdisc specific parameters ];
for the control of the memory resource, the memory resource is controlled by utilizing the self-resource control capability of the system, such as the maximum heap memory (-Xmx) of Java, the maximum out-of-stack memory quantity (-XX: maxDirectMemorySize) distributed by Java process and the like, and the memory control parameters of the process JVM are directly written into the JVM control items corresponding to the starting script of the controlled service.
The restarting unit 232 is configured to restart the controlled service process.
The second writing unit 233 is configured to obtain the process identifier and all associated sub-thread identifiers thereof after the controlled service is started, and write the process identifier and all associated sub-thread identifiers thereof into a task file of the controlled host.
As shown in fig. 9, the process identifier and all associated sub-thread identifiers thereof are written into a task file of the controlled host, and the task content is a list of all controlled process IDs.
The group/cpu/controlled service name/task;
the group/cpu set/controlled service name/task;
the group/blkio/controlled service names/tasks;
/cgroup/net_cls/controlled service name/tasks.
The control unit 234 is configured to dynamically control resources occupied by the controlled service process.
Referring again to fig. 5, in one embodiment, the apparatus further comprises a monitoring module 25;
the monitoring module 25 is configured to collect and display resources occupied by the controlled service process.
For example, please refer to fig. 10-11:
FIG. 10 is a hard control scheme for CPU usage of a single process group with a CPU subsystem, YARN is set to 50% and the overall CPU resource ceiling occupied by YARN process group is not more than 50%, which is a hard limiting case.
Fig. 11 is a block diagram of a CPU, in which CPU time resources are elastically allocated according to a weight ratio by using CPU. Shares of a CPU subsystem, and when a host encounters a CPU contention condition, CPU time slices are allocated according to a weight ratio, and when a CPU is idle, a process group consuming the CPU can fully occupy the remaining CPU time, thereby fully utilizing the resources.
YARN and Spark services were according to 30%: as can be seen from fig. 11, when the system only operates by yacn, yacn occupies more than 45% of CPU time, after Spark service is started, yacn and Spark service occupy resources, cbroup allocates CPU according to the ratio of 1:1, and the ratio is also 1:1, so that flexible soft control is achieved.
The resource control device of the embodiment of the invention converts the resource proportion parameter value allocated by the controlled service into the resource control parameter value and dynamically controls the resources occupied by the controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.
Third embodiment
As shown in fig. 7, a third embodiment of the present invention provides a resource control device, including: a memory 31, a processor 32, and a resource control program stored on the memory 31 and executable on the processor 32, which when executed by the processor 32, is adapted to carry out the steps of the resource control method described below:
acquiring a resource proportion parameter value of controlled service allocation;
converting the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service;
and dynamically controlling the resources occupied by the controlled service process according to the resource control parameter value of the controlled service.
The resource control program, when executed by the processor 32, is further configured to implement the steps of the resource control method described below:
and converting the resource proportion parameter value allocated by the controlled service into the resource control parameter value of the controlled service according to the soft control mode or the hard control mode.
The resource control program, when executed by the processor 32, is further configured to implement the steps of the resource control method described below:
and adjusting the resource control parameter value of the controlled service.
The resource control program, when executed by the processor 32, is further configured to implement the steps of the resource control method described below:
writing the resource control parameter value of the controlled service into a designated file of the controlled host;
restarting the controlled service process;
acquiring a process identifier and all associated sub-thread identifiers thereof after the controlled service is started, and writing the process identifier and all associated sub-thread identifiers thereof into a task file of the controlled host;
and dynamically controlling the resources occupied by the controlled service process.
The resource control program, when executed by the processor 32, is further configured to implement the steps of the resource control method described below:
and collecting and displaying the resources occupied by the controlled service process.
The resource control equipment of the embodiment of the invention converts the resource proportion parameter value allocated by the controlled service into the resource control parameter value and dynamically controls the resources occupied by the controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.
Fourth embodiment
A fourth embodiment of the present invention provides a computer-readable storage medium having stored thereon a resource control program for implementing the steps of the resource control method described in the first embodiment when executed by a processor.
The computer readable storage medium of the embodiment of the invention converts the resource proportion parameter value allocated by the controlled service into the resource control parameter value and dynamically controls the resources occupied by the controlled service process; the problem of cluster resource use conflict when a plurality of distributed systems and non-distributed systems run in the same cluster is solved; the controlled service is prevented from monopolizing all the resources to cause the operation of other systems to be blocked, and the resource utilization rate is improved.
It should be noted that the above device embodiments and method embodiments belong to the same concept, the specific implementation process of the device embodiments is detailed in the method embodiments, and technical features in the method embodiments are correspondingly applicable in the device embodiments, which are not repeated herein.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, and thus do not limit the scope of the claims of the present invention. Those skilled in the art will appreciate that many modifications are possible in which the invention is practiced without departing from its scope or spirit, e.g., features of one embodiment can be used with another embodiment to yield yet a further embodiment. Any modification, equivalent replacement and improvement made within the technical idea of the present invention should be within the scope of the claims of the present invention.

Claims (10)

1. A method of resource control, the method comprising the steps of:
acquiring a resource proportion parameter value allocated by a controlled service, wherein the resource proportion parameter value represents the percentage of available resources allocated by the controlled service in available resources of all the controlled services;
converting the resource proportion parameter value allocated by the controlled service into a resource control parameter value of the controlled service;
dynamically controlling the resources occupied by the process of the controlled service according to the resource control parameter value of the controlled service;
wherein the resource control parameter values of the controlled service include: control group parameter values or memory control parameters;
the resources allocated by the controlled service include one of: CPU, memory, network, disk IO;
and under the condition that the resource of the controlled service is a CPU, the resource control parameter value of the controlled service comprises: the integer value of the relative shared CPU time available between controlled services in the soft control mode, the CPU kernel number and the memory node number available for the process in the hard control mode;
and under the condition that the resource of the controlled service is a memory, the resource control parameter value of the controlled service comprises: default physical memory allocated for controlled services in soft control mode;
converting the resource proportion parameter value allocated by the controlled service into the resource control parameter value of the controlled service, including:
according to a soft control mode or a hard control mode, converting the resource proportion parameter value allocated to the controlled service into a resource control parameter value of the controlled service according to a preset conversion algorithm, wherein the resource control parameter value represents the quantity of available resources allocated to the controlled service;
according to the resource control parameter value of the controlled service, dynamically controlling the resources occupied by the process of the controlled service, including: and correspondingly controlling the resources occupied by the processes of the different controlled services according to the resource control parameter values corresponding to the different controlled services.
2. The method according to claim 1, wherein before the dynamic control of the resources occupied by the process of the controlled service according to the resource control parameter value of the controlled service, further comprises the steps of:
and adjusting the resource control parameter value of the controlled service.
3. The method according to claim 1, wherein the dynamically controlling the resources occupied by the process of the controlled service according to the resource control parameter value of the controlled service comprises the steps of:
writing the resource control parameter value of the controlled service into a designated file of the controlled host;
restarting the process of the controlled service;
acquiring a process identifier and all associated sub-thread identifiers thereof after the controlled service is started, and writing the process identifier and all associated sub-thread identifiers thereof into a task file of the controlled host;
and dynamically controlling the resources occupied by the process of the controlled service.
4. The method according to claim 1, wherein the dynamic control of the resources occupied by the process of the controlled service according to the resource control parameter value of the controlled service further comprises the steps of:
and collecting and displaying the resources occupied by the process of the controlled service.
5. The resource control device is characterized by comprising an acquisition module, a conversion module and a dynamic control module;
the acquisition module is used for acquiring a resource proportion parameter value allocated by the controlled service, wherein the resource proportion parameter value represents the percentage of the available resources allocated by the controlled service in the available resources of all the controlled services;
the conversion module is used for converting the resource proportion parameter value distributed by the controlled service into a resource control parameter value of the controlled service;
the dynamic control module is used for dynamically controlling the resources occupied by the process of the controlled service according to the resource control parameter value of the controlled service;
wherein the resource control parameter values of the controlled service include: control group parameter values or memory control parameters;
the resources allocated by the controlled service include one of: CPU, memory, network, disk IO;
and under the condition that the resource of the controlled service is a CPU, the resource control parameter value of the controlled service comprises: the integer value of the relative shared CPU time available between controlled services in the soft control mode, the CPU kernel number and the memory node number available for the process in the hard control mode;
and under the condition that the resource of the controlled service is a memory, the resource control parameter value of the controlled service comprises: default physical memory allocated for controlled services in soft control mode;
the conversion module is specifically configured to convert, according to a soft control mode or a hard control mode, a resource proportion parameter value allocated to the controlled service into a resource control parameter value of the controlled service according to a preset conversion algorithm, where the resource control parameter value represents an amount of available resources allocated to the controlled service;
the dynamic control module is specifically configured to correspondingly control resources occupied by respective processes of different controlled services according to respective corresponding resource control parameter values of the different controlled services.
6. The apparatus of claim 5, further comprising an adjustment module;
and the adjusting module is used for adjusting the resource control parameter value of the controlled service.
7. The apparatus of claim 5, wherein the dynamic control module comprises a first write unit, a restart unit, a second write unit, and a control unit;
the first writing unit is used for writing the resource control parameter value of the controlled service into a designated file of the controlled host;
the restarting unit is used for restarting the process of the controlled service;
the second writing unit is used for acquiring the process identifier and all associated sub-thread identifiers thereof after the controlled service is started, and writing the process identifier and all associated sub-thread identifiers thereof into a task file of the controlled host;
and the control unit is used for dynamically controlling the resources occupied by the process of the controlled service.
8. The apparatus of claim 5, further comprising a monitoring module;
and the monitoring module is used for collecting and displaying the resources occupied by the process of the controlled service.
9. A resource control device, the device comprising: a memory, a processor and a resource control program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the resource control method of any of claims 1 to 4.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a resource control program, which when executed by a processor, implements the steps of the resource control method according to any of claims 1 to 4.
CN201810067256.2A 2018-01-24 2018-01-24 Resource control method, device and equipment and computer readable storage medium Active CN110069338B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810067256.2A CN110069338B (en) 2018-01-24 2018-01-24 Resource control method, device and equipment and computer readable storage medium
PCT/CN2019/070271 WO2019144788A1 (en) 2018-01-24 2019-01-03 Resource control method and device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810067256.2A CN110069338B (en) 2018-01-24 2018-01-24 Resource control method, device and equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110069338A CN110069338A (en) 2019-07-30
CN110069338B true CN110069338B (en) 2024-03-19

Family

ID=67365162

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810067256.2A Active CN110069338B (en) 2018-01-24 2018-01-24 Resource control method, device and equipment and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN110069338B (en)
WO (1) WO2019144788A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791868B (en) * 2021-09-16 2024-08-27 北京金山云网络技术有限公司 Method and device for controlling CPU resource occupation amount and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102857470A (en) * 2011-06-27 2013-01-02 腾讯科技(深圳)有限公司 Network transmission system, servers and client
CN104885059A (en) * 2012-12-12 2015-09-02 株式会社东芝 Cloud system management device, cloud system, reallocation method, and program
CN106547478A (en) * 2015-09-23 2017-03-29 北京奇虎科技有限公司 The I/O throughput monitoring method of process and device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645957B (en) * 2013-12-25 2017-03-08 北京搜狐新媒体信息技术有限公司 A kind of resources of virtual machine management-control method and device
CN105988872B (en) * 2015-02-03 2020-02-18 阿里巴巴集团控股有限公司 Method and device for CPU resource allocation and electronic equipment
CN105630602B (en) * 2015-12-18 2019-01-15 山东海量信息技术研究院 A kind of method of resource for computer system dynamic adjustment
US10063601B2 (en) * 2016-03-21 2018-08-28 Microsoft Technology Licensing, Llc Client identification for enforcing computer resource quotas
CN106776013B (en) * 2016-11-29 2020-11-24 北京元心科技有限公司 Multi-system resource scheduling method and device
CN106686136A (en) * 2017-02-24 2017-05-17 郑州云海信息技术有限公司 Cloud resource scheduling method and device
CN107529696B (en) * 2017-05-11 2021-01-26 新华三云计算技术有限公司 Storage resource access control method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102857470A (en) * 2011-06-27 2013-01-02 腾讯科技(深圳)有限公司 Network transmission system, servers and client
CN104885059A (en) * 2012-12-12 2015-09-02 株式会社东芝 Cloud system management device, cloud system, reallocation method, and program
CN106547478A (en) * 2015-09-23 2017-03-29 北京奇虎科技有限公司 The I/O throughput monitoring method of process and device

Also Published As

Publication number Publication date
WO2019144788A1 (en) 2019-08-01
CN110069338A (en) 2019-07-30

Similar Documents

Publication Publication Date Title
CN108268317B (en) Resource allocation method and device
CN110941481A (en) Resource scheduling method, device and system
CN107515786B (en) Resource allocation method, master device, slave device and distributed computing system
CN113037794B (en) Method, device and system for computing resource allocation scheduling
CN105159775A (en) Load balancer based management system and management method for cloud computing data center
CN107483364A (en) A kind of scheduling of Hadoop Yarn network bandwidth resources, partition method and device
CN112214288B (en) Pod scheduling method, device, equipment and medium based on Kubernetes cluster
CN112698929B (en) Information acquisition method and device
CN110764908A (en) Load adjusting method and device, server and storage medium
CN114116173A (en) Method, device and system for dynamically adjusting task allocation
CN111240824B (en) CPU resource scheduling method and electronic equipment
CN110069338B (en) Resource control method, device and equipment and computer readable storage medium
CN117519953B (en) Separated memory management method for server-oriented non-perception calculation
CN109189581B (en) Job scheduling method and device
CN116436968A (en) Service grid communication method, system, device and storage medium
CN109995590A (en) A kind of user's self-defining device data processing service trustship method
CN115629854A (en) Distributed task scheduling method, system, electronic device and storage medium
CN111796934B (en) Task issuing method and device, storage medium and electronic equipment
CN112468458B (en) Scheduling method based on neutron layering mechanism
CN114675954A (en) Task scheduling method and device
CN108279982B (en) Method, system and equipment for managing pbs resources and hadoop resources
CN112671871B (en) Mirror image distribution method and device, terminal equipment and storage medium
CN113127186B (en) Method, device, server and storage medium for configuring cluster node resources
CN116775286A (en) Application deployment method and terminal
CN115314493A (en) Cluster scheduling method and device

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