Skip to content

Commit e17d5fb

Browse files
jogmeSashan
authored andcommitted
Add haproxy to benchmarking tool
Adding as a proxy - a middle actor. Currently adding only for apache. Support all the encryption modes for haproxy: - client to proxy - proxy to server - client to server - pure http without encryption Signed-off-by: Norbert Pocs <norbertp@openssl.org> Reviewed-by: Saša Nedvědický <sashan@openssl.org> (Merged from #52)
1 parent 578f383 commit e17d5fb

File tree

3 files changed

+273
-8
lines changed

3 files changed

+273
-8
lines changed

bench-scripts/apache_bench.sh

Lines changed: 92 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ CERT_ALT_SUBJ=${BENCH_CERT_ALT_SUBJ:-'subjectAltName=DNS:localhost,IP:127.0.0.1'
6363
TEST_TIME=${BENCH_TEST_TIME:-'5M'}
6464
HOST=${BENCH_HOST:-'127.0.0.1'}
6565
APACHE_VERSION='2.4.65'
66+
HAPROXY='no'
6667

6768
. ./common_util.sh
69+
. ./haproxy_bench.sh
6870

6971
function install_wolfssl_for_apache {
7072
typeset VERSION=$1
@@ -810,18 +812,25 @@ function enable_mpm_prefork {
810812

811813
function run_test {
812814
typeset SSL_LIB=$1
813-
typeset HTTP='https'
815+
typeset HAPROXY=$2
814816
typeset i=0
815817
typeset PORT=${HTTPS_PORT}
818+
typeset PROTOCOL="https"
816819
if [[ -z "${SSL_LIB}" ]] ; then
817820
SSL_LIB='openssl-master'
818821
fi
822+
if [[ -z "${HAPROXY}" ]] ; then
823+
HAPROXY='no'
824+
fi
819825
typeset RESULTS="${SSL_LIB}".txt
820826
if [[ "${SSL_LIB}" = 'nossl' ]] ; then
821-
HTTP='http'
822827
SSL_LIB='openssl-master'
823828
RESULTS='nossl.txt'
824829
PORT=${HTTP_PORT}
830+
PROTOCOL="http"
831+
fi
832+
if [[ "${HAPROXY}" != 'no' ]] ; then
833+
RESULTS="haproxy-${SSL_LIB}-${HAPROXY}.txt"
825834
fi
826835
typeset HTDOCS="${INSTALL_ROOT}/${SSL_LIB}"/htdocs
827836
typeset SIEGE="${INSTALL_ROOT}"/openssl-master/bin/siege
@@ -839,11 +848,35 @@ function run_test {
839848
#
840849
# generate URLs for sewage
841850
#
851+
# The different modes for haproxy are:
852+
# no: client - server
853+
# no-ssl: client -http- haproxy -http- server
854+
# server: client -https- haproxy -http- server
855+
# client: client -http- haproxy -https- server
856+
# both: client -https- haproxy -https- server
857+
#
858+
# Otherwise said, haproxy is a client when it encrypts the outgoing encryption;
859+
# or it's client side.
860+
#
842861
rm -f siege_urls.txt
843862
for i in `ls -1 ${HTDOCS}/*.txt` ; do
844-
echo "${HTTP}://${HOST}:${PORT}/`basename $i`" >> siege_urls.txt
863+
if [[ "${HAPROXY}" = "no" ]] ; then
864+
echo "${PROTOCOL}://${HOST}:${PORT}/`basename $i`" >> siege_urls.txt
865+
elif [[ "${HAPROXY}" = "no-ssl" ]] ; then
866+
echo "http://${HOST}:${HAPROXY_NOSSL_PORT}/`basename $i`" >> siege_urls.txt
867+
elif [[ "${HAPROXY}" = "server" ]] ; then
868+
echo "https://${HOST}:${HAPROXY_C2P_PORT}/`basename $i`" >> siege_urls.txt
869+
elif [[ "${HAPROXY}" = "client" ]] ; then
870+
echo "http://${HOST}:${HAPROXY_P2S_PORT}/`basename $i`" >> siege_urls.txt
871+
elif [[ "${HAPROXY}" = "both" ]] ; then
872+
echo "https://${HOST}:${HAPROXY_C2S_PORT}/`basename $i`" >> siege_urls.txt
873+
fi
845874
done
846875

876+
if [[ "${HAPROXY}" = "server" ]] || [[ "${HAPROXY}" = "both" ]] ; then
877+
conf_siege_haproxy_cert $SSL_LIB
878+
fi
879+
847880
#
848881
# start apache httpd server
849882
#
@@ -856,13 +889,14 @@ function run_test {
856889
LD_LIBRARY_PATH=${INSTALL_ROOT}/openssl-master/lib "${SIEGE}" -t ${TEST_TIME} -b \
857890
-f siege_urls.txt 2> "${RESULT_DIR}/${RESULTS}"
858891
if [[ $? -ne 0 ]] ; then
859-
echo "${INSTALL_ROOT}/${SSL_LIB} can not run siege"
892+
echo "${INSTALL_ROOT}/${SSL_LIB} can not run siege"
860893
cat "${RESULT_DIR}/${RESULTS}"
861894
exit 1
862895
fi
863896

864897
LD_LIBRARY_PATH=${INSTALL_ROOT}/${SSL_LIB}/lib \
865898
${INSTALL_ROOT}/${SSL_LIB}/bin/httpd -k stop || exit 1
899+
sleep 1
866900
pgrep httpd
867901
while [[ $? -eq 0 ]] ; do
868902
sleep 1
@@ -881,20 +915,27 @@ function run_test {
881915
${RESULT_DIR}/httpd-${SSL_LIB}.conf
882916
cp ${INSTALL_ROOT}/${SSL_LIB}/conf/extra/httpd-ssl.conf \
883917
${RESULT_DIR}/httpd-ssl-${SSL_LIB}.conf
918+
919+
if [[ "${HAPROXY}" = "server" ]] || [[ "${HAPROXY}" = "both" ]] ; then
920+
unconf_siege_haproxy_cert
921+
fi
884922
}
885923

886924
function setup_tests {
925+
typeset i=0
887926
install_openssl master
888927
install_siege openssl-master
889928
install_apache openssl-master
890929
config_apache openssl-master
930+
install_haproxy openssl-master
891931
cd "${WORKSPACE_ROOT}"
892932
clean_build
893933

894934
for i in 3.0 3.1 3.2 3.3 3.4 3.5 3.6 ; do
895935
install_openssl openssl-$i ;
896936
install_apache openssl-$i
897937
config_apache openssl-$i
938+
install_haproxy openssl-$i
898939
cd "${WORKSPACE_ROOT}"
899940
clean_build
900941
done
@@ -967,6 +1008,8 @@ function setup_tests {
9671008

9681009
function run_tests {
9691010
typeset SAVE_RESULT_DIR="${RESULT_DIR}"
1011+
typeset HAPROXY_OPTIONS=('no' 'client' 'server' 'both')
1012+
typeset i=""
9701013

9711014
for i in event worker pre-fork ; do
9721015
mkdir -p ${RESULT_DIR}/$i || exit 1
@@ -975,12 +1018,25 @@ function run_tests {
9751018
enable_mpm_event
9761019
RESULT_DIR="${SAVE_RESULT_DIR}/event"
9771020
run_test nossl
1021+
run_haproxy
1022+
run_test nossl 'no-ssl'
1023+
kill_haproxy
9781024
for i in 3.0 3.1 3.2 3.3 3.4 3.5 3.6 ; do
9791025
enable_mpm_event openssl-${i}
980-
run_test openssl-${i}
1026+
run_haproxy openssl-${i}
1027+
for OPTION in ${HAPROXY_OPTIONS[@]}
1028+
do
1029+
run_test openssl-${i} ${OPTION}
1030+
done
1031+
kill_haproxy
9811032
done
9821033
enable_mpm_event openssl-master
983-
run_test openssl-master
1034+
run_haproxy openssl-master
1035+
for OPTION in ${HAPROXY_OPTIONS[@]}
1036+
do
1037+
run_test openssl-master ${OPTION}
1038+
done
1039+
kill_haproxy
9841040
enable_mpm_event OpenSSL_1_1_1-stable
9851041
run_test OpenSSL_1_1_1-stable
9861042
enable_mpm_event libressl-4.1.0
@@ -995,12 +1051,26 @@ function run_tests {
9951051
enable_mpm_worker
9961052
RESULT_DIR="${SAVE_RESULT_DIR}/worker"
9971053
run_test nossl
1054+
run_haproxy
1055+
run_test nossl 'no-ssl'
1056+
kill_haproxy
9981057
for i in 3.0 3.1 3.2 3.3 3.4 3.5 3.6 ; do
9991058
enable_mpm_worker openssl-${i}
10001059
run_test openssl-${i}
1060+
run_haproxy openssl-${i}
1061+
for OPTION in ${HAPROXY_OPTIONS[@]}
1062+
do
1063+
run_test openssl-${i} ${OPTION}
1064+
done
1065+
kill_haproxy
10011066
done
10021067
enable_mpm_worker openssl-master
1003-
run_test openssl-master
1068+
run_haproxy openssl-master
1069+
for OPTION in ${HAPROXY_OPTIONS[@]}
1070+
do
1071+
run_test openssl-master ${OPTION}
1072+
done
1073+
kill_haproxy
10041074
enable_mpm_worker OpenSSL_1_1_1-stable
10051075
run_test OpenSSL_1_1_1-stable
10061076
enable_mpm_worker libressl-4.1.0
@@ -1015,12 +1085,26 @@ function run_tests {
10151085
enable_mpm_prefork
10161086
RESULT_DIR="${SAVE_RESULT_DIR}/pre-fork"
10171087
run_test nossl
1088+
run_haproxy
1089+
run_test nossl 'no-ssl'
1090+
kill_haproxy
10181091
for i in 3.0 3.1 3.2 3.3 3.4 3.5 3.6 ; do
10191092
enable_mpm_prefork openssl-${i}
10201093
run_test openssl-${i}
1094+
run_haproxy openssl-${i}
1095+
for OPTION in ${HAPROXY_OPTIONS[@]}
1096+
do
1097+
run_test openssl-${i} ${OPTION}
1098+
done
1099+
kill_haproxy
10211100
done
10221101
enable_mpm_prefork openssl-master
1023-
run_test openssl-master
1102+
run_haproxy openssl-master
1103+
for OPTION in ${HAPROXY_OPTIONS[@]}
1104+
do
1105+
run_test openssl-master ${OPTION}
1106+
done
1107+
kill_haproxy
10241108
enable_mpm_prefork OpenSSL_1_1_1-stable
10251109
run_test OpenSSL_1_1_1-stable
10261110
enable_mpm_prefork libressl-4.1.0

bench-scripts/common_util.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function cleanup {
9292

9393
function clean_build {
9494
typeset SAVE_DIR=`pwd`
95+
typeset i=""
9596
cd "${WORKSPACE_ROOT}"
9697
for i in * ; do
9798
if [[ -d $i ]] ; then
@@ -292,6 +293,7 @@ set term png size 1600, 600
292293
set boxwidth 0.4
293294
set autoscale
294295
set output "${PNG_FILE}"
296+
set xtics rotate by 90 right
295297
plot "${DATA_FILE}" using 1:3:xtic(2) with boxes
296298
EOF
297299
gnuplot ${PLOT_FILE}
@@ -308,6 +310,7 @@ function plot_results {
308310

309311
function generate_download_files {
310312
typeset HTDOCS=$1
313+
typeset i=""
311314

312315
mkdir -p ${HTDOCS} || exit 1
313316

0 commit comments

Comments
 (0)