Measuring the I/O Throughput of Your PostgreSQL Database Server

To measure the I/O throughput of your PostgreSQL database server, which is measured in input/output operations per second (IOPS), you can use the fio tool:

Note: The instructions in this section are applicable to a PostgreSQL database server that you have SSH access to. If your PostgreSQL database server is in the cloud of a cloud infrastructure provider and you do not have SSH access to that server, use other tools that are available in that cloud. For Azure, for example, you can use the metrics provided by Azure Database for PostgreSQL.

  1. Install the fio tool on your server. For example:

    # yum install -y epel-release
    # yum install -y fio
  2. Measure the I/O throughput using read operations. For example:

    # fio --ioengine=libaio --direct=1 --runtime=60s --time_based --name=testfio --filename /var/lib/pgsql/testfio --bs=4k --iodepth=64 --size=8G --readwrite=randread
    ...
    testfio: (groupid=0, jobs=1): err= 0: pid=6818: Sat May 29 19:06:15 2021
       read: IOPS=314k, BW=1227MiB/s (1286MB/s)(71.9GiB/60001msec)
    ...
    
  3. Measure the I/O throughput using write operations. For example:

    # fio --ioengine=libaio --direct=1 --runtime=60s --time_based --name=testfio --filename /var/lib/pgsql/testfio --bs=4k --iodepth=64 --size=8G --readwrite=randwrite
    ...

As a result, you will measure the overall I/O throughput of your PostgreSQL database server. If either of the measurements is less than 2000 IOPS, allocate more resources to your server.

CloudBlue, an Ingram Micro business, uses cookies to improve the usability of our site. By continuing to use this site and/or logging in you are accepting the use of these cookies. For more information, visit our Privacy Policy.