0

Thanks to this answer I was able to see the total reads+writes for my apache webserver:

[root@barricade ~]# cat /proc/diskstats | grep sda 8 0 sda 653416 315344 72474412 17441745 4597621 15680121 156902978 282408636 0 80171663 299835582 8 1 sda1 595 245 4696 528 3 0 18 0 0 527 527 8 2 sda2 652661 315089 72468356 17440939 3932716 15680121 156902960 236353355 0 49417302 253779925 

If I interpret the number correctly, the disk has done 653.416 reads and.. 4.597.621 writes?!? this webserver basically serves HTML pages (PHP+MySQL) it's impossible that is generating more writes than reads?

What am I misunderstanding?

Edit: iostat seems to confirm this... still, I'm puzzled...

[root@barricade ~]# iostat Linux 2.6.32-431.20.3.el6.x86_64 (barricade.zane.it) 08/08/2014 _x86_64_ (4 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 3,45 0,00 0,82 2,58 0,00 93,15 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn sda 5,29 72,99 158,06 72474540 156951762 dm-0 13,36 7,07 104,99 7018170 104254024 dm-1 0,35 1,84 0,96 1828536 956040 dm-2 7,03 64,07 52,11 63621098 51741680 

1 Answer 1

5

The contents of /proc/diskstats, and the output of 'iostat' on it's own, both show the cumulative stats since the counters were reset (probably since the machine booted).

If your webserver is serving primarily HTML and simple SQL, it's very likely it's mostly coming out of memory caches, and so very little is hitting the disk for a read. On the other hand, everything that gets logged (such as every HTTP page access, as well as a lot of other things) will generate write activity to disk.

So, it's not unreasonable that your system has done more write activity since boot than read activity, if the content that is being served is simple.

1
  • 3
    This can even be amplified if you don't have noatime or relatime set for a mount, as this essentially means even for every file read from the caches (no disk read operation), you end up with a write operation to update the atime attribute anyway. But on RHEL6-based systems this should be set by default. Commented Aug 9, 2014 at 0:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.