Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTP terminating tools comparison in tarantool (MacBook Pro 13 2017 3.5 Ghz Intel Core i7, 16GB)
worker_processes 8;
error_log logs/error.log info;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
keepalive_requests 256000;
keepalive_timeout 600s;
upstream tnt_backend {
server 127.0.0.1:3301;
keepalive 32;
}
upstream backend {
server 127.0.0.1:8089;
keepalive 32;
}
server {
listen 8080;
server_name localhost;
location /tnt {
tnt_http_rest_methods all;
tnt_pass_http_request off;
tnt_method rest;
tnt_buffer_size 1m;
tnt_pass tnt_backend;
}
location /tnt_proxy {
internal;
tnt_method process_request;
tnt_buffer_size 100k;
tnt_pass_http_request on parse_args;
tnt_method process_request;
tnt_pass tnt_backend;
}
location /http {
proxy_pass http://backend/;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /lua {
rewrite_by_lua '
local cjson = require("cjson")
local map = {
GET = ngx.HTTP_GET,
POST = ngx.HTTP_POST,
PUT = ngx.HTTP_PUT,
}
-- hide `{"params": [...]}` from a user
ngx.req.read_body()
local body = ngx.req.get_body_data()
if body then
body = "{\\"params\\": [" .. body .. "]}"
end
local res = ngx.location.capture("/tnt_proxy", {
args = ngx.var.args,
method = map[ngx.var.request_method],
body = body
})
if res.status == ngx.HTTP_OK then
local answ = cjson.decode(res.body)
-- Read reply
local result = answ["result"]
if result ~= nil then
ngx.status = result[1]
for k, v in pairs(result[2]) do
ngx.header[k] = v
end
table.remove(result, 1)
ngx.say(cjson.encode(result))
else
ngx.status = 502
ngx.say("Tarantool does not work")
end
-- Finalize execution
ngx.exit(ngx.OK)
else
ngx.status = res.status
ngx.say(res.body)
end
';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
#!/usr/bin/env tarantool
local http = require('http.server')
box.cfg {
listen = 3301,
log_level = 1,
readahead = 1280000,
}
box.once('init_security', function()
box.schema.user.grant('guest', 'read,write,execute', 'universe', nil, { if_not_exists = true })
box.schema.func.create('process_request', { setuid = true, if_not_exists = true })
box.schema.user.grant('guest', 'execute', 'function', 'process_request', { if_not_exists = true })
end)
local status = 200
local headers = {}
local body = 'ok'
function process_request()
return status, headers, body
end
local http_response = {
status = status,
headers = headers,
body = body,
}
local function http_handler()
return http_response
end
local httpd = http.new('0.0.0.0', 8089)
httpd:route({ path = '/', method = 'GET'}, http_handler)
httpd:start()
Threads Connections tnt (http.server module) Nginx (proxy_pass) + tnt (http.server module) nginx (tnt_upstream_module with lua processing) + tnt (iproto) nginx (tnt_upstream_module without lua processing) + tnt (iproto)
1 1 19687.36 11431.97 8072.30 8532.16
2 2 28235.58 16940.47 12478.30 15681.66
4 4 31354.27 20819.80 20147.92 24159.62
4 8 33253.24 21168.69 24626.17 33500.89
8 8 33175.44 21733.70 24293.68 25258.52
8 16 32344.75 20135.69 31501.70 36022.13

Software:

  • Nginx version: 1.15.9
  • MacOS Mojave: 10.14.3
  • Tarantool: 1.10.2-1-ge0017ad
  • wrk: [kqueue] Copyright (C) 2012 Will Glozer
nginx version: nginx/1.15.9
built by clang 10.0.0 (clang-1000.11.45.5)
built with OpenSSL 1.0.2q  20 Nov 2018
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx-full/1.15.9 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx-full/1.15.9/bin/nginx --with-cc-opt='-I/usr/local/include -I/usr/local/opt/pcre/include -I/usr/local/opt/openssl/include' --with-ld-opt='-L/usr/local/lib -L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --add-module=/usr/local/share/ngx-devel-kit --add-module=/usr/local/share/lua-nginx-module --add-module=/usr/local/share/tarantool-nginx-module --add-module=/usr/local/share/push-stream-nginx-module
Tarantool 1.10.2-1-ge0017ad
Target: Darwin-x86_64-Release
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/tarantool/1.10.2.1_2 -DENABLE_BACKTRACE=ON
Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++
C_FLAGS: -Wno-unknown-pragmas -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -msse2 -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts
CXX_FLAGS: -Wno-unknown-pragmas -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts

Hardware:

  • Model Name: MacBook Pro
  • Model Identifier: MacBookPro14,2
  • Processor Name: Intel Core i7
  • Processor Speed: 3,5 GHz
  • Number of Processors: 1
  • Total Number of Cores: 2
  • L2 Cache (per Core): 256 KB
  • L3 Cache: 4 MB
  • Memory: 16 GB
wrk -t1 -c1 -d1m http://localhost:8089/ \
&& sleep 5 \
&& wrk -t2 -c2 -d1m http://localhost:8089/ \
&& sleep 5 \
&& wrk -t4 -c4 -d1m http://localhost:8089/ \
&& sleep 5 \
&& wrk -t4 -c8 -d1m http://localhost:8089/ \
&& sleep 5 \
&& wrk -t8 -c8 -d1m http://localhost:8089/ \
&& sleep 5 \
&& wrk -t8 -c16 -d1m http://localhost:8089/ \
&& echo "Testing proxy_pass" \
&& sleep 5 \
&& wrk -t1 -c1 -d1m http://localhost:8080/http \
&& sleep 5 \
&& wrk -t2 -c2 -d1m http://localhost:8080/http \
&& sleep 5 \
&& wrk -t4 -c4 -d1m http://localhost:8080/http \
&& sleep 5 \
&& wrk -t4 -c8 -d1m http://localhost:8080/http \
&& sleep 5 \
&& wrk -t8 -c8 -d1m http://localhost:8080/http \
&& sleep 5 \
&& wrk -t8 -c16 -d1m http://localhost:8080/http \
&& echo "Testing tnt_upstream_module + lua" \
&& sleep 5 \
&& wrk -t1 -c1 -d1m http://localhost:8080/lua \
&& sleep 5 \
&& wrk -t2 -c2 -d1m http://localhost:8080/lua \
&& sleep 5 \
&& wrk -t4 -c4 -d1m http://localhost:8080/lua \
&& sleep 5 \
&& wrk -t4 -c8 -d1m http://localhost:8080/lua \
&& sleep 5 \
&& wrk -t8 -c8 -d1m http://localhost:8080/lua \
&& sleep 5 \
&& wrk -t8 -c16 -d1m http://localhost:8080/lua \
&& echo "Testing tnt_upstream_module without lua" \
&& sleep 5 \
&& wrk -t1 -c1 -d1m http://localhost:8080/tnt \
&& sleep 5 \
&& wrk -t2 -c2 -d1m http://localhost:8080/tnt \
&& sleep 5 \
&& wrk -t4 -c4 -d1m http://localhost:8080/tnt \
&& sleep 5 \
&& wrk -t4 -c8 -d1m http://localhost:8080/tnt \
&& sleep 5 \
&& wrk -t8 -c8 -d1m http://localhost:8080/tnt \
&& sleep 5 \
&& wrk -t8 -c16 -d1m http://localhost:8080/tnt
Running 1m test @ http://localhost:8089/
1 threads and 1 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 47.62us 14.17us 2.12ms 95.35%
Req/Sec 19.79k 0.91k 22.66k 89.18%
1183207 requests in 1.00m, 134.28MB read
Requests/sec: 19687.36
Transfer/sec: 2.23MB
Running 1m test @ http://localhost:8089/
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 74.33us 237.21us 20.79ms 99.77%
Req/Sec 14.19k 1.24k 15.42k 88.94%
1696952 requests in 1.00m, 192.58MB read
Requests/sec: 28235.58
Transfer/sec: 3.20MB
Running 1m test @ http://localhost:8089/
4 threads and 4 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 138.79us 437.18us 32.31ms 99.65%
Req/Sec 7.88k 2.70k 11.27k 56.04%
1882164 requests in 1.00m, 213.60MB read
Requests/sec: 31354.27
Transfer/sec: 3.56MB
Running 1m test @ http://localhost:8089/
4 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 241.00us 98.53us 4.63ms 81.80%
Req/Sec 8.35k 2.05k 9.96k 75.00%
1998519 requests in 1.00m, 226.81MB read
Requests/sec: 33253.24
Transfer/sec: 3.77MB
Running 1m test @ http://localhost:8089/
8 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 241.45us 97.22us 2.45ms 81.65%
Req/Sec 4.17k 1.03k 5.70k 74.81%
1993809 requests in 1.00m, 226.27MB read
Requests/sec: 33175.44
Transfer/sec: 3.76MB
Running 1m test @ http://localhost:8089/
8 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 497.50us 182.95us 11.02ms 87.41%
Req/Sec 4.06k 733.66 5.05k 86.35%
1943893 requests in 1.00m, 220.61MB read
Requests/sec: 32344.75
Transfer/sec: 3.67MB
Testing proxy_pass
Running 1m test @ http://localhost:8080/http
1 threads and 1 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 85.52us 67.61us 7.32ms 99.32%
Req/Sec 11.49k 829.96 12.78k 87.69%
687056 requests in 1.00m, 80.59MB read
Requests/sec: 11431.97
Transfer/sec: 1.34MB
Running 1m test @ http://localhost:8080/http
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 114.04us 25.53us 1.31ms 78.16%
Req/Sec 8.51k 319.95 9.31k 83.19%
1018111 requests in 1.00m, 119.43MB read
Requests/sec: 16940.47
Transfer/sec: 1.99MB
Running 1m test @ http://localhost:8080/http
4 threads and 4 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 188.63us 64.29us 2.06ms 75.45%
Req/Sec 5.23k 702.53 7.26k 69.05%
1251267 requests in 1.00m, 146.78MB read
Requests/sec: 20819.80
Transfer/sec: 2.44MB
Running 1m test @ http://localhost:8080/http
4 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 376.18us 151.62us 3.08ms 74.20%
Req/Sec 5.32k 533.22 6.80k 68.93%
1272229 requests in 1.00m, 149.23MB read
Requests/sec: 21168.69
Transfer/sec: 2.48MB
Running 1m test @ http://localhost:8080/http
8 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 367.26us 148.80us 3.43ms 74.84%
Req/Sec 2.73k 433.24 3.64k 64.08%
1306198 requests in 1.00m, 153.22MB read
Requests/sec: 21733.70
Transfer/sec: 2.55MB
Running 1m test @ http://localhost:8080/http
8 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 803.60us 429.53us 28.42ms 91.00%
Req/Sec 2.53k 426.52 14.86k 72.07%
1210237 requests in 1.00m, 141.96MB read
Requests/sec: 20135.69
Transfer/sec: 2.36MB
Testing tnt_upstream_module + lua
Running 1m test @ http://localhost:8080/lua
1 threads and 1 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 133.15us 227.44us 19.21ms 97.49%
Req/Sec 8.11k 1.56k 10.02k 71.83%
484399 requests in 1.00m, 87.77MB read
Requests/sec: 8072.30
Transfer/sec: 1.46MB
Running 1m test @ http://localhost:8080/lua
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 191.83us 630.26us 31.88ms 99.20%
Req/Sec 6.27k 0.95k 8.06k 76.92%
748866 requests in 1.00m, 135.69MB read
Requests/sec: 12478.30
Transfer/sec: 2.26MB
Running 1m test @ http://localhost:8080/lua
4 threads and 4 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 198.16us 104.50us 10.65ms 94.89%
Req/Sec 5.06k 760.63 7.05k 67.80%
1210885 requests in 1.00m, 219.41MB read
Requests/sec: 20147.92
Transfer/sec: 3.65MB
Running 1m test @ http://localhost:8080/lua
4 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 353.31us 361.30us 24.86ms 94.92%
Req/Sec 6.19k 1.08k 13.15k 69.55%
1480007 requests in 1.00m, 268.17MB read
Requests/sec: 24626.17
Transfer/sec: 4.46MB
Running 1m test @ http://localhost:8080/lua
8 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 574.23us 2.98ms 104.20ms 98.85%
Req/Sec 3.05k 642.05 4.16k 80.00%
1458551 requests in 1.00m, 264.29MB read
Requests/sec: 24293.68
Transfer/sec: 4.40MB
Running 1m test @ http://localhost:8080/lua
8 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 584.78us 1.29ms 62.81ms 98.71%
Req/Sec 3.96k 690.20 7.57k 75.67%
1893228 requests in 1.00m, 343.05MB read
Requests/sec: 31501.70
Transfer/sec: 5.71MB
Testing tnt_upstream_module without lua
Running 1m test @ http://localhost:8080/tnt
1 threads and 1 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 127.85us 356.36us 24.43ms 99.50%
Req/Sec 8.58k 1.07k 11.70k 83.00%
511953 requests in 1.00m, 101.06MB read
Requests/sec: 8532.16
Transfer/sec: 1.68MB
Running 1m test @ http://localhost:8080/tnt
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 160.30us 657.51us 30.59ms 99.39%
Req/Sec 7.88k 0.95k 8.79k 86.83%
941517 requests in 1.00m, 185.87MB read
Requests/sec: 15681.66
Transfer/sec: 3.10MB
Running 1m test @ http://localhost:8080/tnt
4 threads and 4 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 164.09us 141.73us 15.24ms 98.51%
Req/Sec 6.07k 592.58 8.18k 68.64%
1451983 requests in 1.00m, 286.64MB read
Requests/sec: 24159.62
Transfer/sec: 4.77MB
Running 1m test @ http://localhost:8080/tnt
4 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 238.49us 147.67us 13.79ms 96.82%
Req/Sec 8.42k 731.43 10.31k 88.51%
2013393 requests in 1.00m, 397.47MB read
Requests/sec: 33500.89
Transfer/sec: 6.61MB
Running 1m test @ http://localhost:8080/tnt
8 threads and 8 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 312.97us 71.56us 3.23ms 78.90%
Req/Sec 3.17k 189.32 3.82k 82.99%
1518033 requests in 1.00m, 299.68MB read
Requests/sec: 25258.52
Transfer/sec: 4.99MB
Running 1m test @ http://localhost:8080/tnt
8 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 470.08us 697.57us 43.42ms 98.66%
Req/Sec 4.53k 780.17 7.15k 70.72%
2165035 requests in 1.00m, 427.40MB read
Requests/sec: 36022.13
Transfer/sec: 7.11MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment