A virtual machine hot migration method, device, electronic device and storage medium
By generating iterative record tables and using prediction models to predict the remaining time of virtual machine migration, adjusting virtual machine running information to reduce the generation of dirty pages of memory, solving the problems of long hot migration time and low success rate of virtual machines, achieving a faster and more reliable migration process.
Patent Information
- Application Number
- CN202210658109.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-10
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2042-06-10
AI Technical Summary
Existing virtual machine hot migration methods last longer during the migration process and may even fail, especially when memory-intensive virtual machines are migrating across physical hosts.
The remaining migration time is predicted by generating iteration record tables and processing the iteration record tables and the running data of the target virtual machine using a pre-trained prediction model. If the predicted remaining migration time is too long, adjust the running information of the target virtual machine to reduce the generation of dirty pages in memory, thereby shortening the migration time.
It effectively shortens the time for hot migration of virtual machines, improves the success rate of migration, and reduces the impact on business.
Smart Images

Figure CN115048183B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a virtual machine hot migration method, device, electronic device and storage medium. Background Art
[0002] In the management and daily maintenance of cloud computing, in order to balance the load of cloud data centers, to achieve the purpose of efficient use of physical resources and physical machine failure repair, it is necessary to migrate virtual machines across physical nodes.
[0003] The types of virtual machine migration are mainly divided into cold migration and hot migration. In some business scenarios, the business running on the virtual machine cannot be interrupted. At this time, hot migration technology is needed to complete the migration of the virtual machine with millisecond-level interruption, thereby greatly reducing the impact on the business.
[0004] During the hot migration process of a virtual machine, since its central processing unit (CPU) is in operation, the memory data is constantly changing. Using traditional hot migration methods will result in a long hot migration time or even migration failure. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a virtual machine hot migration method, device, electronic device and storage medium, so as to shorten the time of virtual machine hot migration.
[0006] In a first aspect, an embodiment of the present application provides a method for hot migration of a virtual machine, comprising: copying the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtaining a migration information variable; the migration information variable includes the memory page dirty data ratio and the memory page address of each memory page; determining an iteration record table according to the memory page dirty data ratio and the memory page address; using a pre-trained prediction model to process the iteration record table and the operating data of the target virtual machine to obtain the remaining migration time output by the prediction model; if the remaining migration time is greater than the preset time, adjusting the operating information of the target virtual machine so that the target virtual machine reduces the number of memory dirty pages generated, and continuing to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine are migrated to the destination host.
[0007] The embodiment of the present application uses a prediction model to predict the remaining migration time of the target virtual machine. If the remaining migration time is too long, the operating information of the target virtual machine is adjusted to reduce the newly generated memory data to be migrated during the migration process of the target virtual machine, thereby shortening the time required to migrate the virtual machine.
[0008] In any embodiment, the hot migration algorithm is used to copy the memory page data to be migrated of the target virtual machine in the source host to the destination host, including: obtaining the memory page data to be migrated; if the cache area in the source host contains a memory page corresponding to the memory page data to be migrated, then determining the update data based on the migrated memory page data corresponding to the memory page and the memory page data to be migrated; and copying the updated data to the destination host.
[0009] The embodiment of the present application determines the updated data and transmits only the updated data, which greatly reduces the amount of data required to be transmitted, thereby speeding up the speed at which the virtual machine completes the migration.
[0010] In any embodiment, determining the update data according to the migrated memory page data and the to-be-migrated memory page data corresponding to the memory page includes: performing XOR encoding on the migrated memory page data and the to-be-migrated memory page data to obtain the update data.
[0011] The embodiment of the present application obtains updated data by XOR encoding the migrated memory page data and the memory page data to be migrated. During the migration process, only the updated data is transmitted, which greatly reduces the amount of data required to be transmitted, thereby speeding up the virtual machine migration.
[0012] In any embodiment, determining the iteration record table according to the memory page dirty data ratio and the memory page address includes: generating a corresponding memory page update record table according to the memory page dirty data ratio and the memory page address of each memory page data to be migrated; and obtaining the iteration record table according to all the memory page update record tables.
[0013] The embodiment of the present application generates an iteration record table and uses the iteration record table as a factor for predicting the remaining migration duration, thereby improving the accuracy of the prediction of the remaining migration duration.
[0014] In any embodiment, the iteration record table includes at least one of the dirty page position matching degree, the dirty page update ratio, the average memory page data change ratio, the median memory page data change ratio, the maximum value of the memory page data change ratio, and the minimum value of the memory page data change ratio; the memory page update record table includes a dirty mark bit and a memory page data change ratio, and the dirty mark bit is used to indicate whether the memory page corresponding to the corresponding memory page data to be migrated is a memory dirty page;
[0015] The method of obtaining an iteration record table based on all memory page update record tables includes: determining the dirty page position matching degree according to the number of pages to be migrated corresponding to the current iteration migration and the previous iteration migration respectively and the number of memory page addresses being the same; determining the number of the first memory dirty pages in the current iteration migration according to the mark bit, and determining the dirty page update ratio according to the first number of memory dirty pages and the second number of memory dirty pages in the previous iteration migration; determining the average memory page data change ratio, the median memory page data change ratio, the maximum memory page data change ratio and the minimum memory page data change ratio according to the memory page data change ratio corresponding to each memory page to be migrated.
[0016] Each parameter in the iteration record table in the embodiment of the present application is a factor that affects the remaining migration time. Therefore, through the above calculation of each parameter, a data basis is provided for the prediction of the remaining migration time.
[0017] In any embodiment, the operating data includes at least one of the virtual machine CPU operating efficiency, the network transmission rate and the total amount of virtual machine memory; the iteration record table and the operating data of the target virtual machine are processed using a pre-trained prediction model to obtain the remaining migration time output by the prediction model, including: inputting the iteration record table and the operating data of the target virtual machine into the prediction model to obtain the remaining migration time output by the prediction model.
[0018] In the embodiment of the present application, since the iteration record table and the operating data of the target virtual machine will affect the remaining migration time, the accuracy of the remaining migration time prediction is improved based on the iteration record table and the operating data of the target virtual machine.
[0019] In any embodiment, adjusting the operation information of the target virtual machine includes:
[0020] Reduce the CPU speed of the target VM.
[0021] The embodiment of the present application reduces the operating speed of the CPU of the target virtual machine to reduce the number of dirty memory pages generated by the target virtual machine during the migration process, thereby shortening the time required for the migration.
[0022] In any embodiment, the method also includes: obtaining training data; the training data includes a training iteration record table, training operation parameters and a remaining training migration time; using the training iteration record table and the training operation parameters as inputs of the neural network model to be trained to obtain a prediction result output by the neural network model to be trained; optimizing the parameters in the neural network model to be trained according to the prediction result and the remaining training migration time to obtain a trained prediction model.
[0023] The embodiment of the present application trains the neural network model to be trained, obtains a prediction model and uses the prediction model to predict the remaining migration time of the target virtual machine. If the remaining migration time is too long, the running speed of the target virtual machine is reduced, thereby reducing the newly generated memory data to be migrated by the target virtual machine during the migration process, thereby shortening the time required to migrate the virtual machine.
[0024] In the second aspect, an embodiment of the present application provides a virtual machine hot migration device, including: an information acquisition module, used to copy the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtain migration information variables; the migration information variables include the memory page dirty data ratio and memory page address of each memory page; an iteration record table determination module, used to determine the iteration record table according to the memory page dirty data ratio and the memory page address; a prediction module, used to use a pre-trained prediction model to process the iteration record table and the operating data of the target virtual machine to obtain the remaining migration time output by the prediction model; an information adjustment module, used to adjust the operating information of the target virtual machine if the remaining migration time is greater than the preset time, so that the target virtual machine reduces the number of memory dirty pages generated, and continues to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine are migrated to the destination host.
[0025] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory and a bus, wherein the processor and the memory communicate with each other through the bus; the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method of the first aspect.
[0026] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium, comprising: the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method of the first aspect.
[0027] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 A schematic diagram of a virtual machine hot migration method provided in an embodiment of the present application;
[0030] Figure 2 A schematic diagram of another virtual machine migration method provided in an embodiment of the present application;
[0031] Figure 3 A schematic diagram of a neural network structure provided in an embodiment of the present application;
[0032] Figure 4 A schematic diagram of another virtual machine hot migration method flow chart provided in an embodiment of the present application;
[0033] Figure 5 A schematic diagram of the structure of a virtual machine hot migration device provided in an embodiment of the present application;
[0034] Figure 6 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] At present, the migration of memory data is mainly achieved through iterative copying. The basic principle is: in the first iterative migration, all memory data in the virtual machine at the current time is copied to the destination host; it is understandable that during the copying process, since the virtual machine is still in operation, new memory data will be generated. At this time, a second iterative migration is required, that is, the newly generated memory data is copied to the destination host again; this cycle is repeated until the newly generated data can be copied once and in a short time, the virtual machine operation is suspended (milliseconds), and the newly generated memory data is copied to the destination host.
[0036] The memory data copied each time is in paging as the smallest unit. The specific process of the above hot migration is as follows:
[0037] Step 1: Enable memory dirty page tracking. It can be understood that a memory dirty page refers to a memory page after copying, and the memory data contained in it has changed. The memory page whose memory data in the virtual machine has changed is called a memory dirty page.
[0038] Step 2: Copy all memory pages in the virtual machine to the destination host.
[0039] Step 3: Copy the dirty memory pages generated in the previous step to the destination host.
[0040] Step 4: Determine whether the number of remaining dirty memory pages is lower than a preset value. If not, repeat step 3. If so, suspend the virtual machine and copy the remaining dirty memory pages to the destination host within milliseconds.
[0041] Step 5: Start the virtual machine on the destination host and resume providing services.
[0042] The above hot migration method often fails when migrating memory-intensive virtual machines across physical servers. The reasons for this are as follows:
[0043] ① Hot migration across physical hosts requires reliance on the network for data transmission. During the network transmission process, it will be affected by factors such as concurrent migrations squeezing the network speed, network hardware limitations, and network environment fluctuations (network unavailability for a certain period of time).
[0044] ② When a memory-intensive virtual machine runs an application with high read and write memory, the rate at which dirty pages are generated will be greater than the rate at which dirty pages are transmitted, and the remaining dirty pages cannot be reduced below the preset value, causing the virtual machine to be in a migration state for a long time.
[0045] ③ For a virtual machine that is in the migration state for a long time, if the time exceeds the token validity period or the time set by the migration monitoring function, it will trigger the management tool (libvirt) to forcibly terminate the migration interface function, perform migration fuse, and cause migration failure.
[0046] Therefore, the migration of memory-intensive virtual machines across physical hosts using the above hot migration method has the problem of long migration time and even migration failure.
[0047] In order to solve the above technical problems, an embodiment of the present application proposes a method for hot migration of a virtual machine. The method generates an iteration record table for each iterative migration, and uses a prediction model to process the iteration record table and the operating data of the target virtual machine to predict the remaining migration time. If the remaining migration time is too long, the operating information of the target virtual machine is adjusted to reduce the number of memory dirty pages generated by the target virtual machine.
[0048] It can be understood that, in addition to being applicable to hot migration of memory-intensive virtual machines across physical hosts, the embodiments of the present application are also applicable to hot migration of other types of virtual machines across physical hosts, and the embodiments of the present application do not specifically limit the type of virtual machines to be migrated.
[0049] In addition, the execution subject of the embodiment of the present application can be the source host corresponding to the target virtual machine, or it can be an electronic device that is connected to the source host and the destination host for controlling the migration of the target virtual machine, which is not specifically limited in the embodiment of the present application. For the convenience of subsequent description, the electronic device is uniformly used as the execution host.
[0050] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0052] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0053] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0054] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0055] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0056] In the description of the embodiments of the present application, the technical terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the embodiments of the present application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the embodiments of the present application.
[0057] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal connection of two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to the specific circumstances.
[0058] Figure 1 A flow chart of a virtual machine hot migration method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:
[0059] Step 101: copy the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtain a migration information variable; the migration information variable includes the memory page dirty data ratio and memory page address of each memory page.
[0060] Among them, there can be multiple hot migration algorithms, for example: it can be a hot migration method based on the XBZRLE memory page compression algorithm, it can also be a hot migration method based on the compress algorithm, or it can be other hot migration algorithms, which are not specifically limited in the embodiments of the present application. The memory page data to be migrated refers to the memory page data that needs to be copied to the destination host. In the first iterative migration, the memory page data to be migrated is all the memory page data generated by the target virtual machine at the current time; in the second iterative migration, the memory page data to be migrated is the dirty memory page after the first iterative migration, that is, the new memory data generated by the target virtual machine from the start of the first iterative migration to the start of the second iterative migration. By analogy, the memory page data to be migrated corresponding to subsequent iterative migrations are all new memory page data generated by the target virtual machine from the start of the previous iterative migration to the start of this iterative migration.
[0061] It is understandable that the memory page data to be migrated includes at least one memory page to be migrated. Except for the first iteration migration, the memory page included in the memory page data to be migrated is a dirty memory page.
[0062] In the process of migrating the memory page data to be migrated, the electronic device monitors the migration information variable, which includes the memory page dirty data ratio and the memory page address. The so-called memory page dirty data ratio refers to the ratio of dirty data in a memory page to the memory page in this iteration. The memory page address is used to represent the logical position of the memory page to distinguish different memory pages.
[0063] Step 102: determining an iteration record table according to the memory page dirty data ratio and the memory page address;
[0064] In a specific implementation process, the iteration record table is used to represent the relevant information of the memory page data to be migrated during this iterative migration process.
[0065] Step 103: Use the prediction model obtained through pre-training to process the iteration record table and the operation data of the target virtual machine to obtain the remaining migration time output by the prediction model.
[0066] In a specific implementation process, when migrating the memory page data to be migrated, the operation data of the target virtual machine is recorded, and the recorded operation data and the iteration record table are input into the prediction model to obtain the remaining migration time output by the prediction model. It can be understood that the remaining migration time is the time required to complete the migration of the target virtual machine from the current time predicted by the prediction model.
[0067] The operation data may include at least one of the virtual machine CPU operation efficiency, the network transmission rate, and the total amount of virtual machine memory. These parameters may affect the virtual machine migration speed.
[0068] The prediction model is pre-trained using training data, which may be data recorded during historical virtual machine migrations, including, for example, a historical iteration record table, operating parameters during the migration of the virtual machine, and the remaining migration time corresponding to each iteration during historical migrations.
[0069] Step 104: If the remaining migration time is greater than the preset time, adjust the running information of the target virtual machine so that the target virtual machine reduces the number of dirty memory pages generated, and continue to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated until all the memory page data to be migrated of the target virtual machine is migrated to the destination host.
[0070] In a specific implementation, the preset duration is a duration set in advance based on experience, for example, it may be 20 minutes, or it may be 10 minutes, etc., and this embodiment of the present application does not specifically limit this.
[0071] If the remaining migration duration output by the prediction model is greater than the preset duration, the operation information of the target virtual machine is adjusted. It can be understood that the purpose of adjusting the operation information of the target virtual machine is to reduce the number of dirty memory pages generated by the target virtual machine during the subsequent iterative migration process. Therefore, the operation information that affects the number of dirty memory pages generated by the target virtual machine can be adjusted. For example, the operating speed of the CPU of the target virtual machine can be reduced. Specifically, the auto-coverge tool can be used to reduce the generation of memory data from the source. The core principle is to reduce the generation of dirty memory pages by reducing the execution time of the CPU of the target virtual machine. When the auto-coverge tool is turned on, when the remaining migration duration is greater than the preset duration, the operating speed of the target virtual machine will be gradually reduced in proportion until the remaining migration duration is no greater than the preset duration, or until the operating speed of the target virtual machine is reduced by a preset proportion. For example: after the first iterative migration, if the calculated remaining migration time is greater than the preset time, the running speed of the target virtual machine will be reduced by 20%; after the second iterative migration, if the calculated remaining migration time is still greater than the preset time, the running speed of the target virtual machine will be reduced by another 20%, that is, the running speed of the original target virtual machine will be reduced by 40%; and so on, until the remaining migration time is no greater than the preset time, or the running speed of the target virtual machine is reduced by 80%.
[0072] For another example: after the first iterative migration, if the calculated remaining migration time is greater than the preset time, the running speed of the target virtual machine will be reduced by 20%; after the second iterative migration, if the calculated remaining migration time is still greater than the preset time, then based on the current running speed of the target virtual machine, it will be reduced by another 20%, and so on, until the remaining migration time is no greater than the preset time, or the running speed of the target virtual machine is reduced by 99%.
[0073] The above method can ensure that the migration task can be completed in the slowest network.
[0074] It should be noted that the prediction of the remaining migration duration can be performed once for each iterative migration, or the number of iterative migrations can be set, for example, 3 times, that is, the remaining migration duration can be predicted once for every 3 iterative migrations. The embodiment of the present application does not specifically limit the number of iterative migrations. In addition, the proportion of reducing the running speed of the target virtual machine each time can also be set according to actual conditions, for example: the proportion of each reduction can be set to be the same, or the proportion of each reduction can be set to be different.
[0075] If the remaining migration time is not greater than the preset time and the migration task is not completed, then continue to execute step 101 to step 104 until the migration is completed.
[0076] The embodiment of the present application uses a prediction model to predict the remaining migration time of the target virtual machine. If the remaining migration time is too long, the running speed of the target virtual machine is reduced, thereby reducing the newly generated memory data to be migrated by the target virtual machine during the migration process, thereby shortening the time required to migrate the virtual machine.
[0077] Figure 2 A flowchart of another virtual machine migration method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, starting from the 0th iteration, the memory page data to be migrated of the target virtual machine in the source host is copied to the destination host, and the iteration record table 0 is generated during the migration process, and the model interface function is called to use the prediction model to determine whether the running speed of the target virtual machine needs to be reduced. Then, the 1st iteration, the 2nd iteration, ..., the nth iteration are performed until the migration of the target virtual machine is completed.
[0078] Based on the above embodiment, the method of copying the memory page data to be migrated of the target virtual machine in the source host to the destination host by using the hot migration algorithm includes:
[0079] Get the memory page data to be migrated;
[0080] If the cache area in the source host contains a memory page corresponding to the memory page data to be migrated, then determining the update data according to the migrated memory page data corresponding to the memory page and the memory page data to be migrated;
[0081] Copy the updated data to the destination host.
[0082] In the specific implementation process, in some migration scenarios, some relatively fixed memory pages will be frequently modified, and the modified content does not account for a large proportion of the memory page. In order to reduce the amount of data transmitted over the network, a cache area can be maintained in the source host and the destination host respectively. The cache area in the source host and the cache area in the destination host are both used to store the memory pages that have been migrated to the destination host.
[0083] For an iterative migration, the electronic device obtains the memory page data to be migrated, and matches the memory page data to be migrated with the memory page in the cache area in the source host that has been migrated to the destination host. It is understandable that each memory page has its own unique ID (for example: memory address), and even if the data in the memory page changes, its ID will not change accordingly, so it can be matched by ID to determine whether the cache area in the source host includes the memory page corresponding to the memory page data to be migrated. If included, it means that the memory page corresponding to the memory page data to be migrated has been copied to the destination host before. At this time, the electronic device can obtain the data of the memory page to be migrated compared to the memory page in the cache area, that is, the updated data. Copy the updated data to the destination host.
[0084] On the contrary, if there is no memory page corresponding to the memory page data to be migrated in the cache area of the source host, it means that the memory page data to be migrated is migrated for the first time. At this time, the memory page data to be migrated is copied as a whole to the destination host.
[0085] It can be understood that after copying to the destination host, since the destination host's cache area also stores the data that has been migrated to the destination host, after the destination host receives the updated data, the memory page corresponding to the updated data is obtained from the destination host's cache area, and the updated data is restored to a complete memory page based on the obtained memory page.
[0086] It should be noted that, for the first iteration migration, the buffer areas in the source host and the destination host do not contain the memory page data to be migrated.
[0087] The embodiment of the present application determines the updated data and transmits only the updated data, which greatly reduces the amount of data required to be transmitted, thereby speeding up the speed at which the virtual machine completes the migration.
[0088] On the basis of the above embodiment, the step of determining the update data according to the migrated memory page data corresponding to the memory page and the memory page data to be migrated includes:
[0089] The migrated memory page data and the to-be-migrated memory page data are XOR-encoded to obtain the update data.
[0090] In a specific implementation process, after determining the memory page corresponding to the memory page data to be migrated from the cache area of the source host, the migrated memory page data and the memory page data to be migrated corresponding to the memory page can be calculated by XOR encoding to obtain updated data.
[0091] The embodiment of the present application obtains updated data by XOR encoding the migrated memory page data and the memory page data to be migrated. During the migration process, the dirty data ratio of the memory page and the memory page address are collected and recorded, and only the updated data is transmitted, which greatly reduces the amount of data required to be transmitted, thereby speeding up the speed at which the virtual machine completes the migration.
[0092] On the basis of the above embodiment, determining the iteration record table according to the dirty data ratio of the memory page and the memory page address includes:
[0093] Generate a corresponding memory page update record table according to the memory page dirty data ratio and memory page address of each memory page data to be migrated;
[0094] The iteration record table is obtained according to all memory page update record tables.
[0095] In the specific implementation process, each memory page data to be migrated corresponds to a memory page update record table. During the migration process, the memory page dirty data ratio and memory page address corresponding to the memory page data to be migrated are obtained. The corresponding memory page update record table is determined according to the memory page dirty data and the memory page address. Among them, the memory page update record table occupies N bytes of memory space, and each byte records the update information of the memory page in one round of iteration. Among them, each byte records a memory page, and a byte has 8 bits, where the first bit is the dirty mark bit. A number between 0 and 1 can be used to indicate that the memory page is not a dirty memory page, and another number can be used to indicate that the memory page is a dirty memory page. The remaining 7 bits represent the proportion of the memory page change. For example: 10101101, indicating that the page in this round is a dirty page, and the proportion of memory page data change is 45%.
[0096] The iteration record table is calculated based on all memory page update record tables generated by this iteration migration.
[0097] Among them, the iteration record table may include at least one of the following parameters: dirty page location matching degree, dirty page update ratio, average memory page data change ratio, median memory page data change ratio, maximum memory page data change ratio and minimum memory page data change ratio.
[0098] Dirty page location matching degree: It is used to reflect the matching degree of the memory page location of this iteration compared with the previous iteration. Its value range is [0,100]. When the value is 100, it means that the memory page changed in this iteration is the same as the memory page migrated in the previous iteration. Its calculation method is: the number of memory pages with the same address changed in this iteration divided by the largest number of memory pages in the two iterations.
[0099] The dirty page update ratio is calculated as follows: in the iterative update record table, the number of first memory dirty pages whose corresponding memory pages are marked as dirty memory pages is counted, and the number of second memory dirty pages in the last iterative migration process is counted according to the mark bit in the iterative update record table; and then the dirty page update ratio is calculated according to the formula (the number of first memory dirty pages - the number of second memory dirty pages) / the number of second memory dirty pages.
[0100] The average memory page data change ratio is calculated by adding the memory page data change ratios of each memory page update record table and dividing the sum by the number of memory pages migrated in this iteration.
[0101] The median of the memory page data change ratio is to sort the memory page data change ratios in each memory page update record table by size to form a sequence, and the memory page data change ratio in the middle of the sequence is taken as the median of the memory page data change ratio.
[0102] The maximum value of the memory page data change ratio is taken as the maximum value of the memory page data change ratio in each memory page update record table.
[0103] The minimum value of the memory page data change ratio is used as the minimum value of the memory page data change ratio in each memory page update record table.
[0104] Each parameter in the iteration record table in the embodiment of the present application is a factor that affects the remaining migration time. Therefore, through the above calculation of each parameter, a data basis is provided for the prediction of the remaining migration time.
[0105] On the basis of the above embodiment, the operation data includes at least one of the virtual machine CPU operation efficiency, the network transmission rate and the total amount of virtual machine memory; the use of the pre-trained prediction model to process the iteration record table and the operation data of the target virtual machine to obtain the remaining migration time output by the prediction model includes:
[0106] The iteration record table and the operating data of the target virtual machine are input into the prediction model to obtain the remaining migration duration output by the prediction model.
[0107] In the specific implementation process, the embodiment of the present application takes the iteration record table including the dirty page position matching degree, dirty page update ratio, average memory page data change ratio, median memory page data change ratio, maximum memory page data change ratio and minimum memory page data change ratio as examples, and takes the operating parameters including the virtual machine CPU operating efficiency, network transmission rate and total virtual machine memory as examples, and normalizes the above parameters, and the normalized parameters constitute a data matrix as the input of the prediction model. The prediction model predicts the remaining migration time according to the input parameters.
[0108] It is understandable that the prediction model needs to be trained in advance, and the training process is:
[0109] The training data may be acquired when a virtual machine is migrated across physical nodes in the past, including a training iteration record table, training operation parameters, and remaining migration time of the training.
[0110] The parameters included in the training iteration record table and the training operation parameters are consistent with those in the above embodiment. In addition, in general, the parameters input into the model during training and the parameters output by the model are consistent with the parameters input into the model and the parameters output by the model during the prediction phase.
[0111] The network for constructing the prediction model can use a BP neural network and pre-design the number of neurons in the hidden layer. For example, the empirical formula Determine the number of neurons. Where l is the number of neurons, n is the number of input neurons, m is the number of output neurons, and a is a constant between 1 and 10. For example, a is 4, n is 9, and m is 1. In the embodiment of the present application, the number of neurons in the hidden layer is 7. Figure 3 A schematic diagram of a neural network structure provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the neural network includes an input layer, a hidden layer and an output layer. X1-X9 constitute the input layer, and each input neuron corresponds to an input parameter, for example: the dirty page position matching degree is input to the input neuron X1, the dirty page update ratio is input to the input neuron X2, the average of the memory page data change ratio is input to the input neuron X3, the median of the memory page data change ratio is input to the input neuron X4, the maximum value of the memory page data change ratio is input to the input neuron X5, the minimum value of the memory page data change ratio is input to the input neuron X6, the virtual machine CPU operation efficiency is input to the input neuron X7, the network transmission rate is input to the input neuron X8, and the total amount of virtual machine memory is input to the input neuron X9. Y1 constitutes the output layer, which is used to output the remaining migration time.
[0112] After each training, the loss function is calculated according to the prediction results and the remaining migration time of the training, and the parameters in the BP neural network are optimized according to the loss function until the conditions for stopping the training are met to obtain a trained prediction model.
[0113] It is understandable that the condition for stopping training can be a preset number of training times, or a change in the loss value obtained from two consecutive training calculations is less than a preset threshold.
[0114] After completing the model training, the prediction model can be encapsulated into an interface function and deployed based on technologies such as containers. When predicting the remaining migration time, the remaining migration time can be obtained by calling the interface function.
[0115] In the embodiment of the present application, since the iteration record table and the operating data of the target virtual machine will affect the remaining migration time, the accuracy of the remaining migration time prediction is improved based on the iteration record table and the operating data of the target virtual machine.
[0116] Figure 4 A schematic diagram of another virtual machine hot migration method provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the method includes:
[0117] Step 401: Enable the XBZRLE memory page compression algorithm;
[0118] Step 402: Perform a cross-physical node migration on the target virtual machine in the source host; that is, migrate the memory pages in the target virtual machine to the destination host. It should be noted that for the first migration, all the memory page data to be migrated corresponding to the target virtual machine are migrated to the target host; for the second and subsequent migrations, the embodiment of the present application can perform XOR encoding on the migrated memory page data and the memory page data to be migrated, thereby obtaining updated data, and migrate the obtained updated data to the target host.
[0119] Step 403: During the migration process, monitoring migration information variables;
[0120] Step 404: Generate an iteration record table according to the migration information variable; it can be understood that the process of generating the iteration record table refers to the above embodiment, and will not be repeated here.
[0121] Step 405: The iteration record table and the operating data of the target virtual machine are used as model inputs and input into the prediction model to obtain the remaining migration duration output by the prediction model. It can be understood that the prediction model is obtained by training in advance according to the training method provided in the above embodiment. The parameters specifically included in the operating data of the target virtual machine refer to the above embodiment and will not be repeated here.
[0122] Step 406: Determine whether the remaining migration time is greater than the preset time; if so, execute step 407; otherwise, continue to execute step 402 until the target virtual machine is migrated to the destination host;
[0123] Step 407: Adjust the running information of the target virtual machine so that the target virtual machine reduces the number of dirty memory pages generated, and continue to execute step 402. Figure 5 The present invention provides a schematic diagram of a virtual machine hot migration device structure, which can be a module, program segment or code on an electronic device. It should be understood that the device is similar to the above-mentioned Figure 1 The method embodiment corresponds to and can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device can be found in the above description. To avoid repetition, detailed description is appropriately omitted here. The device includes: an information acquisition module 501, an iteration record table determination module 502, a prediction module 503 and an information adjustment module 504, wherein:
[0124] The information acquisition module 501 is used to copy the memory page data to be migrated of the target virtual machine in the source host to the destination host through the hot migration algorithm, and obtain the migration information variable; the migration information variable includes the memory page dirty data ratio and memory page address of each memory page;
[0125] The iteration record table determination module 502 is used to determine the iteration record table according to the memory page dirty data ratio and the memory page address;
[0126] The prediction module 503 is used to process the iteration record table and the operation data of the target virtual machine using the prediction model obtained through pre-training to obtain the remaining migration time output by the prediction model;
[0127] The information adjustment module 504 is used to reduce the running speed of the target virtual machine if the remaining migration time is greater than the preset time, and continue to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated until all the memory page data to be migrated of the target virtual machine is migrated to the destination host.
[0128] Based on the above embodiment, the information acquisition module 501 is specifically used for:
[0129] Get the memory page data to be migrated;
[0130] If the cache area in the source host contains a memory page corresponding to the memory page data to be migrated, then determining the update data according to the migrated memory page data corresponding to the memory page and the memory page data to be migrated;
[0131] The updated data is copied to the destination host.
[0132] Based on the above embodiment, the information acquisition module 501 is specifically used for:
[0133] The migrated memory page data and the to-be-migrated memory page data are XOR-encoded to obtain updated data.
[0134] Based on the above embodiment, the iteration record table determination module 502 is specifically used for:
[0135] Generate a corresponding memory page update record table according to the memory page dirty data ratio and memory page address of each memory page data to be migrated;
[0136] The iteration record table is obtained according to all memory page update record tables.
[0137] On the basis of the above embodiment, the iteration record table includes at least one of the dirty page position matching degree, the dirty page update ratio, the average of the memory page data change ratio, the median of the memory page data change ratio, the maximum value of the memory page data change ratio and the minimum value of the memory page data change ratio; the memory page update record table includes a dirty mark bit and a memory page data change ratio, and the dirty mark bit is used to indicate whether the memory page corresponding to the corresponding memory page data to be migrated is a memory dirty page;
[0138] The iteration record table determination module 502 is specifically used for:
[0139] Determine the dirty page location matching degree according to the number of pages to be migrated corresponding to the current iterative migration and the last iterative migration respectively and the number of memory page addresses being the same;
[0140] Determine the number of first memory dirty pages in this iterative migration according to the mark bit, and determine the dirty page update ratio according to the number of the first memory dirty pages and the number of second memory dirty pages in the previous iterative migration;
[0141] According to the memory page data change ratio corresponding to each memory page to be migrated, the average memory page data change ratio, the median memory page data change ratio, the maximum memory page data change ratio and the minimum memory page data change ratio are determined.
[0142] Based on the above embodiment, the operation data includes at least one of the virtual machine CPU operation efficiency, the network transmission rate and the total amount of virtual machine memory; the iteration record table determination module 502 is specifically used for:
[0143] The iteration record table and the running data of the target virtual machine are input into the prediction model to obtain the remaining migration time output by the prediction model.
[0144] Based on the above embodiment, the device further includes a model training module, which is used to:
[0145] Obtain training data; training data includes training iteration record table, training operation parameters and remaining training migration time;
[0146] Using the training iteration record table and the training operation parameters as inputs of the neural network model to be trained, and obtaining the prediction results of the output of the neural network model to be trained;
[0147] The parameters in the neural network model to be trained are optimized according to the prediction results and the remaining migration time of training to obtain a trained prediction model.
[0148] Figure 6 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present application, such as Figure 6 As shown, the electronic device includes: a processor (processor) 601, a memory (memory) 602 and a bus 603; wherein,
[0149] The processor 601 and the memory 602 communicate with each other via the bus 603;
[0150] The processor 601 is used to call the program instructions in the memory 602 to execute the methods provided by the above-mentioned method embodiments, for example, including: copying the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtaining a migration information variable; the migration information variable includes the memory page dirty data ratio and the memory page address; determining the iteration record table according to the memory page dirty data ratio and the memory page address; using the pre-trained prediction model to process the iteration record table and the running data of the target virtual machine to obtain the remaining migration time output by the prediction model; if the remaining migration time is greater than the preset time, reducing the running speed of the target virtual machine, and continuing to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine are migrated to the destination host.
[0151] The processor 601 may be an integrated circuit chip with signal processing capabilities. The processor 601 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. It may implement or execute various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0152] The memory 602 may include but is not limited to random access memory (RAM), read only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable read-only memory (EEPROM), etc.
[0153] The present embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: copying the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtaining a migration information variable; the migration information variable includes the memory page dirty data ratio and the memory page address; determining an iteration record table according to the memory page dirty data ratio and the memory page address; using a pre-trained prediction model to process the iteration record table and the running data of the target virtual machine to obtain the remaining migration time output by the prediction model; if the remaining migration time is greater than the preset time, reducing the running speed of the target virtual machine, and continuing to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine are migrated to the destination host.
[0154] The present embodiment provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable the computer to execute the methods provided by the above-mentioned method embodiments, for example, including: copying the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtaining a migration information variable; the migration information variable includes the memory page dirty data ratio and the memory page address; determining an iteration record table according to the memory page dirty data ratio and the memory page address; using a pre-trained prediction model to process the iteration record table and the running data of the target virtual machine to obtain the remaining migration time output by the prediction model; if the remaining migration time is greater than the preset time, reducing the running speed of the target virtual machine, and continuing to use the hot migration algorithm to perform the next iterative migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine are migrated to the destination host.
[0155] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0156] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0158] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0159] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A virtual machine hot migration method, characterized in that: include: The hot migration algorithm is used to copy the memory page data to be migrated of the target virtual machine in the source host to the destination host, and the migration information variable is obtained; The migration information variables include the memory page dirty data ratio and the memory page address of each memory page; Determine an iteration record table according to the memory page dirty data ratio and the memory page address; The iteration record table and the operation data of the target virtual machine are processed using the prediction model obtained through pre-training to obtain the remaining migration time output by the prediction model; If the remaining migration time is greater than the preset time, the operation information of the target virtual machine is adjusted so that the target virtual machine reduces the number of dirty memory pages generated, and the hot migration algorithm is continued to be used to perform the next iteration migration on the newly generated memory data to be migrated until all the memory page data to be migrated of the target virtual machine is migrated to the destination host; The determining of the iteration record table according to the memory page dirty data ratio and the memory page address includes: Generate a corresponding memory page update record table according to the memory page dirty data ratio and the memory page address of each memory page data to be migrated; Obtain the iteration record table according to all the memory page update record tables; The iteration record table includes at least one of the dirty page position matching degree, dirty page update ratio, average memory page data change ratio, median memory page data change ratio, maximum memory page data change ratio and minimum memory page data change ratio; the memory page update record table includes a dirty mark bit and a memory page data change ratio, and the dirty mark bit is used to indicate whether the memory page corresponding to the corresponding memory page data to be migrated is a memory dirty page.
2. The method according to claim 1, characterized in that The method of copying the memory page data to be migrated of the target virtual machine in the source host to the destination host by using the hot migration algorithm includes: Acquire the memory page data to be migrated; If the cache area in the source host contains a memory page corresponding to the memory page data to be migrated, then determining update data according to the migrated memory page data corresponding to the memory page and the memory page data to be migrated; The updated data is copied to the destination host.
3. The method according to claim 2, characterized in that The determining the update data according to the migrated memory page data corresponding to the memory page and the memory page data to be migrated includes: The migrated memory page data and the to-be-migrated memory page data are XOR-encoded to obtain the update data.
4. The method according to claim 1, characterized in that: The obtaining the iteration record table according to all the memory page update record tables includes: Determine the dirty page location matching degree according to the number of pages to be migrated corresponding to the current iterative migration and the last iterative migration respectively and the number of memory page addresses being the same; Determine the number of first memory dirty pages in this iterative migration according to the flag bit, and determine the dirty page update ratio according to the first memory dirty page number and the second memory dirty page number in the previous iterative migration; The average memory page data change ratio, the median memory page data change ratio, the maximum value of the memory page data change ratio and the minimum value of the memory page data change ratio are determined according to the memory page data change ratio corresponding to each memory page to be migrated.
5. The method according to claim 4, characterized in that The operation data includes at least one of the virtual machine CPU operation efficiency, the network transmission rate, and the total amount of virtual machine memory; the use of the pre-trained prediction model to process the iteration record table and the operation data of the target virtual machine to obtain the remaining migration time output by the prediction model includes: The iteration record table and the operating data of the target virtual machine are input into the prediction model to obtain the remaining migration duration output by the prediction model.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Acquire training data; the training data includes a training iteration record table, training operation parameters, and training remaining migration time; Using the training iteration record table and the training operation parameters as inputs of the neural network model to be trained, and obtaining a prediction result output by the neural network model to be trained; The parameters in the neural network model to be trained are optimized according to the prediction result and the remaining migration time of the training to obtain the trained prediction model.
7. A virtual machine hot migration device, characterized in that: include: An information acquisition module is used to copy the memory page data to be migrated of the target virtual machine in the source host to the destination host through a hot migration algorithm, and obtain a migration information variable; The migration information variables include the memory page dirty data ratio and the memory page address of each memory page; An iteration record table determination module, used to determine an iteration record table according to the dirty data ratio of the memory page and the memory page address; A prediction module, used to process the iteration record table and the operation data of the target virtual machine using a prediction model obtained through pre-training, and obtain the remaining migration time output by the prediction model; an information adjustment module, configured to adjust the operation information of the target virtual machine if the remaining migration time is greater than a preset time, so that the target virtual machine reduces the number of dirty memory pages generated, and continues to use the hot migration algorithm to perform the next iteration migration on the newly generated memory data to be migrated, until all the memory page data to be migrated of the target virtual machine is migrated to the destination host; The iteration record table determination module is specifically used for: Generate a corresponding memory page update record table according to the memory page dirty data ratio and the memory page address of each memory page data to be migrated; Obtain the iteration record table according to all the memory page update record tables; The iteration record table includes at least one of the dirty page position matching degree, dirty page update ratio, average memory page data change ratio, median memory page data change ratio, maximum memory page data change ratio and minimum memory page data change ratio; the memory page update record table includes a dirty mark bit and a memory page data change ratio, and the dirty mark bit is used to indicate whether the memory page corresponding to the corresponding memory page data to be migrated is a memory dirty page.
8. An electronic device, characterized in that: include: processor, memory and bus, wherein, The processor and the memory communicate with each other via the bus; The memory stores program instructions executable by the processor, and the processor can execute the method according to any one of claims 1 to 6 by calling the program instructions.
9. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, which, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for scheduling network resources based on virtual machine migration
CN102929715A
Data processing method, device and equipment
CN110928634A