启动Tomcat发现deploy war的速度明显变慢, 怀疑磁盘出问题

测试写入

[tomcat@localhost ~]$ dd if=/dev/zero of=kwxgd bs=64k count=4k oflag=dsync
+ records in
+ records out
bytes ( MB) copied, 127.514 s, 2.1 MB/s

测试读取

dd if=kwxgd of=/dev/zero bs=64k count=4k iflag=direct

io状态

[tomcat@localhost ~]$ iostat -x
Linux 2.6.-.el6.x86_64 (localhost.localdomain) 2015年07月02日 _x86_64_( CPU) avg-cpu: %user %nice %system %iowait %steal %idle
0.77 0.00 0.12 0.00 0.00 99.11 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.01 55.48 0.03 2.42 3.20 463.18 190.22 0.04 14.74 0.69 0.17 avg-cpu: %user %nice %system %iowait %steal %idle
0.00 0.00 0.04 0.04 0.00 99.92 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 1.00 0.00 16.00 0.00 16.00 0.01 11.00 11.00 1.10
Linux 2.6.-.el6.x86_64 (localhost.localdomain)     2015年07月02日  _x86_64_( CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
0.77 0.00 0.12 0.00 0.00 99.11 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 2.45 3.20 463.21

rrqm/s: 每秒进行 merge 的读操作数目。即 delta(rmerge)/s
wrqm/s:   每秒进行 merge 的写操作数目。即 delta(wmerge)/s
r/s:           每秒完成的读 I/O 设备次数。即 delta(rio)/s
w/s:       每秒完成的写 I/O 设备次数。即 delta(wio)/s
rsec/s: 每秒读扇区数。即 delta(rsect)/s
wsec/s:  每秒写扇区数。即 delta(wsect)/s
rkB/s:   每秒读K字节数。是 rsect/s 的一半,因为每扇区大小为512字节。(需要计算)
wkB/s: 每秒写K字节数。是 wsect/s 的一半。(需要计算)
avgrq-sz: 平均每次设备I/O操作的数据大小 (扇区)。delta(rsect+wsect)/delta(rio+wio)
avgqu-sz: 平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)。
await: 平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
svctm: 平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio)
%util:    一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。即 delta(use)/s/1000 (因为use的单位为毫秒)

硬盘性能测试
一、安装hdparm

yum install hdparm -y

二、评估读取
SSD 硬盘,请使用hdparm命令进行读取测试。

hdparm -t /dev/xvda

SSH执行以上命令,可使用hdparm评估SSD的读取速率。
“/dev/xvda”指的是对应磁盘的驱动号,请执行“fdisk -l”查看

# 测试随机写IOPS,运行以下命令:
fio -direct= -iodepth= -rw=randwrite -ioengine=libaio -bs=4k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Rand_Write_Testing # 测试随机读IOPS,运行以下命令:
fio -direct= -iodepth= -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Rand_Read_Testing # 测试顺序写吞吐量,运行以下命令:
fio -direct= -iodepth= -rw=write -ioengine=libaio -bs=1024k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Write_PPS_Testing # 测试顺序读吞吐量,运行以下命令:
fio -direct= -iodepth= -rw=read -ioengine=libaio -bs=1024k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Read_PPS_Testing

下表以测试随机写IOPS的命令为例,说明命令中各种参数的含义。

-direct= 表示测试时忽略I/O缓存,数据直写。
-iodepth= 表示使用AIO时,同时发出I/O数的上限为128。
-rw=randwrite 表示测试时的读写策略为随机写(random writes)。作其它测试时可以设置为: randread(随机读random reads)
read(顺序读sequential reads)
write(顺序写sequential writes)
randrw(混合随机读写mixed random reads and writes) -ioengine=libaio 表示测试方式为libaio(Linux AIO,异步I/O)。应用程序使用I/O通常有两种方式: 同步 同步的I/O一次只能发出一个I/O请求,等待内核完成才返回。这样对于单个线程iodepth总是小于1,但是可以透过多个线程并发执行来解决。通常会用16−32根线程同时工作将iodepth塞满。
异步 异步的I/O通常使用libaio这样的方式一次提交一批I/O请求,然后等待一批的完成,减少交互的次数,会更有效率。 -bs=4k 表示单次I/O的块文件大小为4 KB。未指定该参数时的默认大小也是4 KB。 测试IOPS时,建议将bs设置为一个比较小的值,如本示例中的4k。 测试吞吐量时,建议将bs设置为一个较大的值,如本示例中的1024k。
-size=1G 表示测试文件大小为1 GiB。
-numjobs= 表示测试线程数为1。
-runtime= 表示测试时间为1000秒。如果未配置,则持续将前述-size指定大小的文件,以每次-bs值为分块大小写完。
-group_reporting 表示测试结果里汇总每个进程的统计信息,而非以不同job汇总展示信息。
-filename=iotest 指定测试文件的名称,比如iotest。测试裸盘可以获得真实的硬盘性能,但直接测试裸盘会破坏文件系统结构,请在测试前提前做好数据备份。
-name=Rand_Write_Testing 表示测试任务名称为Rand_Write_Testing,可以随意设定。

关于fdisk磁盘信息

Command (m for help): p
Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 249AFED8-1A62-461E-9A07-23B686A34DF4 Command (m for help): n
Partition number (1-128, default 1):
First sector (34-976773134, default 2048):

关于logical sector size 和 physical sector size的说明:

  • The physical_block_size is the minimal size of a block the drive is able to write in an atomic operation.
  • The logical_block_size is the smallest size the drive is able to write (cf. the linux kernel documentation).

