Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ep:labs:03:contents:tasks:ex1 [2020/08/04 20:26]
gheorghe.petre2608 [01. [10p] Rotational delay - IOPS calculations]
ep:labs:03:contents:tasks:ex1 [2025/02/11 23:27] (current)
cezar.craciunoiu
Line 1: Line 1:
-==== 01. [10pRotational delay - IOPS calculations ​====+==== 01. [30pVmstat ​==== 
 +The **vmstat** utility provides a good low-overhead view of system performance. Since **vmstat** is such a low-overhead tool, it is practical to have it running even on heavily loaded servers when it is needed to monitor the system’s health.
  
-<note tip> +=== [10p] Task A - Monitoring stress === 
-Every disk in your storage system has maximum theoretical IOPS value that is based on a formulaDisk performance and IOPS is based on three key factors:+Run **vmstat** on your machine with 1 second delay between updatesNotice the CPU utilisation (info about the output columns [[https://​medium.com/​@damianmyerscough/​vmstat-explained-83b3e87493b3|here]]).
  
-  ​* **Rotational speed**. Measured in RPMmostly 7,200, 10,000 or 15,000 RPM. A higher rotational speed is associated with a higher-performing disk+In another terminal, use the **stress** command to start N CPU workerswhere N is the number of cores on your system
-  * **Average latency**The time it takes for the sector of the disk being accessed to rotate into position under a read/write head+Do not pass the number directlyInstead, use command substitution
-  * **Average seek time**. The time (in ms) it takes for the hard drive’s read/write head to position itself over the track being read or written. + 
-  ​* **Average IOPS**: Divide 1 by the sum of the average latency in ms and the average seek time in ms (1 (average latency in ms + average seek time in ms)+Note: if you are trying to solve the lab on //fep// and you don't have **stress** installed, try cloning and compiling [[https://​github.com/​ColinIanKing/​stress-ng|stress-ng]]. 
-</note+ 
-To calculate the **IOPS range** divide 1 by the sum of the average latency in ms and the average seek time in ms. The formula is:  +<solution -hidden
-<​code>​average IOPS = (average latency in ms + average seek time in ms).+**Task A:**\\ 
 +<​code ​bash> 
 +$ vmstat -w -n 1 
 +$ stress -c $(nproc)
 </​code>​ </​code>​
 +</​solution>​
  
-Let's calculate ​the Rotational Delay - RD for a 10K RPM drive:+=== [10p] Task B - How does it work? === 
 +Let us look at how **vmstat** works under the hood. We can assume that all these statistics (memory, swap, etc.) can not be normally gathered in userspace. So how does **vmstat** get these values from the kernel? Or rather, how does any process interact with the kernel? Most obvious answer//**system calls**//.
  
-  * Divide 10000 RPM by 60 seconds: **''​10000/​60 = 166 RPS''​** +<code bash> 
-  * Convert 1 of 166 to decimal: **''​1/​166 = 0.006 seconds per Rotation''​** +$ strace vmstat 
-  * Multiply the seconds per rotation by 1000 milliseconds (6 MS per rotation). +</code>
-  * Divide the total in half (RD is considered half a revolution around a disk): **''​6/​2 = 3 MS''​** +
-  * Add an average of 3 MS for seek time: **''​3 MS + 3 MS = 6 MS''​** +
-  * Add 2 MS for latency (internal transfer): **''​6 MS + 2 MS = 8 MS''​** +
-  * Divide 1000 MS by 8 MS per I/O: **''​1000/8 = 125 IOPS''​**+
  
-=== [10p] Task A - Calculate rotational delay ===+//"All well and good. But what am I looking at?"//
  
-Calculate ​the rotational delay (RDfor a 5400 RPM drive.+What you //should// be looking at are the system calls after the two **write**s that display the output header ​(hint: it has to do with **/proc/** file system). So, what are these files that **vmstat** opens?
  
-<solution -hidden+<code bash
-As shown in the //"​Calculating IOs Per Second"//​ section: +$ file /proc/meminfo 
-<​code>​ +$ cat /proc/meminfo 
-5400 60 = 90 RPS + 
-1/90 = 0.011 seconds per Rotation +$ man proc
-0.011 * 1000 = 11ms per Rotation +
-11 / 2 = 5.5ms RD (Rotational Delay = half a revolution around a disk) +
-add approx. 3ms seek time => 8.5ms +
-add 2ms latency => 10.5ms +
-Divide 1000ms by 10.5ms per I/O => approx. 95 IOPS+
 </​code>​ </​code>​
-</​solution>​ 
  
 +The manual should contain enough information about what these kernel interfaces can provide. However, if you are interested in //how// the kernel generates the statistics in **/​proc/​meminfo** (for example), a good place to start would be [[https://​elixir.bootlin.com/​linux/​v4.15/​source/​fs/​proc/​meminfo.c|meminfo.c]] (but first, [[https://​ocw.cs.pub.ro/​courses/​so2|SO2 wiki]]).
  
 +=== [10p] Task C - USO flashbacks (1) ===
  
 +Write a one-liner that uses **vmstat** to report complete **disk statistics** and sort the output in **descending** order based on **total reads** column.
 +
 +<note tip>
 +You can eliminate the first two header lines from the **vmstat** output using ''​tail -n +3''​.
 +</​note>​
 +
 +<​solution -hidden>
 +<code bash>
 +$ vmstat -wdn | tail -n +3 | sort -nrk 2
 +</​code>​
 +</​solution>​
ep/labs/03/contents/tasks/ex1.1596562004.txt.gz · Last modified: 2020/08/04 20:26 by gheorghe.petre2608
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0