Beruflich Dokumente
Kultur Dokumente
Overview
Discuss a range of topics about KVM performance
How to improve out of the box experience But crammed into 30 minutes
Use libvirt where possible
Agenda
Low hanging fruit Memory Networking Block I/O basics NUMA and affinity settings CPU Settings Wrap up
Remember this ?
Guest NFS Write Performance
4 50
Be Specific !
virt-manager will:
Specify OS + flavor
The virtio driver If the kernel is recent enough the vhost_net drivers
12.5 x
Default
vhost
virtio
Virtual to physical page map is 512 times smaller TLB can map more physical page resulting fewer misses
Traditional Huge Pages always pinned We now have Transparent Huge Pages Most databases support Huge Pages Benefits not only Host but guests
10
30%
25%
guest bare metal
No-THP
THP
11
Use arp_filter to prevent ARP Flux echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter Use /etc/sysctl.conf for permanent
Packet size - MTU
VM traffic never hits the HW on same box Can really kick up MTU as needed
12
13
14
Latency comparison
Network Latency virtio
Guest Receive (Lower is better)
400 350 300 250 200 150 100 50 0
1 21 64 19 5 76 5 20 48 61 47 5 24 73 5 65 36
Latency (usecs)
4X gap in latency
Virtio Host
15
Moves QEMU network stack from userspace to kernel Improved performance Lower Latency Reduced context switching One less copy
16
Latency comparison
Network Latency - vhost_net
Guest Receive (Lower is better)
400 350 300 250 200 150 100 50 0
1 19 51 13 1 38 7 10 27 30 75 81 95 2 7 45 9 5 65 39
Latency (usecs)
17
40 35 30 25 20 15 10 5 0
io
io
st
st
st
io
os
os
os 32
vi
vi
-v
-v
ho
8-
2-
ho
ho
-v
vh
vh
32
48
-v
-v
51
-v
92
vh
8-
12
2-
20
51
48
92
32
81
12
20
81
32
76
8-
76
8-
vi
18
vhost_net Efficiency
8 Guest Scale Out RX Vhost vs Virtio - % Host CPU
Mbit per % CPU netperf TCP_STREAM 400
Vhost Virtio
19
SR-IOV
20
21
Latency comparison
Network Latency by guest interface method
Guest Receive (Lower is better)
400 350 300 250 200 150 100 50 0
1 19 2 SR-IOV latency close to bare metal 6 51 13 1 38 7 2 10 7 7 30 5 9 81 5 7 45 9 3 55 9
Latency (usecs)
23
M P O l a t o T
1R dH t K M e a V b g dg e t rid e u s
1R dH t K M e a V S -IO g e t R V us
1d ta a e in ta c a b s s ne ( a m ta b re e l)
24
25
Deadline
Two queues per device, one for read and one for writes IOs dispatched based on time spent in queue Per process queue
CFQ
Noop
Each process queue gets fixed time slice (based on process priority)
FIFO Simple I/O Merging Lowest CPU Cost Can set at Boot-time
1Guest
2 Guests
4 Guests
27
I/O from the guest is cached and written through on the host Potential scaling problems with this option with multiple guests (host cpu used to maintain cache)
Cache=writeback - Not supported
28
Cache=WT Cache=none
29
30
900K 800K 700K 600K 500K 400K 300K 200K 100K K 10U 20U
Configurable per device (only by xml configuration file) Libvirt xml file - driver name='qemu' type='raw' cache='none' io='native' 31
It works for Block too ! Device Specific Similar Benefits And drawbacks...
32
6% longer
SAS system SAS T otal
25% longer
KVM VirtIO
KVM/PCI-PassT hrough
Bare-Metal
34 33
NUMA is needed for scaling Keep memory latencies low Linux completely NUMA aware Additional performance gains by enforcing NUMA placement Still some out of the box work is needed
How to enforce NUMA placement numactl CPU and memory pinning One way to test if you get a gain is to mistune it. Libvirt now supports some NUMA placement
34
35
300K 250K 200K 150K 100K 50K K Guest Guest Guest Guest 4 3 2 1
4 Guest-24 vcpu-56G
4 Guest-24 vcpu-56G-NUMA
36
37
1:1 pinning
Good gains with pinning
38
ethtool, ifconfig
Profiling
39
Wrap up
KVM can be tuned effectively
Understand what is going on under the covers Turn off stuff you don't need Be specific when you create your guest Look at using NUMA or affinity Choose appropriate elevators (Deadline vs CFQ) Choose your cache wisely
40
irc, email lists, etc http://www.linux-kvm.org/page/Lists%2C_IRC libvirt Wiki New, revamped edition of the Virtualization Guide
http://docs.redhat.com/docs/enUS/Red_Hat_Enterprise_Linux/index.html Should be available soon ! http://libvirt.org/
http://www.linux-kvm.org/page/Main_Page
41