- PostgreSQL High Performance Cookbook
- Chitij Chauhan Dinesh Kumar
- 438字
- 2021-07-09 18:47:19
Performing a seek rate test
In this recipe, we will be discussing how to benchmark the disk seek rate speed using open source tools.
Getting ready
A file can be read from the disk in two ways: sequentially and at random. Reading a file in sequential order requires less effort than reading a file in random order. In PostgreSQL and other database systems, a file needs to be scanned in random order as per the index scans. During the index scans, as per the index lookups, the relation file needs to fetch the data randomly, by moving its file pointer backward and forward, which needs an additional mechanical overhead in spinning the disk in the normal HDD. In SSD, this overhead is lower as it uses the flash memory. This is one of the reasons why we define that random_page_cost
as always higher than seq_page_cost
in postgresql.conf
. In the previous bonnie++ example, we have random seeks, which were measured per second as 201.0 and used 7% of the CPU.
How to do it...
We can use the same bonnie++ utility command to measure the random seek rate, or we can also use another disk latency benchmarking tool called ioping:
# ioping -R /dev/sda3 -s 8k -w 30 --- /dev/sda3 (block device 65.8 GiB) ioping statistics --- 2.23 k requests completed in 29.2 s, 17.5 MiB read, 76 iops, 613.4 KiB/s generated 2.24 k requests in 30.0 s, 17.5 MiB, 74 iops, 596.2 KiB/s min/avg/max/mdev = 170.6 us / 13.0 ms / 73.5 ms / 5.76 ms
How it works...
Ioping is a disk latency benchmarking tool that produces an output similar to the network utility command ping. This tool also provides no cache or with cache disk benchmarking as bonnie++ and also includes synchronous and asynchronous I/O latency benchmarking. You can install this tool using yum or apt-get in the respective Linux distributions. The preceding results were generated based on PostgreSQL's default block size of 8 KB, which ran for 30 seconds. Ioping provides another useful feature called ping-pong mode for read/write. This mode displays the instant read/write speed of the disk as shown in the following screenshot:
$ ioping -G /tmp/ -D -s 8k 8 KiB >>> /tmp/ (xfs /dev/sda3): request=1 time=1.50 ms (warmup) 8 KiB <<< /tmp/ (xfs /dev/sda3): request=2 time=9.73 ms 8 KiB >>> /tmp/ (xfs /dev/sda3): request=3 time=2.00 ms 8 KiB <<< /tmp/ (xfs /dev/sda3): request=4 time=1.02 ms 8 KiB >>> /tmp/ (xfs /dev/sda3): request=5 time=1.95 ms
In the preceding example, we ran ioping in ping-pong mode (-G
) and used the direct I/O (-D
) with a block size of 8 KB. We can also run the same ping-pong mode in pure cache mode using the (-C
) option.
- 現(xiàn)代測(cè)控系統(tǒng)典型應(yīng)用實(shí)例
- R Machine Learning By Example
- 并行數(shù)據(jù)挖掘及性能優(yōu)化:關(guān)聯(lián)規(guī)則與數(shù)據(jù)相關(guān)性分析
- 機(jī)器人創(chuàng)新實(shí)訓(xùn)教程
- Pig Design Patterns
- 塊數(shù)據(jù)5.0:數(shù)據(jù)社會(huì)學(xué)的理論與方法
- 網(wǎng)絡(luò)化分布式系統(tǒng)預(yù)測(cè)控制
- LAMP網(wǎng)站開(kāi)發(fā)黃金組合Linux+Apache+MySQL+PHP
- Excel 2007常見(jiàn)技法與行業(yè)應(yīng)用實(shí)例精講
- Dreamweaver CS6精彩網(wǎng)頁(yè)制作與網(wǎng)站建設(shè)
- 氣動(dòng)系統(tǒng)裝調(diào)與PLC控制
- 電腦日常使用與維護(hù)322問(wèn)
- 機(jī)器人人工智能
- C++程序設(shè)計(jì)基礎(chǔ)(上)
- 數(shù)字多媒體技術(shù)基礎(chǔ)