Post

Fio Stonewall Behaviour

Welcome to this comprehensive guide on configuring and understanding the behavior of Fio Stonewall, an open-source I/O filter that provides a variety of I/O operations to improve performance and reliability.

# Fio Stonewall Behaviour: Optimizing Self-Hosted Infrastructure for Performance and Reliability

Welcome to this comprehensive guide on configuring and understanding the behavior of Fio Stonewall, an open-source I/O filter that provides a variety of I/O operations to improve performance and reliability in self-hosted infrastructure. This article is intended for experienced sysadmins and DevOps engineers who aim to leverage Fio Stonewall within their homelab or production environments.

Prerequisites

To follow this guide, you’ll need the following software installed:

  1. Ubuntu 20.04 LTS (Focal Fossa) or later
  2. Docker CE version 5.0.8 or higher
  3. Fio version 3.19 or higher

Make sure to update your system and install the required packages using:

1
2
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install docker-ce=5.0.8 docker-compose -y

Step-by-Step Configuration

1. Create a Docker Compose file (docker-compose.yml)

Create a new file called docker-compose.yml in your preferred working directory and add the following configuration:

1
2
3
4
5
6
7
8
9
10
version: '3'
services:
  fio_stonewall:
    image: <username>/fio_stonewall:<tag>
    container_name: fio_stonewall
    restart: always
    volumes:
      - ./fio.conf:/root/fio.conf:ro
      - /dev/urandom:/dev/urandom
    command: [ "/usr/bin/fio" ]

Replace <username> and <tag> with your Docker Hub username and the desired tag for your custom image.

2. Create a Fio Configuration File (fio.conf)

Create a new file called fio.conf in the same directory as your docker-compose.yml. Add the following configuration to enable Stonewall behavior:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
runtime: fio_stonewall
ioengine=libaio
direct=1
iodepth=8
size=2G
numjobs=4
filename=/dev/sda
rwm=randrw
time_based=1
group_reporting

stonewall {
    mode=writeback
    writeback_ratio=50
}

Replace /dev/sda with the desired block device to benchmark.

3. Build and Run the Docker Compose Stack

Build your custom image and run the Docker Compose stack:

1
2
docker build -t <username>/fio_stonewall:<tag> .
docker-compose up --detach

Replace <tag> with the desired tag for your custom image.

Troubleshooting

  • Verify that Fio Stonewall is active by running docker logs fio_stonewall. Look for messages indicating successful Stonewall mode activation.
  • Ensure your block device supports writeback caching and is properly configured in your system’s storage stack (e.g., LVM, MDADM).

Conclusion

Fio Stonewall provides a powerful means of optimizing self-hosted infrastructure by leveraging advanced I/O filtering techniques. By understanding the behavior of Fio Stonewall and configuring it appropriately, you can improve the performance and reliability of your storage subsystems in DevOps and homelab environments.

Potential Security Considerations

  • When using writeback caching, ensure that data is properly synchronized to prevent data loss during power failures or system crashes.
  • Be cautious when using readback mode, as it can expose sensitive data if improperly secured.

Performance Optimization Tips

  • Adjust iodepth, rwm (read/write mix), and time_based parameters to match your workload requirements.
  • Experiment with different writeback ratios to find the optimal setting for your specific use case.

Common Pitfalls

  • Ensure that your block device supports writeback caching before enabling Stonewall mode.
  • Be cautious when modifying the Fio configuration file, as incorrect settings can lead to reduced performance or unexpected behavior.
This post is licensed under CC BY 4.0 by the author.