<div dir="ltr">Instead of limitating the consumed bandwidth by proposiong a configuration flag (yet another one, and which default value to be set ?), I would propose to only decrease the niceness of the process itself, so that other processes would get first the I/O access.<div>
That's not perfect I assume, but that's a quick workaround limitating the frustration.</div><div><br></div><div>-Sylvain</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-14 4:52 GMT+01:00 Wangpan <span dir="ltr"><<a href="mailto:hzwangpan@corp.netease.com" target="_blank">hzwangpan@corp.netease.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>







<div style="LINE-HEIGHT:1.3;BORDER-RIGHT-WIDTH:0px;MARGIN:12px;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px" marginheight="0" marginwidth="0"><u></u>
<div><font color="#000000" size="3" face="宋体">Currently nova doesn't 
limit the disk IO bandwidth in copy_image() method while creating a 
new instance, so the other instances on this host may be affected by this high 
disk IO consuming operation, and some time-sensitive business(e.g RDS instance 
with heartbeat) may be switched between master and slave.</font></div>
<div><font color="#000000" size="3"></font> </div>
<div><font color="#000000" size="3" face="宋体">So can we use the `rsync 
--bwlimit=${bandwidth} src dst` command instead of `cp src dst` while copy_image 
in create_image() of libvirt driver, the remote image copy operation also 
can be limited by `rsync --bwlimit=${bandwidth}` or `scp -l=${bandwidth}`, this 
parameter ${bandwidth} can be a new configuration in nova.conf which allow cloud 
admin to config it, it's default value is 0 which means no limitation, then 
the instances on this host will be not affected while a new instance with 
not cached image is creating.</font></div>
<div><font color="#000000" size="3"></font> </div>
<div><font color="#000000" size="3">the example codes:</font></div>
<div><font color="#000000" size="3">nova/virt/libvit/utils.py:</font></div>
<div><font style color="#000000" size="3">diff --git 
a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py<br>index 
e926d3d..5d7c935 100644<br>--- a/nova/virt/libvirt/utils.py<br>+++ 
b/nova/virt/libvirt/utils.py<br>@@ -473,7 +473,10 @@ def copy_image(src, dest, 
host=None):<br>         # sparse 
files.  I.E. holes will not be written to 
DEST,<br>         # rather recreated 
efficiently.  In addition, 
since<br>         # coreutils 8.11, 
holes can be read efficiently 
too.<br>-        execute('cp', src, 
dest)<br>+        if CONF.mbps_in_copy_image 
> 0:<br>+            
execute('rsync', '--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, 
dest)<br>+        
else:<br>+            
execute('cp', src, dest)<br>     
else:<br>         dest = "%s:%s" % 
(host, dest)<br>         # Try rsync 
first as that can compress and create sparse dest files.<br>@@ -484,11 +487,22 
@@ def copy_image(src, dest, 
host=None):<br>             
# Do a relatively light weight test first, so that 
we<br>             # 
can fall back to scp, without having run out of 
space<br>             
# on the destination for 
example.<br>-            
execute('rsync', '--sparse', '--compress', '--dry-run', src, 
dest)<br>+            if 
CONF.mbps_in_copy_image > 
0:<br>+                
execute('rsync', '--sparse', '--compress', 
'--dry-run',<br>+                        
'--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, 
dest)<br>+            
else:<br>+                
execute('rsync', '--sparse', '--compress', '--dry-run', src, 
dest)<br>         except 
processutils.ProcessExecutionError:<br>-            
execute('scp', src, 
dest)<br>+            if 
CONF.mbps_in_copy_image > 
0:<br>+                
execute('scp', '-l', '%s' % CONF.mbps_in_copy_image * 1024 * 8, src, 
dest)<br>+            
else:<br>+                
execute('scp', src, dest)<br>         
else:<br>-            
execute('rsync', '--sparse', '--compress', src, 
dest)<br>+            if 
CONF.mbps_in_copy_image > 
0:<br>+                
execute('rsync', '--sparse', 
'--compress',<br>+                        
'--bwlimit=%s' % CONF.mbps_in_copy_image * 1024, src, 
dest)<br>+            
else:<br>+                
execute('rsync', '--sparse', '--compress', src, dest)</font></div>
<div> </div>
<div> </div>
<div align="left"><font color="#c0c0c0" face="Verdana">2014-02-14</font></div><font face="Verdana">
<hr style="WIDTH:122px;min-height:2px" align="left" size="2"><span class="HOEnZb"><font color="#888888">
</font></span></font><span class="HOEnZb"><font color="#888888">
<div><font color="#c0c0c0" face="Verdana"><span>Wangpan</span></font></div><u></u></font></span></div><br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>