Skip to content

Commit

Permalink
Update experiment scripts to work in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
KinanBab committed May 14, 2023
1 parent 95c4ef1 commit 3acf731
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 23 deletions.
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN apt-get update && apt-get install -y \
libncursesw5-dev libreadline-dev libgdbm-dev libdb5.3-dev libbz2-dev \
libexpat1-dev liblzma-dev tk-dev libffi-dev wget gcc-11 g++-11 unzip \
openjdk-11-jdk maven python2 valgrind curl libclang-dev flex bison libevent-dev \
libsnappy-dev
libsnappy-dev netcat

RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 90 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
Expand Down Expand Up @@ -75,6 +75,10 @@ RUN mkdir -p /run/mysqld
RUN chown -R mysql:root /run/mysqld/
RUN useradd memcached

# configure mariadb datadir
RUN echo '[mysqld]' >> /etc/mysql/mariadb.cnf
RUN echo 'datadir = /var/lib/mysql' >> /etc/mysql/mariadb.cnf

# Do not copy, instead bind mount during docker run
RUN mkdir /home/k9db

Expand All @@ -86,14 +90,21 @@ RUN echo "test:tsan --test_env TSAN_OPTIONS=suppressions=/home/k9db/.tsan_jvm_su
# for GDPRBench, replace python with python2
RUN ln -s /usr/bin/python2 /usr/bin/python

# Latex for plotting
RUN apt-get update && apt-get install --no-install-recommends -y \
texlive-latex-base texlive-latex-extra \
texlive-fonts-recommended texlive-fonts-extra \
dvipng cm-super
RUN apt-get update && apt-get install -y python3-pip python3.8-venv

# configure mariadb on startup and run mysqld in the background
ADD configure_db.sql /home/configure_db.sql
ADD configure_db.sh /home/configure_db.sh
RUN chmod 750 /home/configure_db.sh
ADD configure_docker.sh /home/configure_docker.sh
RUN chmod 750 /home/configure_docker.sh

EXPOSE 10001/tcp
EXPOSE 3306/tcp

ENTRYPOINT /bin/bash ./home/configure_db.sh && /bin/bash
ENTRYPOINT /bin/bash ./home/configure_docker.sh && /bin/bash

# Run with docker run --mount type=bind,source=$(pwd),target=/home/k9db --name k9db -d -p 3306:3306 -p 10001:10001 -t k9db/latest
10 changes: 10 additions & 0 deletions configure_db.sh → configure_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,15 @@ if [[ -f "/home/configure_db.sql" ]]; then
cd /home/k9db/experiments/ownCloud && /root/.cargo/bin/cargo raze && cd -
cd /home/k9db/experiments/vote && /root/.cargo/bin/cargo raze && cd -

# Install plotting dependencies.
echo "Installing plotting dependencies ..."
cd /home/k9db/experiments/scripts/plotting
rm -rf __pycache__ venv
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt || /bin/true
deactivate
cd -

echo "Configuration done!"
fi
File renamed without changes.
40 changes: 36 additions & 4 deletions experiments/scripts/lobsters-endpoints-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,40 @@ echo "Writing plots and final outputs to $PLOT_OUT"
echo "Writing logs and temporary measurements to $LOG_OUT"
cd "${K9DB_DIR}/experiments/lobsters"

MEMCACHED_USER=""
if [[ "$(whoami)" == "root" ]]; then
MEMCACHED_USER="-u memcached"
fi

# Experiment parameters: you need to change the request scale `RS` parameter if
# running on a different configuration.
RT=120
DS=2.59 # Data scale: corresponds to 15k users
RS=1000 # request scale
INFLIGHT=""
# INFLIGHT="--in-flight=15"
TARGET_IP="$1"

#
# Build harness.
#
bazel build -c opt //:lobsters-harness

#
# Baseline
# Run lobsters harness against baseline, find DB size, find memcached memory
# overhead agaisnt DB.
#
echo "Running against baseline..."
bazel run -c opt //:lobsters-harness -- \
--runtime 0 --datascale $DS --reqscale $RS --queries pelton \
--backend rocks-mariadb --prime --scale_everything $INFLIGHT \
"mysql://k9db:password@$TARGET_IP:3306/lobsters" \
> "$LOG_OUT/baseline-prime.out" 2>&1

bazel run -c opt //:lobsters-harness -- \
--runtime $RT --datascale $DS --reqscale $RS --queries pelton \
--backend rocks-mariadb --prime --scale_everything \
--backend rocks-mariadb --scale_everything \
"mysql://k9db:password@$TARGET_IP:3306/lobsters" \
> "$LOG_OUT/baseline.out" 2>&1

Expand All @@ -39,11 +57,13 @@ echo "Running memcached experiment against baseline..."
cd "$K9DB_DIR/experiments/memcached"

# Run memcached server.
bazel run @memcached//:memcached --config=opt -- -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
bazel build @memcached//:memcached --config=opt
bazel run @memcached//:memcached --config=opt -- $MEMCACHED_USER -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
pid=$!
sleep 30

