Skip to content

Instantly share code, notes, and snippets.

@danielealbano
Last active February 13, 2021 16:09
Show Gist options
  • Save danielealbano/10a4204e18b8327d12e6ba0a79491ed3 to your computer and use it in GitHub Desktop.
Save danielealbano/10a4204e18b8327d12e6ba0a79491ed3 to your computer and use it in GitHub Desktop.
cachegrand / redis / keydb benchmark general instructions
# INITIAL SETUP (for both testers and main server)
# Install required packages
sudo apt update && \
sudo apt upgrade -y && \
sudo apt install -y git wget curl build-essential gdb cmake libevent-dev autoconf automake libpcre3-dev libevent-dev pkg-config zlib1g-dev libssl-dev
# UPGRADE UBUNTU KERNEL TO 5.10.15
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh && \
chmod +x ubuntu-mainline-kernel.sh && \
sudo mv ubuntu-mainline-kernel.sh /usr/local/bin/ && \
sudo /usr/local/bin/ubuntu-mainline-kernel.sh -i v5.10.15
# Create sources dir
mkdir ~/dev
---
# build and run cachegrand
cd ~/dev
git clone https://github.com/danielealbano/cachegrand.git
cd cachegrand
git submodule update --init --recursive
mkdir cmake-build
cd cmake-build
cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_HASHTABLE_HASH_ALGORITHM_T1HA2=1 -DBUILD_TESTS=1 -DBUILD_INTERNAL_BENCHES=1
cmake --build . --target cachegrand-server -- -j 32
sudo su -
ulimit -n 65000
ulimit -Hn 65000
# may be necessary to increase the memlock as well
cd /home/USER/dev/cachegrand/cmake-build/src
# currently cachegrand will bind on 12345 and allow up to 512 connections per thread
# spawining one thread per hardware thread supported
# so if 12 threads, 6144 connections in total but with a limit of 512 per thread
# currently the config logic is DUMB and the value is hardcoded in src/program.h
# the pinning logic is also DUMB currently and should be set via the config file
./cachegrand-server
---
when testing redis remember to pass
--protected-mode off
when testing keydb remember to pass
--protected-mode off
--server-threads __N_THREADS__
--server-thread-affinity true
---
cd ~/dev
git clone https://github.com/RedisLabs/memtier_benchmark.git
cd memtier_benchmark
autoreconf -ivf
./configure
make
# replace __N_THREADS__ with the number of threads that the machine can run in parallel
# replace __IP__ with the ip address of the machine running the server
# for cachegrand
./memtier_benchmark -p 12345 -s __IP__ -P redis --print-percentiles=25,50,75,99,99.9 --clients=128 --threads=__N_THREADS__ --command="ping" -n 10000 -x 5
# for redis / keydb (different port)
./memtier_benchmark -p 6379 -s __IP__ -P redis --print-percentiles=25,50,75,99,99.9 --clients=128 --threads=__N_THREADS__ --command="ping" -n 10000 -x 5
# memtier_benchmark uses threads to simulate the clients, when running everything on the same machine
# while redis is only marginally impacted by this approach both cachegrand and keydb are strongly affected
# Also keep in mind that even if the packets payload is minimal (about 16 bytes for the PING/PONG commands
# and replies) the actual amount of data will be inflated by the tcp/ip and the ethernet frames headers
# and to get over a 1mln of commands per second it may be necessary a +1gbit NIC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment