Redis Appendix
This guide covers deploying Redis with NVIDIA Accelerated IO (XLIO) using Worker Threads mode, focusing on best practices and recommended configurations for multithreaded applications.
Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. For more information about Redis, visit the official Redis website.
XLIO supports two complementary networking modes to optimize Redis performance based on its I/O threading model.
XLIO R2C mode – Optimized for Single-Threaded Redis
XLIO’s traditional R2C architecture leverages the application thread context to drive network operations. This mode is highly efficient for Redis deployments using a single I/O thread, where socket handling remains thread-affine and tightly coupled to application logic
XLIO Worker Threads Mode - Optimized for Multi-Threaded Redis
For Redis 6 and above versions that utilize multi-threaded I/O, XLIO’s Worker Threads mode is the recommended approach. In interduce a Dedicated XLIO worker threads for network processing, decoupling of network operations from application thread context and manage socket ownership and lifecycle across threads.
By aligning XLIO’s architecture with Redis’s threading model, users can achieve optimal performance and scalability across diverse deployment scenarios.
We recommend using stable, official versions of Redis. This example can be adapted to your specific requirements. For more information, see the Redis installation guide.
# Update package lists
sudo apt update
# Install build dependencies
sudo apt install -y build-essential tcl libssl-dev
# Clone Redis repository (using version 7.4 as example)
git clone https://github.com/redis/redis.git -b 7.4
cd redis
# Build Redis with TLS support
make BUILD_TLS=yes
# Test the build (recommended)
make test
It is recommended to use google/tcmalloc with XLIO for optimal performance.
This example can be adapted to your specific requirements.
Configuration File Example
# ===== Network Configuration =====
bind [SPECIFIC_IPV4_ADDR]
port [PORT]
# Maximum length of the queue for SYN state connections
# Should be equal to or less than net.core.somaxconn and net.core.netdev_max_backlog
# Default: 511
tcp-backlog 65535
# Close connection after client is idle for N seconds (0 to disable)
timeout 0
# TCP keepalive interval in seconds
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence of communication
tcp-keepalive 3000
# ===== Threading Configuration (Important for Worker Threads mode) =====
# Number of I/O threads
io-threads 6
# Enable threaded reads
io-threads-do-reads yes
# ===== Security =====
# Adjust as needed for your deployment
protected-mode no
# ===== Logging =====
loglevel verbose
For detailed instructions on optimally tuning your system for XLIO performance, refer to the XLIO Advanced Performance Tuning documentation.
Configure System Parameters:
Set the necessary system parameters for optimal performance:
# Set unlimited locked memory
ulimit -l unlimited
# Increase file descriptor limit
ulimit -n 1048576
# Configure network buffer sizes
sysctl -w net.core.rmem_default=1048576
sysctl -w net.core.rmem_max=2097152
sysctl -w net.core.wmem_default=1048576
sysctl -w net.core.wmem_max=2097152
# Configure TCP buffer sizes
sysctl -w net.ipv4.tcp_rmem="4096 1048576 2097152"
sysctl -w net.ipv4.tcp_wmem="4096 1048576 2097152"
Configure XLIO Environment Variables:
# Enable Worker Threads mode
export XLIO_THREAD_MODE=4
# Set memory limit (adjust according to available system memory)
export XLIO_MEMORY_LIMIT=8GB
# Configure receive work request entries
export XLIO_RX_WRE=2048
# Set stride queue stride size
export XLIO_STRQ_STRIDE_SIZE_BYTES=256
# Configure maximum GRO streams
export XLIO_GRO_STREAMS_MAX=4096
# Set completion queue poll batch maximum
export XLIO_CQ_POLL_BATCH_MAX=1024
# Add additional XLIO parameters as needed
# export <MORE_XLIO_PARAMS>
Launch Redis with XLIO:
LD_PRELOAD=/path/to/libxlio.so /path/to/redis-server /path/to/my_redis.conf
Running Redis Benchmark:
Key Benchmark Parameters
-h– Redis server host (default: 127.0.0.1)-p– Redis server port (default: 6379, use 443 for TLS)-c– Number of clients (parallel connections) to simulate (default: 50)-n– Total number of requests across all threads (default: 100000)-d– Data size for SET/GET values in bytes (default: 3)-t– Run only specific tests (e.g.,get,set)-k– Keep alive connections: 1=keep alive, 0=reconnect (default: 1)--threads– Number of benchmark threads
# Run SET benchmark with plaintext connection
numactl --cpunodebind=<node-attached-to-nic> \
redis-benchmark \
-t set \
-h <redis_server_ip> \
-p <redis_server_port> \
-n 1000000 \
-c 50 \
-d 100000 \
--threads 12
Use numactl to bind the benchmark to the NUMA node attached to your NIC for optimal performance.
XLIO offers additional optimization parameters that can be tuned for specific workloads.
For monitoring XLIO performance counters, refer to the Monitoring, Debugging, and Troubleshooting
When experiencing performance issues, verify the following on the client side:
Client-Side Checks:
CPU and Memory – Ensure the client is not CPU-bound or memory-constrained
Network Throughput – Verify the client can receive at full rate without packet drops
Retransmissions – Check that the client does not trigger excessive TCP retransmissions