Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
Example 1
As shown in fig. 1, an embodiment of the present invention provides a load balancing method in a virtualization system, including:
step S110, configuring load balancing parameters, and setting load balancing constraint conditions according to the load balancing parameters; wherein the load balancing parameters include: the method comprises the following steps that a single host migrates the maximum value m of the number of virtual machines in a scheduling period and the minimum time interval t of two times of migration of the same virtual machine;
step S120, when detecting that the load of a source host exceeds a threshold value, determining a virtual machine to be migrated of the source host according to a load balancing constraint condition;
step S130, migrating the virtual machine to be migrated of the source host to the destination host, and recording migration information of the virtual machine;
in this embodiment, the source host is a host that migrates the virtual machine, and the destination host is a host that migrates the virtual machine;
in one embodiment, the load of the host comprises any one of: CPU occupancy rate, memory occupancy rate, and comprehensive occupancy rate of CPU and memory; the comprehensive occupancy rate of the CPU and the memory is as follows: carrying out weighted average on the CPU occupancy rate and the memory occupancy rate to obtain the occupancy rate;
wherein, the load of the source host exceeds the threshold value, which includes any one of the following: the CPU occupancy rate of the source host is greater than a first threshold value, the memory occupancy rate of the source host is greater than a second threshold value, and the comprehensive occupancy rate of the CPU and the memory of the source host is greater than a third threshold value;
in one embodiment, the determining the virtual machine to be migrated of the source host according to the load balancing constraint condition includes performing the following steps:
sorting all the virtual machines on the source host from high to low according to the resource occupancy rate;
traversing each virtual machine from the virtual machine with the highest resource occupancy rate, and determining the virtual machine to be migrated which meets a first load balancing constraint condition and a second load balancing constraint condition;
wherein the first load balancing constraint condition comprises: the time interval of two times of migration of the same virtual machine is greater than or equal to the minimum time interval t; the second load balancing constraint condition comprises: the number of the virtual machines migrated by a single host in one scheduling period is less than or equal to the maximum value m;
in one embodiment, the resource occupancy of the virtual machine includes any one of: CPU occupancy rate, memory occupancy rate, and comprehensive occupancy rate of CPU and memory; the comprehensive occupancy rate of the CPU and the memory is as follows: carrying out weighted average on the CPU occupancy rate and the memory occupancy rate to obtain the occupancy rate;
in one embodiment, the migrating the virtual machine to be migrated of the source host to the destination host includes:
sequencing all virtual machines to be migrated on the source host from high to low according to the resource occupancy rate;
traversing each virtual machine to be migrated from the virtual machine to be migrated with the highest resource occupancy rate, and determining a target host paired with each virtual machine to be migrated according to a load balancing strategy: sorting other hosts in a virtualization system where the source host is located according to loads from small to large for the virtual machines to be migrated which need to be paired currently, taking the host with the smallest load as a target host corresponding to the virtual machine to be migrated currently, and updating the load of the target host into the load added with the virtual machine to be migrated;
and migrating each virtual machine to be migrated of the source host to a paired destination host.
In one embodiment, the migrating each virtual machine to be migrated of the source host to a paired destination host includes: simultaneously starting to migrate each virtual machine to be migrated of the source host;
in one embodiment, the migration information of the virtual machine includes: identification of the virtual machine and migration time of the virtual machine.
The technical scheme of the embodiment of the invention can reasonably arrange the tasks of the virtual machine migration in a large-batch environment, thereby avoiding a large number of migration tasks or service jitter of certain virtual machines (service jitter caused by frequent migration) in the load balancing scheduling process.
Example 2
As shown in fig. 2, an embodiment of the present invention provides a load balancing apparatus in a virtualization system, including:
a parameter configuration module 201, configured to configure load balancing parameters, and set load balancing constraint conditions according to the load balancing parameters; wherein the load balancing parameters include: the method comprises the following steps that a single host migrates the maximum value m of the number of virtual machines in a scheduling period and the minimum time interval t of two times of migration of the same virtual machine;
a migration list generation module 202, configured to determine, when it is detected that a load of a source host exceeds a threshold, a virtual machine to be migrated of the source host according to a load balancing constraint condition;
the migration module 203 is configured to migrate the virtual machine to be migrated of the source host to the destination host;
the recording module 204 is configured to record migration information of the virtual machine;
in this embodiment, the source host is a host that migrates the virtual machine, and the destination host is a host that migrates the virtual machine;
in one embodiment, the load of the host comprises any one of: CPU occupancy rate, memory occupancy rate, and comprehensive occupancy rate of CPU and memory; the comprehensive occupancy rate of the CPU and the memory is as follows: carrying out weighted average on the CPU occupancy rate and the memory occupancy rate to obtain the occupancy rate;
wherein, the load of the source host exceeds the threshold value, which includes any one of the following: the CPU occupancy rate of the source host is greater than a first threshold value, the memory occupancy rate of the source host is greater than a second threshold value, and the comprehensive occupancy rate of the CPU and the memory of the source host is greater than a third threshold value;
in an embodiment, the migration list generating module 202 is configured to determine the virtual machine to be migrated of the source host according to the load balancing constraint condition by the following method:
sorting all the virtual machines on the source host from high to low according to the resource occupancy rate;
traversing each virtual machine from the virtual machine with the highest resource occupancy rate, and determining the virtual machine to be migrated which meets a first load balancing constraint condition and a second load balancing constraint condition;
wherein the first load balancing constraint condition comprises: the time interval of two times of migration of the same virtual machine is greater than or equal to the minimum time interval t; the second load balancing constraint condition comprises: the number of the virtual machines migrated by a single host in one scheduling period is less than or equal to the maximum value m;
in one embodiment, the resource occupancy of the virtual machine includes any one of: CPU occupancy rate, memory occupancy rate, and comprehensive occupancy rate of CPU and memory; the comprehensive occupancy rate of the CPU and the memory is as follows: carrying out weighted average on the CPU occupancy rate and the memory occupancy rate to obtain the occupancy rate;
in one embodiment, the migration module 203 is configured to migrate the virtual machine to be migrated of the source host to the destination host by: sequencing all virtual machines to be migrated on the source host from high to low according to the resource occupancy rate; traversing each virtual machine to be migrated from the virtual machine to be migrated with the highest resource occupancy rate, and determining a target host paired with each virtual machine to be migrated according to a load balancing strategy: sorting other hosts in a virtualization system where the source host is located according to loads from small to large for the virtual machines to be migrated which need to be paired currently, taking the host with the smallest load as a target host corresponding to the virtual machine to be migrated currently, and updating the load of the target host into the load added with the virtual machine to be migrated; and migrating each virtual machine to be migrated of the source host to a paired destination host.
In one embodiment, the migration module 203 is configured to start migrating the virtual machines to be migrated of the source host at the same time;
in one embodiment, the migration information of the virtual machine includes: identification of the virtual machine and migration time of the virtual machine.
The technical scheme of the embodiment of the invention can reasonably arrange the tasks of the virtual machine migration in a large-batch environment, thereby avoiding a large number of migration tasks or service jitter of certain virtual machines (service jitter caused by frequent migration) in the load balancing scheduling process.
Example 3
An embodiment of the present invention provides a load balancing apparatus in a virtualization system, including:
the load balancing program in the virtualization system realizes the steps of the load balancing method in the virtualization system when being executed by the processor.
The memory may be implemented, for example, by any type or combination of volatile and non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The processor may be a Central Processing Unit (CPU), a field programmable logic array (FPGA), a single chip Microcomputer (MCU), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), or other logic operation device with data processing capability and/or program execution capability.
The load balancing method of the present application is explained below by example 1.
Example 1
The present example provides a load balancing method in a virtualization system, which is directed to a virtualization system, and can reduce service jitter of a virtual machine in a load balancing process of the virtualization system and prevent system performance from decreasing.
As shown in fig. 3, a method for load balancing in a virtualization system may include the following steps:
step S301, configuring load balancing parameters, and setting load balancing constraint conditions according to the load balancing parameters;
wherein the load balancing parameters include: the maximum value m of the number of virtual machines migrated by a single host in one period and the minimum time interval t of two times of migration of the same virtual machine;
step S302, detecting whether a source host with a load exceeding a threshold exists in the virtualization system, if so, executing step S303, otherwise, executing step S302;
step S303, sorting the virtual machines on the source host from high to low according to the resource occupancy rate, and traversing the virtual machines from the virtual machine with the highest resource occupancy rate;
step S304, inquiring the migration records of the virtual machine, judging whether the virtual machine has corresponding records, if so, executing step S305, otherwise, executing step S306;
step S305, determining whether a time interval between the last migration time of the virtual machine and the current time is greater than or equal to the minimum time interval t, if so, executing step S306, otherwise, executing step S307;
step S306, determining the virtual machine as a virtual machine to be migrated;
step 307, judging whether the number n of virtual machines to be migrated of the source host is less than or equal to a maximum value m, if so, executing step 308, otherwise, executing step 310;
step S308, judging whether the virtual machine is the last virtual machine on the source host, if so, executing step S310, otherwise, executing step S309;
step S309, checking the next virtual machine, and returning to the step S304;
step S310, sorting all virtual machines to be migrated on the source host from high to low according to the resource occupancy rate;
step S311, traversing each virtual machine to be migrated from the virtual machine to be migrated with the highest resource occupancy rate, and determining a target host paired with each virtual machine to be migrated according to a load balancing strategy;
step S312, migrating each virtual machine to be migrated of the source host to a paired destination host;
in step S313, migration information of the virtual machine is recorded.
Wherein the migration information of the virtual machine comprises: identification of the virtual machine and migration time of the virtual machine.
According to the load balancing method, the maximum value m of the number of the virtual machines migrated by a single host in one period and the minimum time interval t of two times of migration of the same virtual machine are set, and the system reasonably arranges tasks of the virtual machines to be migrated in a large-batch environment according to the two parameters, so that a large number of migration tasks or service jitter of certain virtual machines (service jitter caused by frequent migration) in the load balancing scheduling process is avoided.
It should be noted that the present invention can be embodied in other specific forms, and various changes and modifications can be made by those skilled in the art without departing from the spirit and scope of the invention.