Testing Performance
This document verifies scheduling performance optimization in a Docker-based environment with bond4 and IPVLAN configurations.
The following uses the redis-benchmark stress test on four redis-server instances as an example to verify whether the feature is successfully enabled and to obtain the performance test results if the feature is enabled. This section includes affinity configuration and performance testing. Perform affinity configuration based on the container or physical machine scenario.
Affinity Configuration (Container Scenario)
- Access the four Docker containers on the server.
1docker exec -it {Container name} bash
- Run the following command in the container:
1echo $nid > /sys/fs/cgroup/cpu/cpu.soft_domain
Domain-based scheduling binds cgroup to a NUMA node. nid identifies the NUMA node number using an offset of +1. For example, if the NUMA node number is 0, the value of nid is 1.
The CPU domain range defaults to the cluster level when domain-based scheduling is enabled. To configure the CPU domain range to the NUMA node level, set cpu.soft_domain_nr_cpu to the number of CPUs within the NUMA node.
1echo $numsCpu > /sys/fs/cgroup/cpu/cpu.soft_domain_nr_cpu
- Start one redis-server instance in each Docker container. That is, four redis-server instances are started.
1 2
cd path/redis-6.0.20 ./src/redis-server ./redis.conf --bind 0.0.0.0 --port 6379
- Perform the test as instructed in Performance Testing.
Affinity Configuration (Physical Machine Scenario)
- Run the following command on the physical machine:
1 2 3
cd /sys/fs/cgroup/cpu mkdir $dirname # dirname is a user-defined directory. echo $nid >/sys/fs/cgroup/cpu/$dirname/cpu.soft_domain
Domain-based scheduling binds cgroup to a NUMA node. nid identifies the NUMA node number using an offset of +1. For example, if the NUMA node number is 0, the value of nid is 1.
The CPU domain range defaults to the cluster level when domain-based scheduling is enabled. To configure the CPU domain range to the NUMA node level, set cpu.soft_domain_nr_cpu to the number of CPUs within the NUMA node.
1echo $numsCpu > /sys/fs/cgroup/cpu/$dirname/cpu.soft_domain_nr_cpu
- Start one redis-server instance in each Docker container. That is, four redis-server instances are started.
1 2
cd path/redis-6.0.20 cgexec -g cpu:$dirname ./src/redis-server ./redis.conf --bind 0.0.0.0 --port 6379
- Perform the test as instructed in Performance Testing.
Performance Testing
- Run the following command to check whether domain-based scheduling is enabled:
1cat /sys/kernel/debug/sched_features | grep -e SOFT_DOMAIN

1cat /sys/fs/cgroup/cpu/docker/*/cpu.soft_domainThe command output is not empty, and the following information is displayed:

- Go to the Redis directory on the client and prepare the stress test script. You can use the following script and modify parameters as needed.
Modify the following parameters as required:
- REDIS_PATH: Redis root directory
- REDIS_SERVER_IP_PREFIX: IP address subnet
- redis_server_ip_suffix: start IP address suffix
- instances: number of instances
- client: parameter of the -c option, set to the optimal number of concurrent connections
- size: parameter of the -d option, which is 3 (bytes) by default and can be changed to 256 or other values
#!/bin/bash REDIS_PATH="xxx1" # Redis directory REDIS_PORT=6379 REDIS_SERVER_IP_PREFIX="192.168.xx" redis_server_ip_suffix=128 # Start IP address suffix instances=4 # Number of instances client=200 # Parameter of -c size=3 # Parameter of -d, which is 3 by default # Stop the redis-benchmark process and clear test data logs. pkill redis-benchmark DATA_LOG="xxx2" # Directory for storing performance test results mkdir -p $DATA_LOG rm -rf ${DATA_LOG}/* # Perform the redis-benchmark stress test on the client. job_ids="" for (( instance=1; instance<=instances; instance++ )); do REDIS_SERVER_IP="${REDIS_SERVER_IP_PREFIX}.${redis_server_ip_suffix}" echo "Running redis-benchmark on ${REDIS_SERVER_IP}:$REDIS_PORT" echo "${REDIS_PATH}/src/redis-benchmark -h ${REDIS_SERVER_IP} -p $REDIS_PORT" ${REDIS_PATH}/src/redis-benchmark -h ${REDIS_SERVER_IP} -p $REDIS_PORT -c $client -d $size -n 10000000 -r 10000000 -t set,get --threads 20 -q >> ${DATA_LOG}/${instances}_c${client}_d${size}_${REDIS_SERVER_IP}_${REDIS_PORT}.log & job_ids="$job_ids $!" ((redis_server_ip_suffix++)) done # Wait for redis-benchmark to complete. echo "Waiting for the $instances jobs: SET, GET" wait $job_ids - Run the stress test script to perform the redis-benchmark test on the four instances simultaneously.
The performance test results are recorded in the DATA_LOG directory. Run the cat ./* command to view the results. The average performance of the four instances is the four-instance performance.