启动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. hybrid app

    hybrid app Hybrid App(混合模式移动应用)是指介于web-app.native-app这两者之间的app,兼具“Native App良好用户交互体验的优势”和“Web App跨平台 ...

  2. XMPP实现登陆注销功能

    XMPP框架的下载与导入等问题请参照 —— XMPP框架的分析.导入及问题解决 DEMO ——XMPP即时通讯(已导入框架)密码:3a7n 这篇我们利用XMPP框架来实现一下登陆功能,先来介绍一下XM ...

  3. 【Android】友盟的自动更新组件

    前言 又好又专业的服务能帮开发者省很多时间.一开始做项目也准备自己来统计数据.自己做自动更新,随着使用友盟服务的时间增加,渐渐放弃了这种想法,转而研究如何更充分的使用,这里分享一下使用自动更新组件的心 ...

  4. 安卓--selector简单使用

    selector ---选择器 在App的使用中经常能看到selector的身影 如:一个按键看上去白色或者其它颜色,可能是一张图片 按下去又显示其它的颜色或者另外一张图片 这里使用shape配合使用 ...

  5. OC 初识NSString,self关键字,继承,成员变量的可见性,description方法

    OC 初识NSString,self关键字,继承,成员变量的可见性,description方法 初识 NSString: char * string = "旭宝爱吃鱼"; 常量字符 ...

  6. 设计模式 之 装饰者(Decorator)模式

    装饰者模式(Decorator):动态地为一个对象添加一些额外的职责,若要扩展一个对象的功能,装饰者提供了比继承更有弹性的替代方案. 结构图: 抽象构件类(Component):给出一个抽象的接口,用 ...

  7. android Gui系统之SurfaceFlinger(1)---SurfaceFlinger概论

    GUI 是任何系统都很重要的一块. android GUI大体分为4大块. 1)SurfaceFlinger 2)WMS 3)View机制 4)InputMethod 这块内容非常之多,但是理解后,可 ...

  8. H5一二事

    先回顾一下WEB技术的几个阶段 Web 1.0 内容为主,主要流行HTML和CSS Web 2.0 动态网页,流行AJAX/JavaScript/DOM H5 时代,WEB开发回归富客户端 那么H5肯 ...

  9. JMS发布/订阅消息传送例子

    前言 基于上篇文章"基于Tomcat + JNDI + ActiveMQ实现JMS的点对点消息传送"很容易就可以编写一个发布/订阅消息传送例子,相关环境准备与该篇文章基本类似,主要 ...

  10. Linux服务器文件删除空间未释放的问题

    一.问题起源 在Linux系统中,通过rm删除文件将会从文件系统的目录结构上解除链接(unlink),如果文件是被打开的(有一个进程正在使用),那么进程将仍然可以读取该文件磁盘空间也一直被占用 这样就 ...