Optimize disk settings

The default disk configurations on most Linux distributions are not optimal. Follow these steps to optimize settings for your Solid State Drives (SSDs) or spinning disks.

Complete the optimization settings for either SSDs or spinning disks. Do not complete both procedures for either storage type.

Optimize SSDs

Complete the following steps to ensure the best settings for SSDs.

  1. Ensure that the SysFS rotational flag is set to false (zero).

    This overrides any detection by the operating system to ensure the drive is considered an SSD.

  2. Apply the same rotational flag setting for any block devices created from SSD storage, such as mdarrays.

  3. Determine your devices by running lsblk:

    vda    253:0    0  32G  0 disk
    |-sda1 253:1    0   8M  0 part
    |-sda2 253:2    0  32G  0 part /

    In this example, the current devices are sda1 and sda2.

  4. Set the IO scheduler to either deadline or noop for each of the listed devices:

    For example:

    echo deadline > /sys/block/<device_name>/queue/scheduler

    where <device_name> is the name of the device you want to apply settings for.

    • The deadline scheduler optimizes requests to minimize IO latency. If in doubt, use the deadline scheduler.

      echo deadline > /sys/block/<device_name>/queue/scheduler
    • The noop scheduler is the right choice when the target block device is an array of SSDs behind a high-end IO controller that performs IO optimization.

      echo noop > /sys/block/<device_name>/queue/scheduler
  5. Set the nr_requests value to indicate the maximum number of read and write requests that can be queued:

    Machine size Value

    Large machines

    `language-bash echo 128 sys/block/<device_name>/queue/nr_requests `

    Small machines

    `language-bash echo 32 sys/block/<device_name>/queue/nr_requests `

  6. Set the readahead value for the block device to 8 KB.

    This setting tells the operating system not to read extra bytes, which can increase IO time and pollute the cache with bytes that weren’t requested by the user.

    The recommended readahead setting for RAID on SSDs is the same as that for SSDs that are not being used in a RAID installation.

    1. Open /etc/rc.local for editing.

    2. Add the following lines to set the readahead on startup:

      touch /var/lock/subsys/local
      echo 0 > /sys/class/block/sda/queue/rotational
      echo 8 > /sys/class/block/sda/queue/read_ahead_kb
    3. Save and close /etc/rc.local.

Optimize spinning disks

  1. Check to ensure read-ahead value is not set to 65536:

    sudo blockdev --report /dev/<spinning_disk>
  2. Set the readahead to 128, which is the recommended value:

    sudo blockdev --setra 128 /dev/<spinning_disk>

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com