Skip to content
Snippets Groups Projects
Commit e5a553cf authored by Peter Cai's avatar Peter Cai
Browse files

Add initial support for Nginx

parent 610d6814
No related branches found
No related tags found
No related merge requests found
NGINX=/opt/nginx/sbin/nginx
NGINX_FSTACK=/opt/nginx_fstack/sbin/nginx
NGINX_CLIENT=tilly02
NGINX_HOST=192.168.199.1
source "$EXP_ROOT/experiments/extra.shared.sh"
load_config() {
source "$EXP_ROOT/configs/nginx.sh"
}
nginx_pre_start() {
load_config
if [ "$CALADAN" == "true" ]; then
echo "No Nginx port for Caladan :/"
exit 1
elif [ "$FSTACK" == "true" ]; then
NGINX="$NGINX_FSTACK"
fi
NGINX_TMP_PREFIX="$(mktemp -d -p /tmp)"
cp "$EXP_ROOT/nginx.conf" "$NGINX_TMP_PREFIX"
cp "$EXP_ROOT/f-stack.conf" "$NGINX_TMP_PREFIX"
sed -i "s/{threads}/$THREADS/g" "$NGINX_TMP_PREFIX/nginx.conf"
sed -i "s/lcore_mask=1/lcore_mask=0x$(printf '%x' $((2 ** THREADS - 1)))/g" "$NGINX_TMP_PREFIX/f-stack.conf"
if [ "$FSTACK" == "true" ]; then
sed -i "s/#{fstack_only}#//g" "$NGINX_TMP_PREFIX/nginx.conf"
fi
EXPERIMENT_NAME_EXT="t$THREADS"
}
nginx_start() {
pkill -INT nginx || true
echo "taskset -c $FIRST_CPU-$((FIRST_CPU + THREADS - 1 - THREAD_TAIL_OFFSET)) $NGINX -c \"$NGINX_TMP_PREFIX/nginx.conf\""
taskset -c $FIRST_CPU-$((FIRST_CPU + THREADS - 1 - THREAD_TAIL_OFFSET)) $NGINX -c "$NGINX_TMP_PREFIX/nginx.conf" &
NGINX_PID=$!
sleep 60
}
nginx_warmup() {
echo "Warming up Nginx..."
sudo -u $SSH_USER ssh $NGINX_CLIENT wrk --latency --timeout 1m --duration 1m --threads 8 -c 1000 http://$NGINX_HOST/plaintext
}
nginx_bench() {
echo "Benchmarking Nginx with $1 connections"
perf_stat_start "$1"
sudo -u $SSH_USER ssh $NGINX_CLIENT wrk --latency --timeout 1m --duration 1m --threads 8 -c $1 http://$NGINX_HOST/plaintext | tee "$DATA_OUT/$1.txt"
perf_stat_stop
}
nginx_stop() {
pkill -INT "$NGINX_PID" || true
rm -rf "$NGINX_TMP_PREFIX" || true
}
source "$EXP_ROOT/experiments/nginx.shared.sh"
pre_start() {
nginx_pre_start
}
run_exp() {
nginx_start
nginx_warmup
nginx_bench 10000
nginx_stop
}
post_start() {
nginx_stop
}
user root;
worker_processes {threads};
daemon off;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
# path of f-stack configuration file
#{fstack_only}# fstack_conf f-stack.conf;
events {
worker_connections 102400;
#{fstack_only}# use kqueue;
multi_accept on;
}
http {
default_type text/plain;
sendfile off;
keepalive_timeout 65;
#gzip on;
server {
listen 80 backlog=4096;
server_name localhost default_server;
access_log off;
gzip off;
sendfile off;
tcp_nopush off;
tcp_nodelay off;
location /plaintext {
return 200 "Hello, world!";
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment