CPU Tuning

Cache share tuning

对于物理 CPU,同一个 core 的 threads 共享 L2 Cache,同一个 socket 的 cores 共享 L3 cache,所以虚拟机的 vcpu 应当尽可能在同一个 core 和 同一个 socket 中,增加 cache 的命中率,从而提高性能。IBM 测试过,合理绑定 vcpu 能给 JVM 来的 16% 的性能提升[2]。
      实现策略:虚拟机 vcpu 尽可能限定在一个 core 或者一个 socket 中。例如:当 vcpu 为 2 时,2 个 vcpu 应限定在同一个 core 中,当 vcpu 大于 2 小于 12 时,应限定在同一个 socket 中。

<vcpu
placement=
'static' cpuset='0-5'>4</vcpu>       #
cpuset 限定 vcpu

NUMA tuning

网易运维团队测试得出:2 个 vcpu 分别绑定到不同 numa
节点的非超线程核上和分配到一对相邻的超线程核上的性能相差有 30%~40%(通过 SPEC CPU2006 工具测试)。可见,同一个虚拟机的
vcpu 需限定在同一个 NUMA 节点,并且分配该 NUMA 节点下的内存给虚拟机,保证虚拟机尽可能访问 local memory 而非
remote memory。

关于 memory allocation mode: If memory is overcommitted in strict mode and
the guest does not have sufficient swap space, the kernel will kill
some guest processes to retrieve additonal memory. Red Hat recommends
using preferred allocation and specifying a single
nodeset (for example, nodeset='0') to prevent this situation[1].

<numatune>
  <memory
mode=
"preferred" nodeset="0"/> 
</numatune>

IRQ tuning

CPU0 常用于处理中断请求,本身负荷较重[3]。事实上,线上环境 CPU0 完全处理 eth0 的 IRQ,eth1 的 IRQ
完全由另一个 CPU 处理,同时 CPU0 处理着大量的 CAL 类型中断。预留 2 个或者 4 个物理 CPU,这些 CPU
和对应网卡中断做绑定,使得其它 CPU 更好更完整的为云主机所用。

VCPU topology tuning

Selecting any desired number of sockets, but with only a single core and
a single thread usually gives the best performance results[1]. 即 VCPU 的
topology 设置为 sockets = vcpu_number, cores = 1, threads = 1.

Disk IO Tuning

Disk IO cache Tuning

kvm 支持多种虚拟机多种 IO Cache 方式:writeback, none, writethrough
等。性能上:writeback > none > writethrough,安全上 writeback < none <
writethrough。For the best storage performance on guest operating
systems that use raw disk volumes or partitions, completely avoid the
page
cache on the host[2].

<disk type='file' device='disk'>
  <driver
name=
'qemu' type='qcow2' cache='none'/>  #
cache 可为 writeback, none, writethrough,directsync,unsafe 等
  ...
</disk>

           
      

Disk IO scheduler

cfq 参数调优。

Memory Tuning

1. 关于 zone_reclaim_mode,设置为 disable 。

2. 关于 swappiness 参数,若 CPU macro-architecture 非 Intel Nehalem 架构,无需要修改优化。

3. 关闭 KVM 内存共享:When KSM merges across nodes on a NUMA host with multiple
guest virtual machines, guests and CPUs from more distant nodes can
suffer a significant increase of access latency to the merged KSM
page[1].

Disable KSM 方式有两种:

1) 禁止某个 Guest 与其它 Guest 共享内存,XML 文件可配置为

<memoryBacking>
    <nosharepages/>
</memoryBacking>

2)  禁止所有 Guest 直接共享内存,Host 配置为

echo 0
/sys/kernel/mm/ksm/pages_shared
echo 0
/sys/kernel/mm/ksm/pages_sharing

4. 打开透明大页:KVM guests can be deployed with huge page memory support in
order to improve performance by increasing CPU cache hits against the
Transaction Lookaside Buffer (TLB)[1].

打开透明大页方式有两种:

1) 允许某个 Guest 开启透明大页

Guest
XML Format
<memoryBacking>
   <hugepages/>
</memoryBacking>
 
echo 25000
/pro c/sys/vm/nr_hugepages
mount -t
hugetlbfs hugetlbfs 
/dev/hugepages
service
libvirtd restart

2) 允许 Host 中所有 Guest 开启透明大页

echo always
/sys/kernel/mm/transparent_hugepage/enabled
echo never
/sys/kernel/mm/transparent_hugepage/defrag
echo 0
/sys/kernel/mm/transparent_hugepage/khugepaged/defrag

Network IO Tuning

开启 vhost_net 模式[3]。

参考资料

    1. Red Hat Enterprise Linux 6 Virtualization Tuning Optimization Guide
    2. Tuning KVM for performance    IBM
    3. 网易 openstack 部署运维实战

kvm 性能调优的更多相关文章

  1. 恒天云技术分享系列3 – KVM性能调优

    恒天云技术分享:http://www.hengtianyun.com/download-show-id-11.html KVM是什么 KVM 是 kernel-based Virtual Machin ...

  2. web前端性能调优

    最近2个月一直在做手机端和电视端开发,开发的过程遇到过各种坑.弄到快元旦了,终于把上线了.2个月干下来满满的的辛苦,没有那么忙了自己准备把前端的性能调优总结以下,以方便以后自己再次使用到的时候得于得心 ...

  3. [网站性能2]Asp.net平台下网站性能调优的实战方案

    文章来源:http://www.cnblogs.com/dingjie08/archive/2009/11/10/1599929.html 前言    最近帮朋友运营的平台进行了性能调优,效果还不错, ...

  4. Asp.net平台下网站性能调优的实战方案(转)

    转载地址:http://www.cnblogs.com/chenkai/archive/2009/11/07/1597795.html 前言 最近帮朋友运营的平台进行了性能调优,效果还不错,所以写出来 ...

  5. 第0/24周 SQL Server 性能调优培训引言

    大家好,这是我在博客园写的第一篇博文,之所以要开这个博客,是我对MS SQL技术学习的一个兴趣记录. 作为计算机专业毕业的人,自己对技术的掌握总是觉得很肤浅,博而不专,到现在我才发现自己的兴趣所在,于 ...

  6. sqlserver性能调优第一步

    相信不少的朋友,无论是做开发.架构的,还是DBA等,都经常听说“调优”这个词.说起“调优”,可能会让很多技术人员心头激情澎湃,也可能会让很多人感觉苦恼,不知道如何入手.当然,也有很多人对此不屑一顾,因 ...

  7. JavaScript:内存泄露、性能调优

    1.在进行JS内存泄露检查之前,先要了解JS的内存管理: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Manageme ...

  8. hadoop 性能调优与运维

    hadoop 性能调优与运维 . 硬件选择 . 操作系统调优与jvm调优 . hadoop运维 硬件选择 1) hadoop运行环境 2)  原则一: 主节点可靠性要好于从节点 原则二:多路多核,高频 ...

  9. JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解

    摘要: JDK本身提供了很多方便的JVM性能调优监控工具,除了集成式的VisualVM和jConsole外,还有jps.jstack.jmap.jhat.jstat.hprof等小巧的工具,本博客希望 ...

随机推荐

  1. ubuntu 安装flash插件

    参考文献: http://wiki.debian.org.hk/w/Install_Flash_Player_with_APTapt-get install adobe-flashplugin

  2. 水晶报表显示到aspx页面中

    1.在前台添加水晶报表显示控件. <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server&q ...

  3. javascript 事件流及应用

    当页面元素触发事件的时候,该元素的容器以及整个页面都会按照特定顺序发生该元素的触发 事件,事件传播的顺序叫做事件流 1.事件流的分类: A.冒泡型事件(所有浏览器都支持)   由明确的事件源到最不确定 ...

  4. js 遍历json对象

    //方法一: var data=[{name:"a",age:12},{name:"b",age:11},{name:"c",age:13} ...

  5. 学习python网络数据采集笔记-1、2章

    英文不好只能看中文版的.邮电出版社翻译的真很烂. 以上是吐槽,以下是正文. 书中用的pthon 3.X版本,建议安装python3.4以上的版本,低版本的没有自带pip安装插件会比较麻烦. 下载地址: ...

  6. C# 操作XML文件,用XML文件保存信息

    using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.IO ...

  7. poj 1681 Painter's Problem

    Painter's Problem 题意:给一个n*n(1 <= n <= 15)具有初始颜色(颜色只有yellow&white两种,即01矩阵)的square染色,每次对一个方格 ...

  8. POJ2103 Jackpot

    Description The Great Dodgers company has recently developed a brand-new playing machine. You put a ...

  9. 【技术帖】解决 Hudson jenkins 连接等待中 - Waiting for next av

    今天构建项目发现如下问题: jenkins 连接等待中 - Waiting for next available executor 左下角那块一直不运行构建,一直在连接等待. 于是,进入一级页面, 右 ...

  10. Windows XP系统安装SQL Server 2005(开发版)图解

    转自Windows XP系统安装SQL Server 2005(开发版)图解 安装前提:由于有些从网上的下载的项目需要导入SQL Server 2005的数据文件,因此,今天便安装了这个数据库,我的系 ...