Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ components_manager:
hello-world-db:
dbconnection#env: DATABASE_URL # HttpArena benchmark env
dbconnection#fallback: postgresql://bench:bench@localhost:5432/benchmark?sslmode=disable # local dev
min_pool_size: 64
min_pool_size#env: DATABASE_MAX_CONN # pre-warm all connections at startup
min_pool_size#fallback: 256 # local dev
max_pool_size#env: DATABASE_MAX_CONN # HttpArena benchmark env (set to 256)
max_pool_size#fallback: 256 # local dev
# min == max: pre-warm all connections at startup for benchmark
blocking_task_processor: fs-task-processor
max_queue_size: 512
connecting_limit: 15
max_queue_size: 4096
connecting_limit: 256
ignore_unused_query_params: true
connlimit_mode: manual
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#include <userver/http/common_headers.hpp>
#include <userver/storages/postgres/cluster.hpp>
#include <userver/storages/postgres/component.hpp>
#include <userver/storages/postgres/io/json_types.hpp>
#include <userver/storages/postgres/result_set.hpp>

namespace userver_httparena::async_db {
namespace {
struct ItemRow {
int64_t id;
std::string name;
std::string category;
std::string_view name;
std::string_view category;
int64_t price;
int64_t quantity;
bool active;
Expand Down Expand Up @@ -48,24 +47,23 @@ std::string Handler::HandleRequestThrow(const userver::server::http::HttpRequest

// Matches
// https://www.http-arena.com/docs/test-profiles/h1/isolated/async-database/implementation/
// kSlave falls back to master if no read replica is available
auto res = pg_->Execute(userver::storages::postgres::ClusterHostType::kSlave,
auto res = pg_->Execute(userver::storages::postgres::ClusterHostType::kSlaveOrMaster,
"SELECT id, name, category, price, quantity, active, tags, "
"rating_score, rating_count FROM items "
"WHERE price BETWEEN $1 AND $2 LIMIT $3",
min, max, limit);

const auto rows = res.AsContainer<std::vector<ItemRow> >(userver::storages::postgres::kRowTag);
auto items = res.AsSetOf<ItemRow>(userver::storages::postgres::kRowTag);

userver::formats::json::StringBuilder sb;
{
userver::formats::json::StringBuilder::ObjectGuard root_guard(sb);
sb.Key("count");
sb.WriteInt64(static_cast<int64_t>(rows.size()));
sb.WriteInt64(static_cast<int64_t>(items.Size()));
sb.Key("items");
{
userver::formats::json::StringBuilder::ArrayGuard items_guard(sb);
for (const auto& row : rows) {
for (const auto& row : items) {
userver::formats::json::StringBuilder::ObjectGuard item_guard(sb);
sb.Key("id");
sb.WriteInt64(row.id);
Expand Down
26 changes: 26 additions & 0 deletions site/data/api-16-1024.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,32 @@
"tpl_static": 0,
"tpl_async_db": 572974
},
{
"framework": "userver",
"language": "C++",
"rps": 137828,
"avg_latency": "6.86ms",
"p99_latency": "35.00ms",
"cpu": "1779.9%",
"memory": "373MiB",
"connections": 1024,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "411.95MB/s",
"input_bw": "7.76MB/s",
"reconnects": 413290,
"status_2xx": 2067430,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0,
"tpl_baseline": 774549,
"tpl_json": 776048,
"tpl_db": 0,
"tpl_upload": 0,
"tpl_static": 0,
"tpl_async_db": 516832
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
26 changes: 26 additions & 0 deletions site/data/api-4-256.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,32 @@
"tpl_static": 0,
"tpl_async_db": 210990
},
{
"framework": "userver",
"language": "C++",
"rps": 59270,
"avg_latency": "3.79ms",
"p99_latency": "29.50ms",
"cpu": "403.6%",
"memory": "203MiB",
"connections": 256,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "177.10MB/s",
"input_bw": "3.33MB/s",
"reconnects": 177804,
"status_2xx": 889058,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0,
"tpl_baseline": 333335,
"tpl_json": 333509,
"tpl_db": 0,
"tpl_upload": 0,
"tpl_static": 0,
"tpl_async_db": 222213
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
20 changes: 20 additions & 0 deletions site/data/async-db-1024.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,26 @@
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "userver",
"language": "C++",
"rps": 236485,
"avg_latency": "3.75ms",
"p99_latency": "11.00ms",
"cpu": "5559.7%",
"memory": "300MiB",
"connections": 1024,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "912.03MB/s",
"input_bw": "15.79MB/s",
"reconnects": 94584,
"status_2xx": 2364854,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
16 changes: 8 additions & 8 deletions site/data/baseline-4096.json
Original file line number Diff line number Diff line change
Expand Up @@ -1428,19 +1428,19 @@
{
"framework": "userver",
"language": "C++",
"rps": 978241,
"avg_latency": "4.19ms",
"p99_latency": "13.40ms",
"cpu": "6153.4%",
"memory": "445MiB",
"rps": 1053894,
"avg_latency": "3.89ms",
"p99_latency": "9.33ms",
"cpu": "6401.3%",
"memory": "411MiB",
"connections": 4096,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "134.31MB/s",
"input_bw": "75.57MB/s",
"bandwidth": "144.70MB/s",
"input_bw": "81.41MB/s",
"reconnects": 0,
"status_2xx": 4891208,
"status_2xx": 5269470,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
Expand Down
16 changes: 8 additions & 8 deletions site/data/baseline-512.json
Original file line number Diff line number Diff line change
Expand Up @@ -1428,19 +1428,19 @@
{
"framework": "userver",
"language": "C++",
"rps": 602547,
"avg_latency": "852us",
"p99_latency": "3.42ms",
"cpu": "6004.9%",
"memory": "199MiB",
"rps": 882230,
"avg_latency": "579us",
"p99_latency": "3.55ms",
"cpu": "6417.0%",
"memory": "220MiB",
"connections": 512,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "82.73MB/s",
"input_bw": "46.55MB/s",
"bandwidth": "121.13MB/s",
"input_bw": "68.15MB/s",
"reconnects": 0,
"status_2xx": 3012738,
"status_2xx": 4411153,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
Expand Down
20 changes: 20 additions & 0 deletions site/data/json-4096.json
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,26 @@
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "userver",
"language": "C++",
"rps": 824264,
"avg_latency": "4.90ms",
"p99_latency": "11.50ms",
"cpu": "6336.2%",
"memory": "532MiB",
"connections": 4096,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "974.43MB/s",
"input_bw": "39.30MB/s",
"reconnects": 163267,
"status_2xx": 4121324,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
20 changes: 20 additions & 0 deletions site/data/json-comp-16384.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,26 @@
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "userver",
"language": "C++",
"rps": 485067,
"avg_latency": "32.61ms",
"p99_latency": "122.40ms",
"cpu": "6493.6%",
"memory": "1.5GiB",
"connections": 16384,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "309.53MB/s",
"input_bw": "36.08MB/s",
"reconnects": 89322,
"status_2xx": 2425337,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
20 changes: 20 additions & 0 deletions site/data/json-comp-4096.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,26 @@
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "userver",
"language": "C++",
"rps": 495304,
"avg_latency": "8.23ms",
"p99_latency": "17.50ms",
"cpu": "6370.6%",
"memory": "556MiB",
"connections": 4096,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "316.07MB/s",
"input_bw": "36.84MB/s",
"reconnects": 97245,
"status_2xx": 2476520,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
20 changes: 20 additions & 0 deletions site/data/json-comp-512.json
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,26 @@
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "userver",
"language": "C++",
"rps": 495502,
"avg_latency": "1.02ms",
"p99_latency": "4.19ms",
"cpu": "6541.9%",
"memory": "248MiB",
"connections": 512,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "316.20MB/s",
"input_bw": "36.86MB/s",
"reconnects": 99102,
"status_2xx": 2477512,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
{
"framework": "uvicorn",
"language": "Python",
Expand Down
18 changes: 9 additions & 9 deletions site/data/limited-conn-4096.json
Original file line number Diff line number Diff line change
Expand Up @@ -1428,19 +1428,19 @@
{
"framework": "userver",
"language": "C++",
"rps": 850039,
"avg_latency": "4.81ms",
"p99_latency": "15.50ms",
"cpu": "6090.8%",
"memory": "578MiB",
"rps": 886892,
"avg_latency": "4.63ms",
"p99_latency": "12.90ms",
"cpu": "6261.2%",
"memory": "603MiB",
"connections": 4096,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "116.69MB/s",
"input_bw": "65.66MB/s",
"reconnects": 423697,
"status_2xx": 4250195,
"bandwidth": "121.75MB/s",
"input_bw": "68.51MB/s",
"reconnects": 441759,
"status_2xx": 4434464,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
Expand Down
16 changes: 8 additions & 8 deletions site/data/limited-conn-512.json
Original file line number Diff line number Diff line change
Expand Up @@ -1428,19 +1428,19 @@
{
"framework": "userver",
"language": "C++",
"rps": 701718,
"avg_latency": "720us",
"rps": 736506,
"avg_latency": "686us",
"p99_latency": "3.98ms",
"cpu": "5875.4%",
"memory": "240MiB",
"cpu": "6086.3%",
"memory": "246MiB",
"connections": 512,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "96.34MB/s",
"input_bw": "54.21MB/s",
"reconnects": 350772,
"status_2xx": 3508594,
"bandwidth": "101.12MB/s",
"input_bw": "56.89MB/s",
"reconnects": 368248,
"status_2xx": 3682530,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
Expand Down
Loading