# Run memcached experiment
bazel build //memcached:memcached --config=opt
bazel run //memcached:memcached --config=opt -- --database=$TARGET_IP \
> "$LOG_OUT/memcached-memory.out" 2>&1
kill $pid
Expand All @@ -60,9 +80,15 @@ sleep 60

cd "${K9DB_DIR}/experiments/lobsters"
echo "Running against K9db..."
bazel run -c opt //:lobsters-harness -- \
--runtime 0 --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything $INFLIGHT \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/_prime_scale$DS.out" 2>&1

bazel run -c opt //:lobsters-harness -- \
--runtime $RT --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything \
--backend pelton --scale_everything \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/scale$DS.out" 2>&1

Expand All @@ -78,9 +104,15 @@ sleep 60
#

echo "Running against K9db (unencrypted)..."
bazel run -c opt //:lobsters-harness -- \
--runtime 0 --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything $INFLIGHT \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/unencrypted-prime.out" 2>&1

bazel run -c opt //:lobsters-harness -- \
--runtime $RT --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything \
--backend pelton --scale_everything \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/unencrypted.out" 2>&1

Expand Down
18 changes: 15 additions & 3 deletions experiments/scripts/lobsters-endpoints-server.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
mkdir -p /mnt/disks/my-ssd/k9db

# sudo is not available inside docker container
SUDO="sudo "
if [[ "$(whoami)" == "root" ]]; then
SUDO=""
fi

DB_IP=$LOCAL_IP
if [[ $LOCAL_IP == "" ]]; then
DB_IP="127.0.0.1"
Expand All @@ -9,14 +15,20 @@ fi
echo "Check load instance for output"
echo "Running server on $DB_IP:10001"

# Build K9db in opt mode.
bazel build //:k9db --config=opt

# Restart mariadb.
# Load script will now run the baseline load.
echo "MariaDB Baseline"
sudo service mariadb restart
./run.sh opt --hostname="$DB_IP:10001" # wait for kill signal from load
$SUDO service mariadb restart

# wait for kill signal from load
rm -rf /mnt/disks/my-ssd/k9db/k9db
bazel run //:k9db --config=opt -- --hostname="$DB_IP:10001" --db_path="/mnt/disks/my-ssd/k9db/"

# Baseline load done.
sudo service mariadb stop
$SUDO service mariadb stop

# Run encrypted K9db.
echo "K9db (encrypted)"
Expand Down
15 changes: 14 additions & 1 deletion experiments/scripts/lobsters-scale-load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ cd "${K9DB_DIR}/experiments/lobsters"
# running on a different configuration.
RT=120
RS=1000 # request scale
INFLIGHT=""
#INFLIGHT="--in-flight=5"
TARGET_IP="$1"

# Building harness.
bazel build -c opt //:lobsters-harness

# Loop over datascales
for DS in "1.72" "3.44" "4.31" "5.17" "6.89" "7.76" "8.62" "10.34" "12.9" "17.24"
do
echo "Running Datascale $DS..."
bazel run -c opt //:lobsters-harness -- \
--runtime 0 --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything $INFLIGHT \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/_prime_scale$DS.out" 2>&1

bazel run -c opt //:lobsters-harness -- \
--runtime $RT --datascale $DS --reqscale $RS --queries pelton \
--backend pelton --prime --scale_everything \
--backend pelton --scale_everything \
"mysql://root:password@$TARGET_IP:10001/lobsters" \
> "$LOG_OUT/scale$DS.out" 2>&1

Expand All @@ -41,3 +52,5 @@ echo "Experiment ran. Now plotting"
cd "${K9DB_DIR}/experiments/scripts/plotting"
. venv/bin/activate
python lobsters-scale.py --paper

echo "Success"
11 changes: 10 additions & 1 deletion experiments/scripts/lobsters-scale-server.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
mkdir -p /mnt/disks/my-ssd/k9db

# sudo is not available inside docker container
SUDO="sudo "
if [[ "$(whoami)" == "root" ]]; then
SUDO=""
fi

DB_IP=$LOCAL_IP
if [[ $LOCAL_IP == "" ]]; then
DB_IP="127.0.0.1"
Expand All @@ -9,8 +15,11 @@ fi
echo "Check load instance for output"
echo "Running server on $DB_IP:10001"

# Build K9db in opt mode.
bazel build //:k9db --config=opt

# Stop mariadb.
sudo service mariadb stop
$SUDO service mariadb stop

for DS in "1.72" "3.44" "4.31" "5.17" "6.89" "7.76" "8.62" "10.34" "12.9" "17.24"
do
Expand Down
23 changes: 19 additions & 4 deletions experiments/scripts/owncloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ echo "Writing plots and final outputs to $PLOT_OUT"
echo "Writing logs and temporary measurements to $LOG_OUT"
cd "${K9DB_DIR}/experiments/ownCloud"

# sudo is not available inside docker container
SUDO="sudo "
MEMCACHED_USER=""
if [[ "$(whoami)" == "root" ]]; then
SUDO=""
MEMCACHED_USER="-u memcached"
fi

