IaaS host machine energy-saving method and systemTechnical Field
The invention relates to the technical field of energy conservation of a host machine in a virtual machine, in particular to an energy conservation method and system for an IaaS host machine.
Background
The internet is developed today, and a server develops an energy-saving concept in about 2008, and reduces the main frequency of a CPU under the condition of low CPU load, thereby reducing power output and realizing energy saving. All servers typically have a power saving mode setting in the BIOS. With the development of cloud computing, the power saving mode is automatically started, some unforeseen situations occur, such as that the client performance of a cloud host cannot run up, and the like, and in the virtualized IaaS layer, a client is generally guided not to start the power saving mode in the BIOS of a server.
In the prior art, the contradiction points occur as follows: how to achieve the coexistence of performance and energy saving. For example, in a virtualized environment, a plurality of physical devices (hosts) are combined to form a pool concept, so that a client VM (virtual machine) can freely and flexibly transfer in a physical device resource pool, and if an energy-saving mode is completely closed, a high-performance mode is used, so that the same amount of electric energy is always used no matter whether the physical devices borne by the VM cloud host exist, the temperature of the devices is increased, and the electric energy use of a central air conditioner of a machine room is indirectly increased.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide an IaaS host energy saving method and system, which can combine and allocate the energy saving mode and the performance mode of a host, so as to achieve the optimal energy saving effect without affecting the performance of the host.
In order to solve the technical problems, the invention provides the following technical scheme: an energy-saving method for an IaaS host machine comprises the following steps:
s1, starting the host machine and enabling the host machine to enter a performance mode;
s2, customizing an energy-saving mode of the host, and if the energy-saving mode is met, enabling the host to enter the energy-saving mode from the performance mode, specifically:
s21, detecting the number of VM virtual machines of the host machine, and if the number of the VM virtual machines is 0, enabling the host machine to enter an energy-saving mode; if the number of the VM virtual machines is not 0, the VM virtual machines are in a performance mode;
s22, when the number of the VM virtual machines is not 0, continuously detecting the hardware performance of the host machine, wherein the steps include:
detecting the CPU utilization rate, and if the CPU utilization rate is lower than a set threshold, enabling the host machine to enter an energy-saving mode; the set threshold value of the CPU utilization rate is preset with a specific numerical value on a host machine;
s23, after the step S22, if the host machine is still in the performance mode, collecting the qemu process quantity of the host machine, and if the qemu process quantity is lower than the set quantity, starting the energy-saving mode by the host machine; the set number of the qemu process number is preset with a specific number value on the host machine.
Further, the specific value of the threshold for the CPU utilization in step S22 is 30%.
Further, in step S22, when the number of VM virtual machines is not 0, continuing to detect the hardware performance of the host, the method further includes:
detecting the utilization rate of the memory, and if the utilization rate of the memory is lower than a set value, enabling the host machine to enter an energy-saving mode; the setting value of the memory utilization rate is preset with a specific numerical value on the host machine.
Further, the specific value of the set value of the memory utilization rate in the step S22 is 50%.
Further, in the step S23, the specific quantity value of the set quantity of qemu processes is 3.
The invention also aims to provide an IaaS host machine energy-saving system, which comprises a VM virtual machine and a host machine thereof, wherein the host machine comprises an energy-saving mode module, a performance mode module, a VM virtual machine quantity detection module, a CPU utilization rate detection module, a memory utilization rate detection module and a qemu process quantity detection module;
the energy-saving mode module is used for controlling the energy-saving mode of the host machine;
the performance mode module is used for controlling the performance mode of the host machine;
the VM virtual machine number detection module is used for detecting the number of the VM virtual machines, and when the number of the VM virtual machines is detected to be 0, the energy-saving mode module controls the host machine to enter an energy-saving mode; when detecting that the number of the VM virtual machines is not 0, the performance mode module controls the host machine to enter a performance mode;
the CPU utilization rate detection module is used for detecting the CPU utilization rate and presetting a specific numerical value for a set threshold value of the CPU utilization rate on the host machine, and when the CPU utilization rate is detected to be lower than the set threshold value, the energy-saving mode module controls the host machine to enter an energy-saving mode; when the CPU utilization rate is not lower than a set threshold value, the performance mode module controls the host machine to enter a performance mode;
the memory utilization rate detection module is used for detecting the memory utilization rate and setting a specific numerical value for a set value of the memory utilization rate on the host in advance, and when the memory utilization rate is detected to be lower than the set value, the energy-saving mode module controls the host to enter an energy-saving mode; when the memory utilization rate is not lower than a set value, the performance mode module controls the host machine to enter a performance mode;
the qemu process quantity detection module is used for detecting the qemu process quantity and presetting a specific quantity value for the set quantity of the qemu process quantity on the host, and when the qemu process quantity is detected to be lower than the set quantity, the energy-saving mode module controls the host to enter an energy-saving mode; and when detecting that the number of the qemu processes is not lower than the set number, controlling the host machine to enter a performance mode by the performance mode module.
After the technical scheme is adopted, the invention at least has the following beneficial effects: the energy-saving mode of the host machine is controlled by detecting the virtual number of the virtual machines, the CPU utilization rate, the memory utilization rate and the qemu process number, so that the energy-saving mode and the performance mode can be optimally switched, and the optimal energy-saving control under the state of not losing the highest performance is achieved.
Drawings
FIG. 1 is a flowchart of the steps of a method for saving energy of an IaaS host machine according to the present invention;
FIG. 2 is a system framework diagram for energy saving of an IaaS host according to the present invention.
Detailed Description
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict, and the present application is further described in detail with reference to the drawings and specific embodiments.
Example 1
The invention collects some energy-saving data through a series of collecting modules or detecting modules, judges whether a physical host (host) needs to enter an energy-saving mode, and switches and controls the energy-saving mode or a performance mode through a setting module. Thus, as shown in fig. 1, the present invention provides a method for saving energy of an IaaS host machine, comprising the steps of:
1. firstly, a physical host needs to be started, namely a host is started and enters a performance mode; under default conditions, the host machine can enter a performance mode as soon as the host machine is started;
2. after the host machine is started, the host machine is in a performance mode, and whether the host machine has an energy-saving mode condition needs to be detected in order to achieve the energy-saving mode; the energy-saving mode of the host machine is customized in advance, if the energy-saving mode condition is met, the host machine enters the energy-saving mode from the performance mode, and the method specifically comprises the following steps:
21. detecting the number of VM virtual machines of a host machine, and if the number of the VM virtual machines is 0, enabling the host machine to enter an energy-saving mode; if the number of the VM virtual machines is not 0, the VM virtual machines are in a performance mode;
22. when the number of the VM virtual machines is not 0, the VM virtual machines will be in a performance mode, and at this time, a series of hardware performances of the host machine need to be continuously detected to control whether the host machine needs to enter an energy saving mode, including:
detecting the CPU utilization rate, and if the CPU utilization rate is lower than a set threshold, enabling the host machine to enter an energy-saving mode; the set threshold value of the CPU utilization rate is preset with a specific numerical value on a host machine; the set threshold of the CPU utilization rate may be arbitrarily adjusted according to the actual situation, and in this embodiment, the set threshold of the CPU utilization rate is set to 30% preferentially;
or detecting the memory utilization rate, and if the memory utilization rate is lower than a set value, enabling the host machine to enter an energy-saving mode; setting a specific numerical value on a host machine in advance according to the set value of the memory utilization rate; the set value of the memory utilization rate can be adjusted arbitrarily according to the actual situation, and in this embodiment, the set value is set to 50% preferentially;
23. after step 22, if the host is still in the performance mode, collecting the qemu process quantity of the host, and if the qemu process quantity is lower than the set quantity, starting the energy-saving mode by the host; the set number of the qemu process number is preset with a specific number value on a host machine; the set number of the qemu process numbers can be arbitrarily adjusted according to actual conditions, and in this embodiment, the number value of the set number is preferably set to 3.
Example 2
The present embodiment provides an IaaS host machine energy saving system based on the method of embodiment 1, as shown in fig. 2, including a VM virtual machine and a host machine thereof, where the host machine includes an energy saving mode module, a performance mode module, a VM virtual machine number detection module, a CPU utilization detection module, a memory utilization detection module, and a qemu process number detection module;
the energy-saving mode module is used for controlling the energy-saving mode of the host machine;
the performance mode module is used for controlling the performance mode of the host machine;
the VM virtual machine number detection module is used for detecting the number of the VM virtual machines, and when the number of the VM virtual machines is detected to be 0, the energy-saving mode module controls the host machine to enter an energy-saving mode; when detecting that the number of the VM virtual machines is not 0, the performance mode module controls the host machine to enter a performance mode;
the CPU utilization rate detection module is used for detecting the CPU utilization rate and presetting a specific numerical value for a set threshold value of the CPU utilization rate on the host machine, and when the CPU utilization rate is detected to be lower than the set threshold value, the energy-saving mode module controls the host machine to enter an energy-saving mode; when the CPU utilization rate is not lower than a set threshold value, the performance mode module controls the host machine to enter a performance mode;
the memory utilization rate detection module is used for detecting the memory utilization rate and setting a specific numerical value for a set value of the memory utilization rate on the host in advance, and when the memory utilization rate is detected to be lower than the set value, the energy-saving mode module controls the host to enter an energy-saving mode; when the memory utilization rate is not lower than a set value, the performance mode module controls the host machine to enter a performance mode;
the qemu process quantity detection module is used for detecting the qemu process quantity and presetting a specific quantity value for the set quantity of the qemu process quantity on the host, and when the qemu process quantity is detected to be lower than the set quantity, the energy-saving mode module controls the host to enter an energy-saving mode; and when detecting that the number of the qemu processes is not lower than the set number, controlling the host machine to enter a performance mode by the performance mode module.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various equivalent changes, modifications, substitutions and alterations can be made herein without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.