The logical sector size being smaller than the physical sector size is normal for most modern disks. This is simply how Advanced Format disks are most often implemented. Some external disks use the same (4096-byte) sector size for both physical and logical sectors, and I've heard that some high-end internal disks now do the same, but most disks these days are Advanced Format models with 512-byte logical sectors and 4096-byte physical sectors. There's nothing you can (or should try to) do about this.

关于First sector default 2048的说明:

Most modern disk drives need a partition to be aligned on sector 2048 to avoid writes overlapping two sectors, but for a long time the sector 63 was used by the fdisk utility and distro's installers by default. This can cause severe performance issues on modern disks. Often they will try to cover up for it in firmware, which means the issue will be still there, but the pain will be just low enough to not really find out whats wrong.

The best solution is to use either GPT/EFI partitions or switch to using LVM since partitions have been an outdated concept for many years now.
On modern distros like Ubuntu the fdisk utility is patched to default to 2048 sectors. You need to use sector 63? In fact it does not even allowed doing it wrong anymore

Centos 检查磁盘读写性能的更多相关文章

  1. DD测磁盘读写性能

    1.测试磁盘的纯写入性能 dd if=/dev/zero of=/file [oracle@11g ~]$ touch ddTest[oracle@11g ~]$ time dd if=/dev/ze ...

  2. linux磁盘读写性能优化

    在LINUX系统中,如果有大量读请求,默认的请求队列或许应付不过来,我们可以 动态调整请求队列数来提高效率,默认的请求队列数存放在/sys/block/xvda/queue/nr_requests 文 ...

  3. centos文件/文件夹操作-检查磁盘、内存、cpu使用情况-vi操作命令

    Part1:CentOS文件/文件夹操作 1.新建文件夹 即创建目录 mkdir 文件名 新建一个名为test的文件夹在home下 vi source1 mkdir /home/test 注意:当创建 ...

  4. 检查 Linux 服务器性能

    如何用十条命令在一分钟内检查 Linux 服务器性能 如果你的Linux服务器突然负载暴增,报警短信快发爆你的手机,如何在最短时间内找出Linux性能问题所在?来看Netflix性能工程团队的这篇博文 ...

  5. 检查Linux服务器性能的关键十条命令

    检查Linux服务器性能的关键十条命令 概述 通过执行以下命令,可以在1分钟内对系统资源使用情况有个大致的了解. uptime dmesg | tail vmstat 1 mpstat -P ALL ...

  6. [转帖]如何用十条命令在一分钟内检查 Linux 服务器性能

    如何用十条命令在一分钟内检查 Linux 服务器性能 时间:2016-09-28   作者:admin 分类:新手入门 阅读:246次 http://embeddedlinux.org.cn/emb- ...

  7. 磁盘IO性能优化-实践

    RAID卡缓存策略调整 原因详解 操作实例 I/O 调度算法 文件系统journal 磁盘挂载参数 操作实例 性能数据对比 RAID卡缓存策略调整 可以将RAID卡缓存策略由No Write Cach ...

  8. 万字长文详解HBase读写性能优化

    一.HBase 读优化 1. HBase客户端优化 和大多数系统一样,客户端作为业务读写的入口,姿势使用不正确通常会导致本业务读延迟较高实际上存在一些使用姿势的推荐用法,这里一般需要关注四个问题: 1 ...

  9. (转)innodb 与 myisam 读写性能分析

    前提: mysql在5.0之前,读写性能相差很大,读性能:myisam 很强 mysql在5.0之后,差距不是很大 http://passover.blog.51cto.com/2431658/507 ...

随机推荐

  1. Android 短信的还原

    上篇文章讲到<Android 短信的备份>,本文主要实现Android 短信的还原,即是将一条 布局文件: <RelativeLayout xmlns:android="h ...

  2. iOS 边框显示不完全

    设置边框为1以上就可以了,如果不觉得宽的话!

  3. 免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been exceeded."解决方案(5月5号)

    免费开发者证书真机调试App ID失效问题:"Unable to add App ID because the '10' App ID limit in '7' days has been ...

  4. juqery 实现 防止当前页面重复点击,以减轻服务器压力

    <script> //防止当前页面重复点击,以减轻服务器压力 $(document).ready(function () { var current_url = location.path ...

  5. oom_kill_process造成数据库挂起并出现found dead shared server

    这篇博客是上一篇博客Oracle shutdown immediate遭遇ORA-24324 ORA-24323 ORA-01089的延伸(数据库挂起hang时,才去重启的),其实这是我们海外一工厂的 ...

  6. dubbox 编译 和 测试

    因为 dubbox 并没有发布到maven中央仓库仓库中,所以需要我们自己到官网下载,自己编译,install 到本地. 1. 首先安装git客户端工具 TortoiseGit, 然后使用它将 dub ...

  7. mysql IP转换函数

    1.将字符串类型的实际IP转换成十进制数值型的 SELECT INET_ATON('209.207.224.40'); 执行结果:

  8. Linux network driver

    一.常见问题 1)2.6.32内核不兼容I219网卡 http://exxactcorp.com/blog/how-to-installconfigure-intel-i219-network-ada ...

  9. linux 下 mysql 安装(不用编译的方式)

    环境是centos6.x.相信其他的也大同小异.相对来说这种方式我用的比较多. 一些环境依赖表库: yum install perl yum install libaio 1)下载:在mysql的网站 ...

  10. web性能优化系列之网站瓶颈识别

    最近,公司网站的的访问量日益增大,PV马上过百万了.前期网站一到访问高峰,马上会变得很卡甚至打不开,后来做了很多优化后现在访问比较顺畅了.经过此事明白了一个道理,在遇到这类问题要做到两点,第一要相信自 ...