0% found this document useful (0 votes)
6 views

Benchmarking disk performance

The document provides a comprehensive guide on benchmarking disk and network performance inside Docker containers using tools like fio, nuttcp, and netperf. It includes detailed instructions for setting up Docker images, running benchmarks, interpreting results, and monitoring container performance with cAdvisor. Additionally, it offers solutions for SELinux issues and integration with Prometheus and Grafana for enhanced monitoring.

Uploaded by

dharsanimv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Benchmarking disk performance

The document provides a comprehensive guide on benchmarking disk and network performance inside Docker containers using tools like fio, nuttcp, and netperf. It includes detailed instructions for setting up Docker images, running benchmarks, interpreting results, and monitoring container performance with cAdvisor. Additionally, it offers solutions for SELinux issues and integration with Prometheus and Grafana for enhanced monitoring.

Uploaded by

dharsanimv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Benchmarking disk performance

Choose a Benchmarking Tool

There are several tools available for benchmarking disk performance inside Docker
containers:

 fio (Flexible I/O Tester)


 dd (Basic disk read/write speed test)
 bonnie++ (More comprehensive disk testing)
 sysbench (General system benchmarking)

Disk performance benchmark inside a Docker container using fio.

Understanding the fio Job File Setup

The mixed.fio file configures fio to perform random direct I/O with:

 Block size: 4K
 File size: 16GB (/ferrari/fio-test-file)
 I/O engine: libaio (asynchronous I/O)
 I/O depth: 32
 Parallel jobs: 8
 Workload mix: 70% read, 30% write

1. Running the Benchmark on Bare Metal / VM

If you're testing on a physical machine or virtual machine, simply run:

fio mixed.fio

This will execute the workload and provide performance statistics.

2. Running the Benchmark in Docker

To run the test in a Docker container, you need to prepare a Docker image with fio.

Dockerfile Explanation

Create a file named Dockerfile with the following content:

FROM ubuntu
MAINTAINER [email protected]
RUN apt-get update
RUN apt-get -qq install -y fio
ADD mixed.fio /
VOLUME ["/ferrari"]
ENTRYPOINT ["fio"]

 FROM ubuntu → Uses an Ubuntu base image.


 MAINTAINER [email protected] → Defines the maintainer (optional).
 RUN apt-get update → Updates package lists.
 RUN apt-get -qq install -y fio → Installs fio quietly (-qq).
 ADD mixed.fio / → Copies the mixed.fio job file into the container.
 VOLUME ["/ferrari"] → Defines /ferrari as a mountable volume.
 ENTRYPOINT ["fio"] → Sets fio as the default command.

3. Building the Docker Image

Once the Dockerfile is ready, build the image:

docker build -t docker_fio_perf .

 -t docker_fio_perf → Tags the image as docker_fio_perf.

4. Running the Benchmark in Docker

To execute the test inside a container:

docker run --rm -v /ferrari:/ferrari docker_fio_perf mixed.fio

 --rm → Removes the container after execution.


 -v /ferrari:/ferrari → Mounts the host directory /ferrari inside the container.
 docker_fio_perf → Uses the built image.
 mixed.fio → Specifies the job file.

This runs fio with the predefined job settings and collects performance results.

5. Handling SELinux Issues (Fedora/RHEL/CentOS)

If your system has SELinux enabled, you may get a Permission denied error when
mounting volumes.

To fix it, use the :z flag while mounting:

docker run --rm -v /ferrari:/ferrari:z docker_fio_perf mixed.fio


 :z → Relabels the /ferrari directory for SELinux compatibility.

6. Interpreting the Results

After running fio, you'll see output similar to:

READ: io=11.2GiB, bw=350MiB/s, iops=89k, runt=32000msec


WRITE: io=4.8GiB, bw=150MiB/s, iops=37k, runt=32000msec

 bw=350MiB/s → Read bandwidth (speed).


 iops=89k → Read IOPS (operations per second).
 bw=150MiB/s → Write bandwidth.
 iops=37k → Write IOPS.

7. Cleaning Up

After benchmarking, you can remove the test files to free up space:

rm -f /ferrari/fio-test-file

To remove the Docker image if no longer needed:

docker rmi docker_fio_perf

Conclusion

This method provides a consistent and reproducible way to benchmark disk performance
inside Docker while ensuring SELinux compatibility on RHEL-based systems. 🚀
Benchmarking network performance

This guide explains how to use nuttcp and netperf to measure network bandwidth and
request/response performance between two endpoints.

1. Installing the Required Tools

First, install the necessary software on both endpoints.

On Fedora/RHEL (for nuttcp)


yum install -y nuttcp

For netperf, download it from netperf.org.

On Ubuntu/Debian
apt update && apt install -y nuttcp netperf

2. Measuring Network Bandwidth with nuttcp

nuttcp is used for measuring throughput between two systems.

Step 1: Start the nuttcp Server

On one endpoint (Server), run:

nuttcp -S

This starts the server and listens for connections.

Step 2: Measure Transmit Throughput (Client → Server)

On the other endpoint (Client), run:

nuttcp -t <SERVER_IP>