# The database IP is either 127.0.0.1 or LOCAL_IP if running on gcloud.
DB_IP=$LOCAL_IP
if [[ $LOCAL_IP == "" ]]; then
Expand All @@ -30,13 +38,18 @@ write_every=19
ops=10000
zipf=0.6

#
# Building harness.
#
bazel build :benchmark -c opt

#
# Run against MariaDB baseline.
#
echo "Running against MariaDB..."

# Start MariaDB.
sudo service mariadb start
$SUDO service mariadb restart

# Run harness against MariaDB.
bazel run :benchmark -c opt -- \
Expand Down Expand Up @@ -65,7 +78,8 @@ mariadb -P3306 --host=$DB_IP -u k9db -ppassword \
echo "Running against MariaDB+memcached..."
cd "$K9DB_DIR/experiments/memcached"

bazel run @memcached//:memcached --config=opt -- -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
bazel build @memcached//:memcached --config=opt
bazel run @memcached//:memcached --config=opt -- $MEMCACHED_USER -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
pid=$!
sleep 30

Expand All @@ -92,7 +106,7 @@ echo "stats" | nc localhost 11211 -q 1 > "$LOG_OUT/memcached-memory.out" 2>&1

# Kill memcached and MariaDB.
kill $pid
sudo service mariadb stop
$SUDO service mariadb stop

#
# Run against K9db.
Expand All @@ -102,6 +116,7 @@ echo "Running against K9db..."
# Run K9db server.
cd ${K9DB_DIR}
rm -rf /mnt/disks/my-ssd/k9db/k9db
bazel build //:k9db --config=opt
bazel run //:k9db --config=opt -- --db_path="/mnt/disks/my-ssd/k9db/" \
> "$LOG_OUT/k9db-server.out" 2>&1 &
sleep 10
Expand Down Expand Up @@ -137,4 +152,4 @@ cd "${K9DB_DIR}/experiments/scripts/plotting"
. venv/bin/activate
python owncloud-comparison.py --paper

echo "Terminated"
echo "Success"
4 changes: 2 additions & 2 deletions experiments/scripts/setup/plotting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
cd experiments/scripts/plotting

# Install latex dependencies
sudo apt-get install -y texlive-latex-base texlive-fonts-recommended texlive-fonts-extra dvipng cm-super
sudo apt-get install -y texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra dvipng cm-super

# Install python3 virtualenv.
sudo apt-get install -y python3.8-venv
sudo apt-get install -y python3-pip python3.8-venv

# Create virtual env and install requirements
python3 -m venv venv
Expand Down
23 changes: 19 additions & 4 deletions experiments/scripts/votes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ echo "Writing plots and final outputs to $PLOT_OUT"
echo "Writing logs and temporary measurements to $LOG_OUT"
cd "${K9DB_DIR}/experiments/vote"

# sudo is not available inside docker container
SUDO="sudo "
MEMCACHED_USER=""
if [[ "$(whoami)" == "root" ]]; then
SUDO=""
MEMCACHED_USER="-u memcached"
fi

# The database IP is either 127.0.0.1 or LOCAL_IP if running on gcloud.
DB_IP=$LOCAL_IP
if [[ $LOCAL_IP == "" ]]; then
Expand All @@ -27,11 +35,16 @@ runtime=60
warmup=60
prime=30

#
# Build harness
#
bazel build :vote-benchmark -c opt

#
# MariaDB baseline
#
echo "Running against MariaDB..."
sudo service mariadb start
$SUDO service mariadb restart

# Baseline mariadb.
echo " Priming..."
Expand Down Expand Up @@ -60,7 +73,8 @@ echo "Running against MariaDB+memcached..."

# Running memcached server in background.
cd "$K9DB_DIR/experiments/memcached"
bazel run @memcached//:memcached --config=opt -- -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
bazel build @memcached//:memcached --config=opt
bazel run @memcached//:memcached --config=opt -- $MEMCACHED_USER -m 1024 -M > "$LOG_OUT/memcached-server.log" 2>&1 &
pid=$!
sleep 30

Expand Down Expand Up @@ -97,7 +111,7 @@ bazel run :vote-benchmark -c opt -- \

# Kill memcached and mariadb
kill $pid
sudo service mariadb stop
$SUDO service mariadb stop

#
# K9db.
Expand All @@ -108,6 +122,7 @@ echo "Running against K9db..."
# Running K9db server in background.
cd ${K9DB_DIR}
rm -rf /mnt/disks/my-ssd/k9db/k9db
bazel build //:k9db --config=opt
bazel run //:k9db --config=opt -- --db_path="/mnt/disks/my-ssd/k9db/" \
> "$LOG_OUT/k9db-server.out" 2>&1 &
sleep 10
Expand Down Expand Up @@ -144,4 +159,4 @@ cd "${K9DB_DIR}/experiments/scripts/plotting"
. venv/bin/activate
python votes.py --paper

echo "Terminated"
echo "Success"

0 comments on commit 3acf731

Please sign in to comment.