Openstack CPU/Disk/network QoS 功能

在openstack中Instance Recource Quota这个feature很早就加进来了,不过一直没有全部测试过这个feature。今天在havana版本中测试了一下这个功能。

首先,这个feature在社区的wiki如下:

https://wiki.openstack.org/wiki/InstanceResourceQuota


测试过程中发现,这个wiki有些信息已经和代码匹配不上了。

从总体上来说这个feature的功能是通过cgroup和tc来实现的。cgroup限制CPU/Disk的IO,tc来限制network IO.

首先看一下CPU限制,目前支持一下参数:

quota:cpu_shares
quota:cpu_period
quota:cpu_quota

我仅测试了quota:cpu_period,测试步骤如下:

nova flavor-key  test_resource_quato set quota:cpu_period=110000

通过CLI设置了flavor的Extra Specs. 当然也可以通过dashboard设置,不过目前存在以下bug,虽然可以实际设进去,但是在dashboard上会重定向错误:

https://bugs.launchpad.net/horizon/+bug/1268860

然后使用这个flavor启动虚机,在计算节点上查看cgroup如下:

[root@ci91szcmp005vcpu0]# pwd
/cgroup/cpu/libvirt/qemu/instance-00000010/vcpu0
[root@ci91szcmp005vcpu0]# cat cpu.cfs_period_us
110000
[root@ci91szcmp005vcpu0]# cd ../vcpu1/
[root@ci91szcmp005vcpu1]# cat cpu.cfs_period_us
110000

默认的cpu period是100000,这里已经改成了110000,说明起作用了。

相关代码如下:

https://github.com/openstack/nova/blob/master/nova/virt/libvirt/driver.py#L3012-3019

对于Network IO的测试我以前写过一个blog,在havana版本中没有太大的变化,只是tc的作用对象从vnetXX变为了tap设备。在此不再累述,可以参考以下blog:

http://blog.csdn.net/matt_mao/article/details/15339729

另外目前支持的network IO的参数如下:

quota:vif_inbound_average
quota:vif_inbound_peak
quota:vif_inbound_burst
quota:vif_outbound_average
quota:vif_outbound_peak
quota:vif_outbound_burst

相关代码如下:

https://github.com/openstack/nova/blob/master/nova/virt/libvirt/designer.py#L126-133

测试Disk IO时发现了以下错误日志:

2014-01-1603:25:18.9923158 ERROR nova.compute.manager [req-8e364bca-9313-4c38-a900-34d2b7f3f700 ad3955246b8d45c8a808b83e4d51c246 88f530c7b2484336824c87801d6d4950] [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] Error: unsupported configuration: block I/O throttling not supported withthisQEMU binary
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] Traceback (most recent call last):
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1037, in _build_instance
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     set_access_ip=set_access_ip)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1410, in _spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     LOG.exception(_(‘Instance failed to spawn‘), instance=instance)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/compute/manager.py", line 1407, in _spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     block_device_info)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 2070, in spawn
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     block_device_info, context=context)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3205, in _create_domain_and_network
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain = self._create_domain(xml, instance=instance, power_on=power_on)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3148, in _create_domain
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain.XMLDesc(0))
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line 3143, in _create_domain
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     domain.createWithFlags(launch_flags)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 187, in doit
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     result = proxy_call(self._autowrap, f, *args, **kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 147, in proxy_call
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     rv = execute(f,*args,**kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib/python2.6/site-packages/eventlet/tpool.py", line 76, in tworker
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     rv = meth(*args,**kwargs)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]   File"/usr/lib64/python2.6/site-packages/libvirt.py", line 708, in createWithFlags
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]     ifret == -1: raise libvirtError (‘virDomainCreateWithFlags() failed‘, dom=self)
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587] libvirtError: unsupported configuration: block I/O throttling not supported withthisQEMU binary
2014-01-1603:25:18.9923158 TRACE nova.compute.manager [instance: ab6f99d6-06f4-4ea2-b4d3-fa3dce322587]

可能由于qemu的bug,目前还不能正常工作。

https://www.redhat.com/archives/libvirt-users/2012-December/msg00008.html


Openstack CPU/Disk/network QoS 功能

上一篇:使用 jQuery() 操作 DOM 对象要注意的小问题


下一篇:HttpWebRequest和HttpWebResponse