Skip to content

Instantly share code, notes, and snippets.

@Totktonada
Created February 10, 2021 05:26
Show Gist options
  • Save Totktonada/667b504bdad8cbc5777a0442d1181230 to your computer and use it in GitHub Desktop.
Save Totktonada/667b504bdad8cbc5777a0442d1181230 to your computer and use it in GitHub Desktop.
tarantool/http v1 vs v2 benchmarking

How to run

Prepare tarantool and modules builds:

git clone https://github.com/tarantool/http.git http-v1
cd http-v1
git checkout da1407c8e82dbdfd44abab8b1bb9860c217e7e22
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j
cd -

git clone https://github.com/tarantool/http.git http-v2
cd http-v2
git checkout e7e00ea0e9f668493ea8f222569b3d91c30b46f9
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j
cd -

git clone https://github.com/tarantool/http.git http-v2-adaptor-to-v1
cd http-v2-adaptor-to-v1
git checkout e69ef4fa21ed78c0941bf8f3b2b0501cd49277bd
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j
cd -

git clone --recursive https://github.com/tarantool/tarantool.git
cd tarantool
git checkout 1a01c906fe5f337dae0cf2f21738312c3a8a4c61
git submodule update --init --recursive
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_BACKTRACE=ON -DENABLE_DIST=ON && make -j
cd -

Prepare the system (varies across hardware and OS):

# close all heavy background applications like web-browser
grep -o intel_pstate=disable /proc/cmdline  # ensure pstate is disabled
cpupower -c all frequency-set -g userspace  # as root
cpupower -c all frequency-set -f 2.9GHz     # as root; no TurboBoost
sync && echo 3 > /proc/sys/vm/drop_caches   # as root

Run benchmarks:

./bench-v1.sh
./bench-v2.sh
./bench-v2-adaptor-to-v1.sh

Collect report:

./gen_report.sh

Credits

The benchmark is adapted from the comparison between the http server module and the nginx upstream module made by Ilya Konyukhov.

#!/bin/sh
set -exu
export LUA_PATH='./http-v1/?.lua;./http-v1/?/init.lua;;'
./tarantool/src/tarantool server-v1.lua > server-v1.log 2> server-v1.err &
for mode in 1:1 2:2 4:4 4:8 8:8; do
threads="${mode%:?}"
connections="${mode#?:}"
sleep 5
wrk --threads "${threads}" \
--connections "${connections}" \
--duration 1m \
http://localhost:8089 \
> "wrk-v1-t${threads}-c${connections}.log" \
2> "wrk-v1-t${threads}-c${connections}.err"
done
killall tarantool
wait
#!/bin/sh
set -exu
export LUA_PATH='./http-v2-adaptor-to-v1/?.lua;./http-v2-adaptor-to-v1/?/init.lua;;'
./tarantool/src/tarantool server-v1.lua > server-v2-adaptor-to-v1.log 2> server-v2-adaptor-to-v1.err &
for mode in 1:1 2:2 4:4 4:8 8:8; do
threads="${mode%:?}"
connections="${mode#?:}"
sleep 5
wrk --threads "${threads}" \
--connections "${connections}" \
--duration 1m \
http://localhost:8089 \
> "wrk-v2-adaptor-to-v1-t${threads}-c${connections}.log" \
2> "wrk-v2-adaptor-to-v1-t${threads}-c${connections}.err"
done
killall tarantool
wait
#!/bin/sh
set -exu
export LUA_PATH='./http-v2/?.lua;./http-v2/?/init.lua;;'
./tarantool/src/tarantool server-v2.lua > server-v2.log 2> server-v2.err &
for mode in 1:1 2:2 4:4 4:8 8:8; do
threads="${mode%:?}"
connections="${mode#?:}"
sleep 5
wrk --threads "${threads}" \
--connections "${connections}" \
--duration 1m \
http://localhost:8089 \
> "wrk-v2-t${threads}-c${connections}.log" \
2> "wrk-v2-t${threads}-c${connections}.err"
done
killall tarantool
wait
#!/bin/sh
grep Requests/sec wrk-v1-t*.log
printf '\n'
grep Requests/sec wrk-v2-t*.log
printf '\n'
grep Requests/sec wrk-v2-adaptor-to-v1-t*.log
printf '\n'
./tarantool/src/tarantool --version
printf '\n'
printf "http-v1: $(cd http-v1 && git describe --long --always)\n"
printf "http-v2: $(cd http-v2 && git describe --long --always)\n"
printf "http-v2-adaptor-to-v1: $(cd http-v2-adaptor-to-v1 && git describe --long --always)\n"
printf '\n'
uname -a
printf '\n'
cat /proc/cpuinfo
#!/usr/bin/env tarantool
local http = require('http.server')
local http_response = {
status = 200,
headers = {},
body = 'ok',
}
local httpd = http.new('0.0.0.0', 8089)
httpd:route({path='/', method='GET'}, function()
return http_response
end)
httpd:start()
#!/usr/bin/env tarantool
local http = require('http.server')
local router = require('http.router')
local http_response = {
status = 200,
headers = {},
body = 'ok',
}
local httpd = http.new('0.0.0.0', 8089)
local my_router = router.new()
httpd:set_router(my_router)
my_router:route({path='/', method='GET'}, function()
return http_response
end)
httpd:start()
@Totktonada
Copy link
Author

