虚拟机在线迁移实验结果绘图

栏目: 服务器 · 发布时间: 4年前

内容简介:《虚拟机在线迁移实验》一文中,模拟了CPU压力、内存压力、磁盘压力还有各种网络故障,得到了这些条件下虚拟机在线迁移的性能数据。本文,就利用gnuplot给迁移过程中得到的性能数据进行绘图,绘图结果用于写论文。

《虚拟机在线迁移实验》一文中,模拟了CPU压力、内存压力、磁盘压力还有各种网络故障,得到了这些条件下虚拟机在线迁移的性能数据。

《ApacheBenchmark和gnuplot》 一文中,找到了测试Web应用性能的方法,学习了gnuplot的基本用法。

本文,就利用gnuplot给迁移过程中得到的性能数据进行绘图,绘图结果用于写论文。

数据处理

gnuplot的数据是纯文本的,不带单位的,按列分布的。那么首先就要处理下数据,使之符合gnuplot的要求,以CPU数据为例,处理后的数据如下:

#CPU占用率  迁移时间    停机时间    迁出数据量   迁入数据量
0%  18  6.28    283 248
10% 20  6.53    353 341
20% 19  4.52    323 300
30% 20  4.58    354 338
40% 21  4.62    336 347
50% 20  5.41    355 323
60% 19  4.54    303 309
70% 21  5.24    356 355
80% 19  4.41    351 338
90% 17  7.31    328 362
99% 19  5.77    351 348

绘图

设计

绘图,最基本的,要知道绘图的目的,想要显示出哪些信息?然后考虑绘制什么图?柱状图还是折线图?x轴是什么?y轴是什么?要不要第二坐标轴?

另外,就要考虑在一张图里面放入哪些信息,不能太少,显得空旷;不能太多,显得杂乱。

对于迁移过程中的四个指标,我们来分析一下。对于迁移时间和停机时间,可以放到一张图(图1)里面,这里的迁移时间和停机时间都是秒级,所以可以使用同一个坐标轴。对于迁移数据量,也可以放进图1,建立第二坐标轴即可。而对于应用程序性能,这个就麻烦了,等会再讨论。

CPU与迁移性能

1、按照以上设计,新建cpu.plt,内容如下:

# graph title
set title "CPU usage, downtime and migration time"
set key below box 1

# x-axis
set xlabel "CPU usage"
set format x "%g%%"

# y-axis
set ylabel "seconds"
set yrange[0:25]
set ytics 5 nomirror

# y2-axis
set y2label "MB"
set y2range[0:500]
set y2tics 100
set grid

plot "cpu.dat" using 1:2 with linespoints title "migration time",\
    "cpu.dat" using 1:3 with linespoints title "downtime",\
    "cpu.dat" using 1:4 axis x1y2 with linespoints title "transfered data"

#pause 5
pause mouse

2、 gnuplot cpu.plt ,执行脚本绘制图片

虚拟机在线迁移实验结果绘图

看上去,挺不错的。但是,实际上的downtime应该是毫秒级,不能和migration time共用y轴,否则看不出downtime的变化。所以,最好把迁移数据量拿出来单独绘图,downtime和migration time绘制在同一个图中,使用不同的坐标系。

3、新建cpu1.plt,绘制迁移时间和停机时间

# graph title
set title "CPU usage, downtime and migration time"
set key below box 1

# x-axis
set xlabel "CPU usage (%)"

# y-axis
set ylabel "Time (s)"
set yrange[0:25]
set ytics 5 nomirror

# y2-axis
set y2label "Time (ms)"
set y2range[0:10]
set y2tics 2
set grid

plot "cpu.dat" using 1:2 with linespoints title "migration time (s)",\
    "cpu.dat" using 1:3 axis x1y2 with linespoints title "downtime (ms)",

#pause 5
pause mouse

虚拟机在线迁移实验结果绘图

4、新建cpu2.plt,绘制迁移数据量

# graph title
set title "CPU usage and transfered data"
set key below box 1

# x-axis
set xlabel "CPU usage (%)"

# y-axis
set ylabel "Transfered Data (MB)"
set yrange[0:500]
set ytics 50

plot "cpu.dat" using 1:4 with linespoints title "Source Machine",\
    "cpu.dat" using 1:5 with linespoints title "Target Machine"

#pause 5
pause mouse

虚拟机在线迁移实验结果绘图

CPU与吞吐量

1、性能测试

ab -g cpu0.dat -t 120 -n 10000000 http://10.0.2.154/
ab -g cpu80.dat -t 120 -n 10000000 http://10.0.2.154/

生成cpu0.dat和cpu80.dat两个文件。

2、处理ab数据,计算吞吐量

#!/bin/bash
for var in {0,80}
do
    start_time=`awk '{print $6}' cpu${var}.dat | grep -v 'wait' | sort | uniq -c|head -1|awk '{print $2}'`
    awk '{print $6}' cpu${var}.dat | grep -v 'wait' | sort | uniq -c|awk -v t=${start_time} '{print $2-t,$1}' > cpu${var}-t.dat
done

生成cpu0-t.dat和cpu80-t.dat两个文件。

3、填充空缺数据为0

#!/bin/bash

for var in {0,80}
do
    array_str=`cat cpu${var}-t.dat | awk '{print $1}'`
    array_str2=`cat cpu${var}-t.dat | awk '{print $2}'`
    IPS=' '
    array=($array_str)
    array2=($array_str2)

    index=0
    count=0
    max=121
    echo "#cpu${var}" > cpu${var}-tf.dat
    while ( [ $index -lt $max ] && [ $count -lt $max ] )
    do
        if [[ ${array[index]} == $count ]]
        then
            echo "$count ${array2[index]}" >> cpu${var}-tf.dat
            index=`expr $index + 1`
            count=`expr $count + 1`
        else
            echo "$count 0"  >> cpu${var}-tf.dat
            count=`expr $count + 1`
        fi
    done
done

4、新建cpu3.plt,绘制吞吐量

# output as png image
#set terminal png  size 1000,560
#set output "cpu3.png"
# graph title
set title "CPU usage and throughput"
set key below box 1

# x-axis label
set xlabel "Time (s)"
# y-axis label
set ylabel "Responses per second"

plot "cpu0_tf.dat" using 1:2 with linespoints title "CPU usage 0%",\
    "cpu80_tf.dat" using 1:2 with linespoints title "CPU usage 80%"

pause mouse

虚拟机在线迁移实验结果绘图

后记

内存压力、磁盘压力、网络故障等条件下的实验结果绘图,和CPU压力类似,详情参考 live-migration-plot

对于吞吐量的绘图,还有很多需要完善。比如说取样,绘制所有CPU占用率下的吞吐量会太乱,取样少了又没有对比,所以2-4条是比较合适的。再比如说时间间隔问题,输入ab测试命令后,输入迁移命令,这中间存在时间间隔。而且通过观察吞吐量曲线,也无法看出从何时开始进行迁移,只能看出停机时间。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

数据结构与算法分析

数据结构与算法分析

韦斯 (Mark Allen Weiss) / 陈越 / 机械工业出版社 / 2016-3-1 / 69.00元

本书是国外数据结构与算法分析方面的经典教材,使用卓越的Java编程语言作为实现工具讨论了数据结构(组织大量数据的方法)和算法分析(对算法运行时间的估计)。本书把算法分析与有效率的Java程序的开发有机地结合起来,深入分析每种算法,内容全面、缜密严格,并细致讲解精心构造程序的方法。一起来看看 《数据结构与算法分析》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

html转js在线工具
html转js在线工具

html转js在线工具