A method, device and electronic device for dynamic migration of virtual machines
By identifying and limiting the rate limit of target threads with large amount of dirty page generation during virtual machine migration, the problem of excessively fast dirty page generation in virtual machine dynamic migration is solved, and the smooth completion of the migration and the normal operation of customer business is achieved.
Patent Information
- Application Number
- CN202210567363.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-05-23
AI Technical Summary
During the dynamic migration of virtual machines, the speed of dirty page generation is too fast, resulting in the migration failure, affecting the normal operation of the customer's business process.
By adjusting the count value, identify the target threads that affect the migration of virtual machine data, and use preset tools to increase the speed limit for these target threads to reduce the amount of dirty page generation.
While ensuring the smooth progress of dynamic migration of virtual machines, it reduces the impact on customer business and improves business availability during data migration.
Smart Images

Figure CN115033341B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a method, device and electronic device for dynamic migration of a virtual machine. Background Art
[0002] Virtual dynamic migration means that virtual machines are migrated between different physical hosts while ensuring the normal operation of customer services on the virtual machines. There is only a very short downtime during the migration process, and for customer services themselves, users do not feel the interruption of service. The process of virtual machine dynamic migration is usually accompanied by the generation of dirty pages, and the generation speed of dirty pages will affect the speed of virtual machine dynamic migration. If the generation speed of dirty pages is too fast and the transmission bandwidth is not large enough, the dynamic migration of virtual machines cannot be completed.
[0003] In order to solve the above problems, existing solutions are usually implemented by suppressing the generation speed of dirty pages, such as the method of dynamic migration of virtual machines based on the automatic convergence auto-converge function module of the simulated processor qemu-virtual machine (kernel-based virtual machine, kvm). The amount of data migrated each time during the dynamic migration of virtual machines is limited, and it often takes multiple rounds of migration to succeed. If two consecutive rounds of data migration do not converge, where non-convergence indicates that the amount of dirty pages generated in the previous round of data migration is greater than or equal to half of the amount of migrated data, it will affect the data migration speed. Therefore, qemu will reduce the running speed of the virtual machine and reduce the operation of writing memory, so that the dirty page generation speed is reduced. At the same time, auto-converge will continue to increase the usage limit of the virtual central processing unit (Virtual Central Processing Unit, VCPU) until the dynamic migration of kvm is successful.
[0004] With this type of dynamic migration of virtual machines, as the VCPU usage limit increases, the VCPU maximum rate may eventually reach 99%, which will seriously affect the customer business processes running on the virtual machine and even cause a crash. Summary of the invention
[0005] The present application discloses a method, device and electronic device for dynamic migration of a virtual machine, which ensures the success of dynamic migration of the virtual machine while taking into account the customer business process on the virtual machine, thereby improving the business availability during data migration.
[0006] In a first aspect, the present application provides a method for dynamic migration of a virtual machine, the method comprising:
[0007] When it is determined that the previous round of data migration did not converge, adjusting the count value, wherein the count value represents the number of consecutive non-convergence times;
[0008] When the count value is equal to the preset value, identifying each target thread that affects the virtual machine data migration in each current service thread;
[0009] After increasing the speed limit for each target thread using a preset tool, data migration for the virtual machine continues.
[0010] Through the above method, the speed limit of the target thread that affects the data migration of the virtual machine is increased, so that during the data migration process, the amount of dirty pages generated corresponding to the target thread is reduced, thereby ensuring the smooth progress of the dynamic migration of the virtual machine while taking into account the customer business process on the virtual machine, thereby improving the business availability during the data migration process.
[0011] In a possible design, determining that the previous round of data migration does not converge includes:
[0012] Get the amount of dirty pages generated and the amount of data migrated corresponding to the previous round of data migration;
[0013] Determine whether the dirty page generation amount is greater than or equal to half of the data migration amount;
[0014] If not, determining that the previous round of data migration has converged;
[0015] If so, it is determined that the previous round of data migration did not converge.
[0016] Through the above method, it is possible to determine whether the previous round of data migration has converged, and then to determine whether the next round of data migration can be successfully completed.
[0017] In a possible design, before determining that the previous round of data migration does not converge, the method further includes:
[0018] Determine each VCPU that executes each service thread during the virtual machine data migration process;
[0019] Adjusting each VCPU according to preset parameters, wherein the preset parameters at least include a first rate limit;
[0020] Based on each VCPU after adjusting the parameters, data migration is performed on the virtual machine.
[0021] Through the above method, the execution process of each business thread is initially restricted during the virtual machine data migration process, which is suitable for the scenario where the dirty page generation speed is not fast, and at the same time can ensure the normal operation of customer business.
[0022] In a possible design, identifying each target thread affecting the virtual machine data migration in each current service thread includes:
[0023] Detect the memory usage percentage corresponding to each current business thread;
[0024] Sort all memory usage percentages in descending order to get the sorting result;
[0025] Determine the service threads corresponding to the top N memory usage percentages in the sorting result as the target threads, respectively, where N is an integer greater than or equal to 1; or
[0026] Compare all memory usage percentages with the preset thresholds to obtain comparison results;
[0027] The business threads corresponding to the respective memory usage percentages greater than the preset threshold in the comparison results are respectively determined as the target threads.
[0028] Through the above method, the target threads that affect the virtual machine migration process are determined, so as to further restrict the operation process of these target threads, thereby improving the virtual machine migration efficiency and ensuring the normal operation of non-target services.
[0029] In a possible design, after increasing the speed limit of each target thread using a preset tool, continuing to migrate data for the virtual machine includes:
[0030] Limiting each target thread according to a second rate limit, wherein the second rate limit is greater than the first rate limit;
[0031] The speed of each non-target thread in the virtual machine data migration process is limited according to the preset parameters, wherein the non-target thread is a service thread other than the target thread in the service threads.
[0032] Through the above method, the rate limit of the target thread is greater than the rate limit of the non-target thread, thereby reducing the amount of dirty pages generated, thereby ensuring that the dynamic migration of the virtual machine is completed smoothly while reducing the impact on customer business.
[0033] In a possible design, after continuing to migrate data on the virtual machine, the method further includes:
[0034] Calculate the remaining data migration amount of all service threads of the virtual machine;
[0035] Determine whether the remaining data migration amount is less than the amount of data that can be transmitted within a preset time period, wherein the preset time period is a virtual machine suspension time period;
[0036] If yes, pausing the virtual machine within the preset time period and completing the last data migration for each service thread;
[0037] Otherwise, continue with the next round of data migration for the virtual machine.
[0038] Through the above method, data migration is completed for the virtual machine. For the customer business itself, the user does not feel the service interruption, which helps to reduce the impact on the customer business.
[0039] In a possible design, after the last data migration of each service thread is completed, the method further includes:
[0040] Determine whether each target thread is speed-limited;
[0041] If any target thread is speed-limited, the speed limit on the target thread is released.
[0042] Through the above method, after the dynamic migration of the virtual machine is completed, the speed limit processing of the target thread is ended.
[0043] In a second aspect, the present application provides a virtual machine dynamic migration device, the device comprising:
[0044] A first determination module is used to adjust a count value when it is determined that the previous round of data migration did not converge, wherein the count value represents the number of consecutive non-convergence times;
[0045] An identification module, used for identifying each target thread affecting the virtual machine data migration in each current service thread when the count value is equal to a preset value;
[0046] The first migration module is used to increase the speed limit of each target thread using a preset tool and then continue to migrate data on the virtual machine.
[0047] In a possible design, the first determining module is further configured to:
[0048] Get the amount of dirty pages generated and the amount of data migrated corresponding to the previous round of data migration;
[0049] Determine whether the dirty page generation amount is greater than or equal to half of the data migration amount;
[0050] If not, determining that the previous round of data migration has converged;
[0051] If so, it is determined that the previous round of data migration did not converge.
[0052] In one possible design, the device further includes:
[0053] A second determination module is used to determine each VCPU that executes each service thread during the virtual machine data migration process;
[0054] An adjustment module, configured to adjust each VCPU according to preset parameters, wherein the preset parameters at least include a first rate limit;
[0055] The second migration module is used to migrate data of the virtual machine based on each VCPU after adjusting the parameters.
[0056] In a possible design, the identification module is specifically used for:
[0057] Detect the memory usage percentage corresponding to each current business thread;
[0058] Sort all memory usage percentages in descending order to get the sorting result;
[0059] Determine the service threads corresponding to the top N memory usage percentages in the sorting result as the target threads, respectively, where N is an integer greater than or equal to 1; or
[0060] Compare all memory usage percentages with the preset thresholds to obtain comparison results;
[0061] The business threads corresponding to the respective memory usage percentages greater than the preset threshold in the comparison results are respectively determined as the target threads.
[0062] In a possible design, the first migration module is specifically configured to:
[0063] Limiting each target thread according to a second rate limit, wherein the second rate limit is greater than the first rate limit;
[0064] The speed of each non-target thread in the virtual machine data migration process is limited according to the preset parameters, wherein the non-target thread is a service thread other than the target thread in the service threads.
[0065] In one possible design, the device further includes:
[0066] A calculation module is used to calculate the remaining data migration amount of all service threads of the virtual machine;
[0067] A first judgment module is used to judge whether the remaining data migration amount is less than the amount of data that can be transmitted within a preset time period, wherein the preset time period is a virtual machine suspension time period;
[0068] The first processing module is used to suspend the virtual machine within the preset time period and complete the last data migration for each business thread if the remaining data migration amount is less than the data transferable within the preset time period; otherwise, continue the next round of data migration for the virtual machine.
[0069] In one possible design, the device further includes:
[0070] The second judgment module is used to judge whether each target thread is speed-limited;
[0071] The second processing module is used for releasing the speed limit of any target thread if any target thread is speed-limited.
[0072] In a third aspect, the present application provides an electronic device, including:
[0073] Memory, used to store computer programs;
[0074] The processor is used to implement the above-mentioned virtual machine dynamic migration method steps when executing the computer program stored in the memory.
[0075] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned virtual machine dynamic migration method steps are implemented.
[0076] Based on the above virtual machine dynamic migration method, the speed limit of the target thread that affects the virtual machine data migration is increased, so that during the data migration process, the amount of dirty pages generated corresponding to the target thread is reduced. This ensures the smooth progress of the virtual machine dynamic migration while taking into account the customer business process on the virtual machine, thereby improving the business availability during the data migration process.
[0077] The technical effects that can be achieved in each of the above-mentioned second to fourth aspects and each of the above-mentioned aspects refer to the technical effects that can be achieved in the above-mentioned first aspect or various possible schemes in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 One of the schematic diagrams of a virtual machine dynamic migration method provided in this application;
[0079] Figure 2 A flowchart of a method for dynamic migration of a virtual machine provided in this application;
[0080] Figure 3 A second schematic diagram of a method for dynamic migration of a virtual machine provided in this application;
[0081] Figure 4 A schematic diagram of the structure of a virtual machine dynamic migration device provided in this application;
[0082] Figure 5 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0083] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operating methods in the method embodiments can also be applied to device embodiments or system embodiments. It should be noted that in the description of the present application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A is connected to B, which can represent: A is directly connected to B and A is connected to B through C. In addition, in the description of the present application, words such as "first" and "second" are only used to distinguish the purpose of description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0084] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0085] The process of virtual machine dynamic migration is usually accompanied by the generation of dirty pages, and the generation speed of dirty pages will affect the speed of virtual machine dynamic migration. If the generation speed of dirty pages is too fast and the transmission bandwidth is not large enough, the dynamic migration of virtual machines cannot be completed. At this time, it is usually necessary to suppress the generation speed of dirty pages. The existing technology usually uses qemu-kvm to achieve this. Among them, virtual machine migration based on qemu-kvm is mainly divided into the following stages:
[0086] Starting stage: The source host checks whether the status of the virtual machine to be migrated meets the migration conditions, and checks whether the destination host is reachable and meets the migration conditions of the virtual machine to be migrated.
[0087] Preparation phase: First, the source host calls the rpc interface connected to the destination host libvirt to prepare for virtual machine migration. In this phase, the destination host is mainly responsible for starting a virtual machine to be migrated, setting the virtual machine to be migrated to a paused state, and then monitoring messages from the source host.
[0088] Execution phase: The source host is responsible for migrating the memory, device information, and disk data of the virtual machine to be migrated from the source host to the destination host.
[0089] Completion stage: The destination host is mainly responsible for starting the virtual machine that was previously in a suspended state. If the network block device (NBD) is used to migrate the disk, the NBD service needs to be stopped.
[0090] Confirmation phase: After the VM has been successfully started on the destination end, the source host stops the source VM and sends a migration completion event.
[0091] In the above virtual machine migration process, the auto-converge function module is usually started. The workflow of auto-converge can be referred to Figure 1 Before each round of data migration is officially started, the remaining amount of data to be transferred will be estimated, that is, the number of dirty pages generated by the virtual machine from the end of the previous round of data migration to the start of the new round of data migration is obtained from the KVM kernel. If the number of remaining dirty pages is less than the amount of data that can be copied at the previous round of copy rate within the allowed downtime, the operation of the virtual machine will be suspended, the remaining data will be copied, and the data migration iteration process will end and enter the completion stage; if the number of remaining dirty pages is greater than or equal to the amount of data that can be copied at the previous round of copy rate within the allowed downtime, the next round of data copy will continue.
[0092] While counting the amount of remaining data, the auto converge function module will check whether the data migration process has converged. Convergence means that the amount of dirty pages generated during the data migration process is less than half of the amount of migrated data. If the non-convergence lasts for two rounds, all VCPUs in the virtual machine will be limited. That is, before each iteration, if it is determined that the previous round of data migration cannot converge, the VCPU needs to be limited, and the limit is gradually increased by one step each time. In general, the limit rate starts from a speed limit of 20%, and increases by 10% step to a maximum of 99%.
[0093] In the above process, when the VCPU limit rate reaches a certain level, its dirty page generation rate will also be reduced to a convergent level, so that the migration can be completed in the end. However, in scenarios where the virtual machine has a large amount of memory, the dirty page generation rate is particularly fast, or the bandwidth capacity of the migration network on the source host is limited, the VCPU limit rate may reach 99%, making all services running on the virtual machine almost unavailable, or even causing the virtual machine to fail, which will seriously affect the customer service process running on the virtual machine, and even cause a crash.
[0094] In order to solve the above problems, the present application provides a method for dynamic migration of virtual machines, which increases the rate limit of the target thread that affects data migration, thereby reducing the amount of dirty pages generated by the target thread during data migration, which can not only ensure the smooth progress of dynamic migration of virtual machines, but also reduce the impact on customer services and improve service availability during data migration. Among them, the method and device described in the embodiments of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can refer to each other, and the repeated parts will not be repeated.
[0095] like Figure 2 FIG. 1 is a flowchart of a method for dynamic migration of a virtual machine provided by the present application, which specifically includes the following steps:
[0096] S21, when it is determined that the previous round of data migration is not convergent, adjusting the count value;
[0097] During the dynamic migration of a virtual machine, the amount of data migrated each time is limited, and multiple rounds of migration are often required to succeed. In an embodiment of the present application, the various VCPUs that execute various business threads during the virtual machine data migration process are first determined, and then each VCPU is adjusted according to preset parameters, wherein the preset parameters include an initial rate limit, an incremental step, and a first rate limit, and the first rate limit represents the maximum rate limit.
[0098] Furthermore, based on each VCPU after adjusting the parameters, data migration is performed on the virtual machine, wherein the first rate limit value corresponding to the adjusted parameters of the VCPU is 80%. Of course, fine-tuning can also be performed according to actual conditions, and then data migration is performed on each business thread based on each VCPU after adjusting the parameters.
[0099] In order to test the effect of adjusting the maximum rate limit of each VCPU to 80%, the following description is given in combination with a specific application scenario.
[0100] In this application scenario, the physical source host is configured as follows: CPU 2x8x2=32Intel(R)Xeon(R)CPU E5-26500@2.00GHz; MEM 16G*12=192G, CentOS Linux release 7.6.1810(Core); the migration virtual machine is configured as follows: 32 cores, 32G memory, CentOS Linux release 7.6.1810(Core); the virtual machine is pressurized by the qemu stress program, where the stress program generates 16G dirty memory data per second through 16 VCPUs, and the data migration network speed is limited to 100M.
[0101] Based on the above application scenario, the maximum rate limit of the VCPU corresponding to all business threads is set to 80%, and pressure is applied inside the virtual machine. That is, the memory pressure tool stress provided by qemu is used to write 16G of dirty memory data per second through 16 VCPUs.
[0102] Further, start hot migration of virtual machines. When it is found that the auto converge function module process has limited the speed of all VCPUs on the virtual machine to 80% during the virtual machine migration process, find out the memory noise thread in the virtual machine, that is, Figure 2 The target thread shown in the figure is selected, and the memory noise thread is specifically restricted, and the data migration status is queried. At this point, the virtual machine has been slowed down by 80%. The customer business completed the data migration within 12 minutes.
[0103] Furthermore, when the test environment and external stress conditions remained unchanged, qemu was changed to the original version and the same virtual machine migration test was performed. After a period of testing, due to the excessive generation of memory dirty pages, the speed of all VCPUs on the virtual machine was limited to 99%, resulting in the data migration process failing to succeed after four days of execution.
[0104] That is to say, after adjusting the maximum rate of each VCPU from 99% to 80%, it can ensure the successful migration of virtual machines while ensuring the normal operation of customer services. Specifically, the comparison results of dynamic migration of virtual machines corresponding to the original solution and the solution of this application are shown in Table 1:
[0105] Comparison plan Ping delay fio read and write unix bench score Migration Results Migration takes time This application plan 12.9ms 1146Kb / s 191.8 success 12 minutes Original plan 965ms 40.23Kb / s 4.9 fail More than 4 days
[0106] Table 1
[0107] As shown in Table 1, the corresponding ping delay of the solution in the embodiment of the present application is only 1.3% of that of the original solution, and the fio read and write speed is 28.5 times that of the original solution, and the unix bench score is more than 39 times that of the original solution, and the virtual machine migration time is only 12 minutes, while the original solution continued to migrate for 4 days and still failed. Therefore, the solution of the present application can greatly shorten the efficiency of dynamic migration of virtual machines.
[0108] However, in a possible application scenario, if there is a business thread that produces dirty pages at a fast speed, further processing is required based on the above.
[0109] Specifically, during the data migration process, after the previous round of data migration is completed, it is necessary to determine whether the previous round of data migration did not converge. The specific judgment method is: obtain the dirty page generation amount and data migration amount corresponding to the previous round of data migration, and determine whether the dirty page generation amount is greater than or equal to half of the data migration amount; if not, it is determined that the previous round of data migration converged; if so, it is determined that the previous round of data migration did not converge.
[0110] When it is determined that the last round of data migration did not converge, the count value is adjusted, wherein the count value represents the number of consecutive non-convergence times. If the last round of data migration converges, the count value is cleared to 0 and counting starts again.
[0111] S22, when the count value is equal to the preset value, identifying each target thread that affects the virtual machine data migration in each current service thread;
[0112] In an embodiment of the present application, if the count value is equal to the preset value, it indicates that the dirty page generation speed in the current scene is relatively fast, wherein the preset value is generally 2, and of course it can also be adjusted according to the actual situation. In this case, the VCPU parameters corresponding to each current business thread are difficult to meet the virtual machine migration requirements, wherein the VCPU parameters include the VCPU rate limit starting value, the increase step size, and the maximum rate limit. If the data migration of each business thread continues according to the current VCPU parameters, it will affect the speed of the dynamic migration of the virtual machine. If the dirty page generation speed is too fast and the transmission bandwidth is not large enough, then the dynamic migration of the virtual machine cannot be completed.
[0113] In order to solve the above problem, in an embodiment of the present application, it is considered to restrict the target service threads with large virtual machine memory usage and fast dirty page generation speed. These target threads have a great impact on the speed of virtual machine migration. The specific method of identifying each target thread in all service threads can be:
[0114] Detect the memory usage percentage corresponding to each current business thread;
[0115] Sort all memory usage percentages in descending order to get the sorting result;
[0116] The business threads corresponding to the top N memory usage ratios in the sorting results are respectively determined as target threads, where N is an integer greater than or equal to 1.
[0117] Of course, the specific method for identifying each target thread among all business threads can also be:
[0118] Detect the memory usage percentage corresponding to all business threads in the virtual machine;
[0119] Compare all memory usage percentages with the preset thresholds to obtain comparison results;
[0120] The business threads corresponding to the respective memory usage percentages greater than a preset threshold in the comparison results are respectively determined as target threads.
[0121] In actual application, the above identification process can be implemented using commands such as ps, such as ps-aux, sort-k4nr, head-n3, etc.
[0122] Through the above method, target threads with large dirty page generation during virtual machine migration are determined, so as to further restrict the operation of these target threads, thereby improving the efficiency of virtual machine migration and reducing the impact on customer users.
[0123] S23, after increasing the speed limit of each target thread using a preset tool, continue to migrate data for the virtual machine.
[0124] After identifying each target thread, each target thread is limited using a preset tool, such as cpulimit. During the limiting process, the rate limit of the target thread can be directly set to the second rate limit, wherein the second rate limit is greater than the first rate limit corresponding to each non-target thread during the virtual machine data migration process, wherein the non-target thread is a service thread other than the target thread in each service thread. The rate limit of the target thread can also be gradually increased according to an initial rate limit until the maximum rate is the second rate limit.
[0125] For example, if the VCPU parameters of the current non-target thread are: rate limit starting value 20%, increment step 10%, and first rate limit 80%, then the rate limit of the target thread can be increased from 80% to 99% in increments of 10%. The specific value of the second rate limit can be adjusted according to the dirty page generation speed and memory usage ratio of the target thread.
[0126] After increasing the speed limit of each target thread, further, each non-target thread in the virtual machine data migration process is speed-limited according to preset parameters.
[0127] Specifically, during the data migration process corresponding to each service thread, if it is estimated that the rate limit corresponding to the current VCPU will cause the current data migration to not converge, the VCPU rate limit is adjusted according to the incremental step corresponding to the current VCPU, and it is continuously estimated whether the rate limit corresponding to the VCPU after the modified parameters will cause the current data migration to not converge, until it is estimated that the rate limit corresponding to the modified VCPU can successfully complete the current data migration, at which point the modified VCPU parameters are the preset parameters. At the same time, the preset parameters can also be dynamically adjusted in real time according to the number of VCPUs of the current virtual machine and the data migration status.
[0128] For example, the rate limit of each target thread is set to start at 50%, increase the step size by 10%, and set the maximum rate limit to 99%; the rate limit of each VCPU parameter corresponding to each non-target thread is set to start at 20%, increase the step size by 10%, and set the maximum rate limit to 80%. In this case, since the maximum rate limit of the target thread reaches 99%, the dirty page generation speed of the target thread can be effectively suppressed. At the same time, since the maximum rate limit of each VCPU parameter corresponding to the non-target business is 80%, the normal operation of the customer business can be effectively supported.
[0129] Through the above method, the rate limit of the target thread is greater than the rate limit of the non-target thread, thereby reducing the amount of dirty pages generated, thereby ensuring that the dynamic migration of the virtual machine is completed smoothly while reducing the impact on customer business.
[0130] After the current data migration is completed, the remaining data migration amount of all service threads of the virtual machine is further calculated, and it is determined whether the remaining data migration amount is less than the amount of data that can be transmitted within the preset time period, wherein the preset time period is the virtual machine suspension time period, which is generally short, and for the customer service itself, the user does not feel the interruption of the service. If the remaining data migration amount is less than the amount of data that can be transmitted within the preset time period, the virtual machine is suspended within the preset time period, and the last data migration is completed for each service thread; otherwise, the next round of data migration is continued for the virtual machine.
[0131] Through the above method, the data migration of the virtual machine is completed. For the customer business itself, the user does not feel the service interruption, which helps to ensure the normal operation of the customer business.
[0132] Furthermore, after pausing the virtual machine, it is further necessary to determine whether the restriction program of the target thread is closed, that is, to determine whether each target thread is speed-limited. In an embodiment of the present application, when the target thread identification and restriction process is triggered, a flag will be set. This flag is used to determine whether the current speed limit tool is closed after the virtual machine data migration is completed; if any target thread is speed-limited, the speed limit on any target thread is lifted and the virtual machine migration task is terminated; otherwise, the virtual machine migration task is terminated directly.
[0133] In this way, after the dynamic migration of the virtual machine is completed, the rate limit of the target thread is adjusted to be consistent with the first rate limit of the non-target thread, so as to prepare for the next dynamic migration of the virtual machine.
[0134] Based on the above virtual machine dynamic migration method, the speed limit of the target thread that affects the virtual machine data migration is increased, so that during the data migration process, the amount of dirty pages generated corresponding to the target thread is reduced. This ensures the smooth progress of the virtual machine dynamic migration while taking into account the customer business process on the virtual machine, thereby improving the business availability during the data migration process.
[0135] In order to further elaborate on the above virtual machine dynamic migration method, Figure 3 The above virtual machine dynamic migration method is further described.
[0136] By Figure 3 and Figure 2 By comparison, it can be seen that when the current data migration is estimated to be non-convergent, the present application is different from the prior art in that, according to the virtual machine dynamic migration method of the present application, the VCPU parameters corresponding to all business threads are first adjusted, that is, the use of the VCPU is restricted, and the restriction is gradually increased by one restriction step each time. In general, the restriction rate starts from a speed limit of 20%, and increases by 10% step to a maximum of 80%.
[0137] In the above case, if the VCPU corresponding to each business thread uses the rate limit of 80% for two consecutive times, it indicates that the current memory dirty page generation speed is relatively fast. At this time, the target threads with large memory usage and fast memory dirty page generation rate in each business thread are identified. And the restrictions on the identified target threads are increased, so that the initial rate limit of the target thread is 50%, the incremental step is 10%, and the maximum rate limit is 99%. In this way, the rate limit of the target thread can be increased in a targeted manner, thereby ensuring the normal operation of the customer's business.
[0138] In addition, by Figure 3 It can also be known that after the dynamic migration of the virtual machine is completed, the rate limit of the target thread needs to be adjusted to be consistent with the rate limit corresponding to the non-target thread, that is, the target thread limit program needs to be turned off.
[0139] Based on the same inventive concept, the present application also provides a virtual machine dynamic migration device, such as Figure 4 FIG. 1 is a schematic diagram of a structure of a virtual machine dynamic migration device in the present application, the device comprising:
[0140] A first determination module 41 is used to adjust a count value when it is determined that the previous round of data migration did not converge, wherein the count value represents the number of consecutive non-convergence times;
[0141] An identification module 42, configured to identify, in each current service thread, each target thread that affects the migration of virtual machine data when the count value is equal to a preset value;
[0142] The first migration module 43 is used to increase the speed limit of each target thread using a preset tool and then continue to migrate data on the virtual machine.
[0143] In a possible design, the first determining module 41 is further configured to:
[0144] Get the amount of dirty pages generated and the amount of data migrated corresponding to the previous round of data migration;
[0145] Determine whether the dirty page generation amount is greater than or equal to half of the data migration amount;
[0146] If not, determining that the previous round of data migration has converged;
[0147] If so, it is determined that the previous round of data migration did not converge.
[0148] In one possible design, the device further includes:
[0149] A second determination module is used to determine each VCPU that executes each service thread during the virtual machine data migration process;
[0150] An adjustment module, configured to adjust each VCPU according to preset parameters, wherein the preset parameters at least include a first rate limit;
[0151] The second migration module is used to migrate data of the virtual machine based on each VCPU after adjusting the parameters.
[0152] In a possible design, the identification module 42 is specifically used for:
[0153] Detect the memory usage percentage corresponding to each current business thread;
[0154] Sort all memory usage percentages in descending order to get the sorting result;
[0155] Determine the service threads corresponding to the top N memory usage percentages in the sorting result as the target threads, respectively, where N is an integer greater than or equal to 1; or
[0156] Compare all memory usage percentages with the preset thresholds to obtain comparison results;
[0157] The business threads corresponding to the respective memory usage percentages greater than the preset threshold in the comparison results are respectively determined as the target threads.
[0158] In a possible design, the first migration module 43 is specifically configured to:
[0159] Limiting each target thread according to a second rate limit, wherein the second rate limit is greater than the first rate limit;
[0160] The speed of each non-target thread in the virtual machine data migration process is limited according to the preset parameters, wherein the non-target thread is a service thread other than the target thread in the service threads.
[0161] In one possible design, the device further includes:
[0162] A calculation module is used to calculate the remaining data migration amount of all service threads of the virtual machine;
[0163] A first judgment module is used to judge whether the remaining data migration amount is less than the amount of data that can be transmitted within a preset time period, wherein the preset time period is a virtual machine suspension time period;
[0164] The first processing module is used to suspend the virtual machine within the preset time period and complete the last data migration for each business thread if the remaining data migration amount is less than the data transferable within the preset time period; otherwise, continue the next round of data migration for the virtual machine.
[0165] In one possible design, the device further includes:
[0166] The second judgment module is used to judge whether each target thread is speed-limited;
[0167] The second processing module is used for releasing the speed limit of any target thread if any target thread is speed-limited.
[0168] Based on the above-mentioned virtual machine dynamic migration device, the maximum rate of the VCPU corresponding to the target thread that affects data migration is increased, so that during the data migration process, the amount of dirty pages generated corresponding to the target thread is reduced, which can not only ensure the smooth dynamic migration of the virtual machine, but also will not affect the customer business corresponding to the non-target thread, thereby improving the business availability during the data migration process.
[0169] Based on the same inventive concept, an electronic device is also provided in the embodiment of the present application, and the electronic device can implement the functions of the aforementioned virtual machine dynamic migration method and device, referring to Figure 5 , the electronic device comprises:
[0170] At least one processor 51, and a memory 52 connected to the at least one processor 51. The specific connection medium between the processor 51 and the memory 52 is not limited in the embodiment of the present application. Figure 5 In the example, the processor 51 and the memory 52 are connected via a bus 50. The bus 50 is Figure 5 The connection between other components is shown by bold lines, and the connection between other components is only for schematic illustration and is not intended to be limiting. The bus 50 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 51 can also be called a controller, and there is no limitation on the name.
[0171] In the embodiment of the present application, the memory 52 stores instructions that can be executed by at least one processor 51. The at least one processor 51 can execute the virtual machine dynamic migration method discussed above by executing the instructions stored in the memory 52. The processor 51 can implement Figure 4 The functions of each module in the device shown.
[0172] Among them, the processor 51 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 52 and calling data stored in the memory 52, the various functions of the device and processing data, the device can be monitored as a whole.
[0173] In a possible design, the processor 51 may include one or more processing units, and the processor 51 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 51. In some embodiments, the processor 51 and the memory 52 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0174] The processor 51 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the virtual machine dynamic migration method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0175] The memory 52 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 52 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 52 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 52 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0176] By programming the processor 51, the code corresponding to the method for dynamic migration of virtual machines described in the above embodiment can be fixed into the chip, so that the chip can execute the code when running. Figure 1The steps of the virtual machine dynamic migration method of the embodiment shown are as follows: How to design and program the processor 51 is a technology well known to those skilled in the art and will not be described in detail here.
[0177] Based on the same inventive concept, an embodiment of the present application further provides a storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the virtual machine dynamic migration method discussed above.
[0178] In some possible implementations, various aspects of the virtual machine dynamic migration method provided in the present application can also be implemented in the form of a program product, which includes program code. When the program product is run on an apparatus, the program code is used to enable the control device to execute the steps of the virtual machine dynamic migration method according to various exemplary embodiments of the present application described above in this specification.
[0179] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0180] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0183] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for dynamic migration of a virtual machine, characterized in that: The method comprises: Determine each VCPU that executes each service thread during the virtual machine data migration process; Adjusting each VCPU according to preset parameters, wherein the preset parameters at least include a first rate limit; Based on each VCPU after adjusting parameters, data migration is performed on the virtual machine; When it is determined that the previous round of data migration did not converge, adjusting the count value, wherein the count value represents the number of consecutive non-convergence times; When the count value is equal to the preset value, identifying each target thread that affects the virtual machine data migration in each current service thread; Limiting each target thread according to a second rate limit, wherein the second rate limit is greater than the first rate limit; The speed of each non-target thread in the process of virtual machine data migration is limited according to the preset parameters, and the data migration of the virtual machine is continued.
2. The method according to claim 1, characterized in that The identifying each target thread affecting the virtual machine data migration in each current service thread includes: Detect the memory usage percentage corresponding to each current business thread; Sort all memory usage percentages in descending order to get the sorting result; Determine the service threads corresponding to the top N memory usage percentages in the sorting result as the target threads, respectively, where N is an integer greater than or equal to 1; or Compare all memory usage percentages with the preset thresholds to obtain comparison results; The business threads corresponding to the respective memory usage percentages greater than the preset threshold in the comparison results are respectively determined as the target threads.
3. The method according to claim 1, characterized in that The non-target thread is a service thread other than the target thread in the service threads.
4. The method according to claim 1, characterized in that After continuing to migrate data on the virtual machine, the method further includes: Calculate the remaining data migration amount of all service threads of the virtual machine; Determine whether the remaining data migration amount is less than the amount of data that can be transmitted within a preset time period, wherein the preset time period is a virtual machine suspension time period; If yes, pausing the virtual machine within the preset time period and completing the last data migration for each service thread; Otherwise, continue the virtual machine for the next round of data migration.
5. The method according to claim 4, characterized in that After the last data migration of each service thread is completed, the method further includes: Determine whether each target thread is speed-limited; If any target thread is speed-limited, the speed limit on the target thread is released.
6. A virtual machine dynamic migration device, characterized in that: The device comprises: A determination module, used to determine each VCPU executing each service thread during the virtual machine data migration process; Adjusting each VCPU according to preset parameters, wherein the preset parameters at least include a first rate limit; Based on each VCPU after adjusting parameters, data migration is performed on the virtual machine; When it is determined that the previous round of data migration did not converge, adjusting the count value, wherein the count value represents the number of consecutive non-convergence times; An identification module, used for identifying each target thread affecting the virtual machine data migration in each current service thread when the count value is equal to a preset value; A first migration module, configured to limit each target thread according to a second rate limit, wherein the second rate limit is greater than the first rate limit; The speed of each non-target thread in the process of virtual machine data migration is limited according to the preset parameters, and the data migration of the virtual machine is continued.
7. The device according to claim 6, characterized in that The identification module is specifically used for: Detect the memory usage percentage corresponding to each current business thread; Sort all memory usage percentages in descending order to get the sorting result; Determine the service threads corresponding to the top N memory usage percentages in the sorting result as the target threads, respectively, where N is an integer greater than or equal to 1; or Compare all memory usage percentages with the preset thresholds to obtain comparison results; The business threads corresponding to the respective memory usage percentages greater than the preset threshold in the comparison results are respectively determined as the target threads.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method steps of any one of claims 1 to 5 when executing the computer program stored in the memory.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Virtual machine live migration method and device and storage medium
CN114443211A