Compare commits
No commits in common. "6d9a140407c4e8919c6c83f6c3170eaf188a8008" and "8924f2ef22dd68208dcc145c3f1a7ddfd97812df" have entirely different histories.
6d9a140407
...
8924f2ef22
8 changed files with 33 additions and 116 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
||||||
kaproxy/nginx
|
|
||||||
kasvc/keepalive-svc
|
|
||||||
PROFILE.LOG
|
|
||||||
PROFILE.LOG.old
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
FROM archlinux:latest
|
FROM archlinux:latest
|
||||||
|
|
||||||
RUN pacman -Sy git base-devel curl luajit unzip --noconfirm
|
RUN pacman -Sy curl --noconfirm
|
||||||
|
|
||||||
RUN git clone https://github.com/wg/wrk
|
|
||||||
WORKDIR /wrk
|
|
||||||
RUN make
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
COPY run.sh /
|
COPY run.sh /
|
||||||
CMD ["/run.sh"]
|
CMD ["/run.sh"]
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function log_request_to () {
|
log_request () {
|
||||||
return_code=$(curl -Sikl -o /dev/null -w "%{http_code}" $1 2>/dev/null)
|
return_code=$(curl -Sikl -o /dev/null -w "%{http_code}" $1 2>/dev/null)
|
||||||
case ${return_code:0:1} in
|
case ${return_code:0:1} in
|
||||||
"4" | "5")
|
"4" | "5")
|
||||||
echo "query of $1 returned $return_code"
|
echo "query of $1 returned $return_code"
|
||||||
return 1
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
return 0
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_wrk_on () {
|
while :
|
||||||
/wrk/wrk -t1 -c10 $1 &
|
do
|
||||||
}
|
log_request "https://kaproxy:8080/0"
|
||||||
|
log_request "https://kaproxy:8080/1"
|
||||||
|
log_request "https://kaproxy:8080/2"
|
||||||
|
log_request "https://kaproxy:8080/3"
|
||||||
|
log_request "https://kaproxy:8080/4"
|
||||||
|
log_request "https://kaproxy:8080/5"
|
||||||
|
log_request "https://kaproxy:8080/6"
|
||||||
|
log_request "https://kaproxy:8080/7"
|
||||||
|
log_request "https://kaproxy:8080/8"
|
||||||
|
log_request "https://kaproxy:8080/9"
|
||||||
|
done
|
||||||
|
|
||||||
function sigint_handler() {
|
# TODO: use wrk2 or something to stress test endpoints I dunno
|
||||||
jobs -p | xargs kill -9
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
trap 'sigint_handler' INT
|
|
||||||
|
|
||||||
// TODO: make this a more elegant item
|
|
||||||
// maybe a while loop with curl
|
|
||||||
sleep 0.5
|
|
||||||
|
|
||||||
do_wrk_on "https://kaproxy:8080/0"
|
|
||||||
do_wrk_on "https://kaproxy:8080/1"
|
|
||||||
do_wrk_on "https://kaproxy:8080/2"
|
|
||||||
do_wrk_on "https://kaproxy:8080/3"
|
|
||||||
do_wrk_on "https://kaproxy:8080/4"
|
|
||||||
do_wrk_on "https://kaproxy:8080/5"
|
|
||||||
do_wrk_on "https://kaproxy:8080/6"
|
|
||||||
do_wrk_on "https://kaproxy:8080/7"
|
|
||||||
do_wrk_on "https://kaproxy:8080/8"
|
|
||||||
do_wrk_on "https://kaproxy:8080/9"
|
|
||||||
|
|
||||||
wait $(jobs -p)
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ FROM archlinux:latest
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN pacman -Syyu --noconfirm
|
RUN pacman -Syyu --noconfirm
|
||||||
RUN pacman -S base-devel glibc gcc-libs valgrind --noconfirm
|
RUN pacman -S base-devel glibc gcc-libs perf --noconfirm
|
||||||
COPY nginx /nginx
|
COPY nginx /nginx
|
||||||
WORKDIR /nginx
|
WORKDIR /nginx
|
||||||
RUN auto/configure \
|
RUN auto/configure \
|
||||||
--with-debug \
|
--with-debug \
|
||||||
--with-http_ssl_module \
|
--with-http_ssl_module \
|
||||||
--with-cc-opt="-gdwarf-4 -fno-omit-frame-pointer"
|
--with-cc-opt="-ggdb -fno-omit-frame-pointer"
|
||||||
RUN make
|
RUN make
|
||||||
RUN make install
|
RUN make install
|
||||||
COPY nginx.conf /
|
COPY nginx.conf /
|
||||||
|
|
|
||||||
1
kaproxy/nginx
Submodule
1
kaproxy/nginx
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 64d0795ac41836b6be8fcceba68f1dbb62b4035a
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
worker_processes 10;
|
worker_processes 5;
|
||||||
error_log /dev/stdout notice;
|
error_log /dev/stdout notice;
|
||||||
pid /tmp/pid;
|
pid /tmp/pid;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 10;
|
worker_connections 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function p_invoke() {
|
function p_invoke() {
|
||||||
# set trace-children=yes to profile worker processes
|
perf record -F1000 --call-graph dwarf -o /perf.data \
|
||||||
valgrind --tool=callgrind \
|
-- /nginx/objs/nginx \
|
||||||
--trace-children=no \
|
|
||||||
--callgrind-out-file=/tmp/callgrind.output \
|
|
||||||
/nginx/objs/nginx \
|
|
||||||
-p /tmp \
|
-p /tmp \
|
||||||
-e /tmp/error.log \
|
-e /tmp/error.log \
|
||||||
-c /nginx.conf \
|
-c /nginx.conf \
|
||||||
|
|
|
||||||
62
run.sh
62
run.sh
|
|
@ -1,63 +1,5 @@
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
if [[ ! $1 ]]; then
|
|
||||||
echo "Error: expected one argument (nginx code directory)"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d $1 ]]; then
|
|
||||||
echo "Error: provided nginx code directory is invalid"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
PROFILE_OUTPUT=PROFILE.LOG
|
|
||||||
if [ -f $PROFILE_OUTPUT ]; then
|
|
||||||
mv $PROFILE_OUTPUT $PROFILE_OUTPUT.old
|
|
||||||
fi
|
|
||||||
|
|
||||||
KACLIENT=nginx-profile-setup-kaclient-1
|
|
||||||
KAPROXY=nginx-profile-setup-kaproxy-1
|
|
||||||
|
|
||||||
echo "[+] building and deploying containers"
|
|
||||||
go build keepalive-svc.go
|
go build keepalive-svc.go
|
||||||
mv keepalive-svc kasvc/
|
mv keepalive-svc kasvc/
|
||||||
rsync -avz $1 kaproxy/
|
rsync -avz ../nginx kaproxy/
|
||||||
sudo docker-compose up --build -d
|
sudo docker-compose up --build
|
||||||
sudo docker exec -it $KAPROXY callgrind_control -i off
|
|
||||||
|
|
||||||
sudo docker wait $KACLIENT
|
|
||||||
echo "[+] client finished, triggering reload"
|
|
||||||
sudo docker exec -it $KAPROXY callgrind_control -i on
|
|
||||||
sudo docker kill -s CONT $KAPROXY
|
|
||||||
|
|
||||||
echo "[+] wait five seconds for reload complete"
|
|
||||||
sleep 5
|
|
||||||
sudo docker exec -it $KAPROXY callgrind_control -i off
|
|
||||||
|
|
||||||
echo " > restarting client"
|
|
||||||
sudo docker-compose restart kaclient
|
|
||||||
sudo docker wait $KACLIENT
|
|
||||||
|
|
||||||
echo "[+] client finished again. Killing NGINX and fetching profile data"
|
|
||||||
sudo docker kill -s INT $KAPROXY
|
|
||||||
sudo docker exec -it $KAPROXY callgrind_control -d
|
|
||||||
|
|
||||||
echo "[+] building profiling report"
|
|
||||||
sudo docker exec $KAPROXY bash -c "find /tmp -iname \"callgrind.out*\"" | while read file
|
|
||||||
do
|
|
||||||
echo " > processing: " $file
|
|
||||||
F=$(basename $file)
|
|
||||||
sudo docker cp $KAPROXY:$file $F;
|
|
||||||
sudo chmod 777 $F
|
|
||||||
echo "Output file: $F" >> $PROFILE_OUTPUT
|
|
||||||
callgrind_annotate \
|
|
||||||
--include=kaproxy \
|
|
||||||
--auto=yes \
|
|
||||||
$F >> $PROFILE_OUTPUT
|
|
||||||
echo "End of profile: $F\n\n\n" >> $PROFILE_OUTPUT
|
|
||||||
rm -f $F
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "[+] cleaning up"
|
|
||||||
sudo docker-compose down
|
|
||||||
less $PROFILE_OUTPUT
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue