启动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. AppCompatActivity实现全屏的问题

    前言:我的 Activity 是继承 BaseActivity , 而 BaseActivity 继承 AppCompatActivity . BaseActivity 的继承 /** * 应用程序的 ...

  2. 优化MySchool数据库(一)

    <优化MyShcool数据库>:能够的独立的分析|设计|创建|运营|你的独立的数据库系统 设计--->实现--->TSQL--->查询优化---->性能优化技术-- ...

  3. 小结RunLoop

    Core Foundation中关于RunLoop的5个类 CFRunLoopRef CFRunLoopModeRef CFRunLoopSourceRef CFRunLoopTimerRef CFR ...

  4. 一个统计报表sql问题

    今天朋友问我了一个统计报表的sql问题.我弄了好久.终于算是写出来了.这里记录下. 问题:  id--------------name--------------addtime1            ...

  5. IntelliJ IDEA 导入新项目以后的简单配置

    首先,配置Maven. 然后,配置Git. 选择自己调试要用的默认浏览器. 进行Edit Configurations 配置: 转载请注明出处! http://www.cnblogs.com/libi ...

  6. asp.net MD5 加密

    //Md5摘要 string resultMD5 = FormsAuthentication.HashPasswordForStoringInConfigFile("要加密的内容" ...

  7. 虚拟机中MySQL连接问题:Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql

    环境:在VirtualBox中安装了Ubuntu虚拟机,网络使用了NAT模式,开启了端口转发. 局域网内其他计算机访问虚拟机中的MySQL Server出现两个问题: Lost connection ...

  8. 简述MVC框架模式以及在你(Android)项目中的应用

    标题是阿里电话面试的问题,一直以为自己很清楚MVC模式,结果被问到时,居然没法将MVC和Android中各个组件对应起来,所以,面试肯定挂了,不过面试也是学习的一种方式,可以知道大公司看中什么,以及自 ...

  9. DROP_SNAPSHOT_RANGE过程不能清理表RM$_SNAPSHOT_DETAILS

    今天在测试.验证DROP_SNAPSHOT_RANGE不能彻底快照的过程中遇到了DROP_SNAPSHOT_RANGE无法清理WRM$_SNAPSHOT_DETAILS表中数据的情况,测试服务器版本为 ...

  10. 【转】ETL数据增量抽取——通过触发器方式实现

    在使用Kettle进行数据同步的时候, 共有 1.使用时间戳进行数据增量更新 2.使用数据库日志进行数据增量更新 3.使用触发器+快照表 进行数据增量更新 今天要介绍的是第3中方法. 实验的思路是这样 ...