wrk-v1-t1-c1.log:Requests/sec: 33907.07
wrk-v1-t2-c2.log:Requests/sec: 33616.87
wrk-v1-t4-c4.log:Requests/sec: 30560.91
wrk-v1-t4-c8.log:Requests/sec: 30309.99
wrk-v1-t8-c8.log:Requests/sec: 28523.17

wrk-v2-t1-c1.log:Requests/sec: 25004.30
wrk-v2-t2-c2.log:Requests/sec: 24434.65
wrk-v2-t4-c4.log:Requests/sec: 24487.39
wrk-v2-t4-c8.log:Requests/sec: 24013.35
wrk-v2-t8-c8.log:Requests/sec: 23398.88

wrk-v2-adaptor-to-v1-t1-c1.log:Requests/sec: 20533.03
wrk-v2-adaptor-to-v1-t2-c2.log:Requests/sec: 19341.44
wrk-v2-adaptor-to-v1-t4-c4.log:Requests/sec: 19049.91
wrk-v2-adaptor-to-v1-t4-c8.log:Requests/sec: 20709.71
wrk-v2-adaptor-to-v1-t8-c8.log:Requests/sec: 18473.65

Tarantool 2.8.0-58-g1a01c906f
Target: Linux-x86_64-RelWithDebInfo
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=ON
Compiler: /usr/bin/cc /usr/bin/c++
C_FLAGS: -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type
CXX_FLAGS: -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type

http-v1: 1.1.0-0-gda1407c
http-v2: 2.1.0-18-ge7e00ea
http-v2-adaptor-to-v1: 2.1.0-19-ge69ef4f

Linux tkn_work_nb 5.4.10-gentoo #2 SMP Tue Feb 11 10:32:26 MSK 2020 x86_64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz GenuineIntel GNU/Linux

cat /proc/cpuinfo

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2390.576
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2389.926
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 1
cpu cores : 4
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2240.748
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 2
cpu cores : 4
apicid : 4
initial apicid : 4
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2279.454
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 3
cpu cores : 4
apicid : 6
initial apicid : 6
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 4
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2570.818
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 5
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 3180.728
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 1
cpu cores : 4
apicid : 3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 6
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2042.447
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 2
cpu cores : 4
apicid : 5
initial apicid : 5
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

processor : 7
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x5e
cpu MHz : 2315.901
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 3
cpu cores : 4
apicid : 7
initial apicid : 7
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips : 5799.77
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment