kvm 性能调优
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 中。
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].
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 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 文件可配置为
2) 禁止所有 Guest 直接共享内存,Host 配置为
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 开启透明大页
2) 允许 Host 中所有 Guest 开启透明大页
Network IO Tuning
开启 vhost_net 模式[3]。
参考资料
-
- Red Hat Enterprise Linux 6 Virtualization Tuning Optimization Guide
- Tuning KVM for performance IBM
- 网易 openstack 部署运维实战
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
docker 中 NGINX+PHP+MYSQL+REDIS+Elasticsearch 环境搭建 (linux系统)
项目中N次使用PHP+MYSQL+NGINX+REDIS+ Elasticsearch,为了方便所以使用了docker fox.风来了 完整版地址: http://blog.csdn.net/fenglailea/article/details/50451555 目前是 LINUX 下,稍后制作 WINDOWS下的 1.docker 环境安装 http://blog.csdn.net/fenglailea/article/details/44886427 推荐使用方法二 2.下载镜像 国外和国内的docker hub 是两种速度体验,访问国外的HUB 的时间,可以和朋友一起搓一顿都够了。 可以使用国内的docker HUB 使用国外下载 docker hub 时,有时会报错,比如超时,或者有代理什么的,直接PASS,重新PULL 2.1 nginx+php+redis 镜像下载 docker pull foxiswho/docker-nginx-php大约2小时,docker hub 国内没有服务器就是慢,可以使用国内的一些docker 仓库如 阿里云等 2.2elasticsearc...
- 下一篇
docker官方文档摘要
Prerequisites Docker requires a 64-bit installation regardless of your CentOS version. Also, your kernel must be 3.10 at minimum, which CentOS 7 runs.
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- CentOS8安装Docker,最新的服务器搭配容器使用
- 设置Eclipse缩进为4个空格,增强代码规范
- Red5直播服务器,属于Java语言的直播服务器
- SpringBoot2整合Redis,开启缓存,提高访问速度
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS7安装Docker,走上虚拟化容器引擎之路