Added license information
[kvmfornfv.git] / docs / all / live_migration.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. (c) <optionally add copywriters name>
4
5 Fast Live Migration
6 ===================
7
8 The NFV project requires fast live migration. The specific requirement is total
9 live migration time < 2Sec, while keeping the VM down time < 10ms when running
10 DPDK L2 forwarding workload.
11
12 We measured the baseline data of migrating an idle 8GiB guest running a DPDK L2
13 forwarding work load and observed that the total live migration time was 2271ms
14 while the VM downtime was 26ms. Both of these two indicators failed to satisfy
15 the requirements.
16
17 Current Challenges
18 ------------------
19
20 The following 4 features have been developed over the years to make the live
21 migration process faster.
22
23 + XBZRLE:
24         Helps to reduce the network traffic by just sending the
25         compressed data.
26 + RDMA:
27         Uses a specific NIC to increase the efficiency of data
28         transmission.
29 + Multi thread compression:
30         Compresses the data before transmission.
31 + Auto convergence:
32         Reduces the data rate of dirty pages.
33
34 Tests show none of the above features can satisfy the requirement of NFV.
35 XBZRLE and Multi thread compression do the compression entirely in software and
36 they are not fast enough in a 10Gbps network environment. RDMA is not flexible
37 because it has to transport all the guest memory to the destination without zero
38 page optimization. Auto convergence is not appropriate for NFV because it will
39 impact guest’s performance.
40
41 So we need to find other ways for optimization.
42
43 Optimizations
44 -------------------------
45 a. Delay non-emergency operations
46    By profiling, it was discovered that some of the cleanup operations during
47    the stop and copy stage are the main reason for the long VM down time. The
48    cleanup operation includes stopping the dirty page logging, which is a time
49    consuming operation. By deferring these operations until the data transmission
50    is completed the VM down time is reduced to about 5-7ms.
51 b. Optimize zero page checking
52    Currently QEMU uses the SSE2 instruction to optimize the zero pages
53    checking.  The SSE2 instruction can process 16 bytes per instruction. By using
54    the AVX2 instruction, we can process 32 bytes per instruction. Testingt shows
55    that using AVX2 can speed up the zero pages checking process by about 25%.
56 c. Remove unnecessary context synchronization.
57    The CPU context was being synchronized twice during live migration. Removing
58    this unnecessary synchronization shortened the VM downtime by about 100us.
59
60 Test Environment
61 ----------------
62
63 The source and destination host have the same hardware and OS:
64 ::
65 Host: HSW-EP
66 CPU: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz
67 RAM: 64G
68 OS: RHEL 7.1
69 Kernel: 4.2
70 QEMU v2.4.0
71
72 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
73 QEMU parameters:
74 ::
75   /root/qemu.git/x86_64-softmmu/qemu-system-x86_64-enable-kvm -cpu host -smp 4 –device virtio-net-pci,netdev=net1,mac=52:54:00:12:34:56 –netdev type=tap,id=net1,script=/etc/kvm/qemu-ifup,downscript=no,vhost=on–device virtio-net-pci,netdev=net2,mac=54:54:00:12:34:56 –netdevtype=tap,id=net2,script=/etc/kvm/qemu-ifup2,downscript=no,vhost=on  -balloon virtio -m 8192-monitor stdio  /mnt/liang/ia32e_rhel6u5.qcow
76
77 Network connection
78
79 .. figure:: lmnetwork.jpg
80    :align: center
81    :alt: live migration network connection
82    :figwidth: 80%
83
84
85 Test Result
86 -----------
87 The down time is set to 10ms when doing the test. We use pktgen to send the
88 packages to guest, the package size is 64 bytes, and the line rate is 2013
89 Mbps.
90
91 a. Total live migration time
92
93    The total live migration time before and after optimization is shown in the
94    chart below. For an idle guest, we can reduce the total live migration time
95    from 2070ms to 401ms. For a guest running the DPDK L2 forwarding workload,
96    the total live migration time is reduced from 2271ms to 654ms.
97
98 .. figure:: lmtotaltime.jpg
99    :align: center
100    :alt: total live migration time
101
102 b. VM downtime
103
104    The VM down time before and after optimization is shown in the chart below.
105    For an idle guest, we can reduce the VM down time from 29ms to 9ms. For a guest
106    running the DPDK L2 forwarding workload, the VM down time is reduced from 26ms to
107    5ms.
108
109 .. figure:: lmdowntime.jpg
110    :align: center
111    :alt: vm downtime
112    :figwidth: 80%