Example:

nuttcp -t 192.168.1.10

This tests how fast data can be sent from the client to the server.

Step 3: Measure Receiver Throughput (Server → Client)


Run the following on the Client:

nuttcp -r <SERVER_IP>

This measures how fast data is received from the server to the client.

3. Measuring Request/Response Performance with netperf

netperf helps test latency and responsiveness over TCP and UDP.

Step 1: Start netserver on the Server

On one endpoint (Server), start netserver:

netserver

This will listen for incoming test connections.

Step 2: Run TCP Request/Response Test

On the Client, run:

netperf -H <SERVER_IP> -t TCP_RR

Example:

netperf -H 192.168.1.10 -t TCP_RR

This measures TCP request/response performance.

Step 3: Run UDP Request/Response Test

To test UDP, run:

netperf -H <SERVER_IP> -t UDP_RR

This measures UDP request/response performance.

4. Interpreting the Results

nuttcp Output Example:


192.168.1.20 -> 192.168.1.10: 1000 Mbps, 950 Mbits/sec, 118 MB/sec

 1000 Mbps → Link speed


 950 Mbits/sec → Actual data transfer rate
 118 MB/sec → Throughput in megabytes
netperf Output Example (TCP RR Test):
TCP REQUEST/RESPONSE TEST
Throughput: 2500 Transactions/sec

 Higher transactions/sec → Better performance.

5. Running Tests in Docker

To benchmark network performance inside Docker, follow these steps:

Step 1: Start a nuttcp Server in Docker


docker run --rm -it --name nuttcp-server ubuntu bash
apt update && apt install -y nuttcp
nuttcp -S

Then, on another container or host machine, run:

docker run --rm -it ubuntu bash


apt update && apt install -y nuttcp
nuttcp -t <SERVER_CONTAINER_IP>

Step 2: Start a netperf Server in Docker


docker run --rm -it --name netserver ubuntu bash
apt update && apt install -y netperf
netserver

From another container or host machine:

netperf -H <NETSERVER_CONTAINER_IP> -t TCP_RR

Conclusion

This guide covers how to:

 Measure network bandwidth using nuttcp


 Test request/response performance using netperf
 Run benchmarks inside Docker
Performance monitoring

Setting Up cAdvisor for Docker Container Monitoring

cAdvisor (Container Advisor) is a lightweight, real-time monitoring tool for Docker


containers. It provides insights into CPU, memory, disk, and network usage.

1. Running cAdvisor as a Docker Container

The easiest way to run cAdvisor is by using its official Docker image.

Run the following command to start cAdvisor in a Docker container:

sudo docker run \


--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest

Explanation of Flags:

 --volume=/:/rootfs:ro → Mounts the root filesystem (read-only).


 --volume=/var/run:/var/run:rw → Allows access to Docker's runtime files.
 --volume=/sys:/sys:ro → Provides access to system information.
 --volume=/var/lib/docker/:/var/lib/docker:ro → Enables container statistics.
 --publish=8080:8080 → Exposes cAdvisor’s web interface on port 8080.
 --detach=true → Runs the container in the background.
 --name=cadvisor → Names the container cadvisor.
 google/cadvisor:latest → Uses the latest cAdvisor image.

2. Accessing cAdvisor's Web Interface

After starting the container, open a browser and go to:

http://localhost:8080

You'll see CPU, memory, disk, and network usage graphs for the host machine.

To view individual Docker container metrics:

1. Click on Docker Containers.


2. Navigate to Subcontainers.
3. Click on a container to see detailed resource usage.
3. Running cAdvisor Outside of Docker

If you prefer to run cAdvisor directly on the host (bare metal or VM), follow these steps:

Install cAdvisor (Standalone Mode)

1. Download the latest binary:


2. wget
https://github.com/google/cadvisor/releases/latest/download/cadvisor
3. Make it executable:
4. chmod +x cadvisor
5. Run cAdvisor:
6. ./cadvisor
7. Open http://localhost:8080 in a browser to view the monitoring dashboard.

For more options, refer to:


👉 cAdvisor Standalone Guide

4. Stopping and Removing cAdvisor

If you need to stop or remove the container:

sudo docker stop cadvisor


sudo docker rm cadvisor

5. Integrating cAdvisor with Prometheus & Grafana

To collect and visualize container metrics with Prometheus & Grafana:

1. Run Prometheus with this prometheus.yml config:


2. scrape_configs:
3. - job_name: 'cadvisor'
4. static_configs:
5. - targets: ['localhost:8080']
6. Run Grafana and add Prometheus as a data source.
7. Use Grafana dashboards to monitor container performance.

6. Alternative: Using sFlow for Docker Monitoring

Another option for monitoring Docker network performance is sFlow. Follow the setup guide
here:
👉 sFlow Docker Monitoring
Conclusion

 cAdvisor is a simple and powerful tool for real-time container monitoring.


 It runs efficiently inside a Docker container or as a standalone binary.
 You can integrate it with Prometheus & Grafana for advanced visualization.

Would you like help setting up Prometheus/Grafana for better monitoring? 🚀

You might also like