baseline
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- Shared header config; required by s2/s3/s4 scripts.
|
||||
-- Override BEARER / HOST via env vars when invoking wrk2.
|
||||
|
||||
local M = {}
|
||||
M.token = os.getenv("BEARER") or "test-token-aaaaaaaaaaaaaaaaaaaa"
|
||||
M.host = os.getenv("HOST") or "127.0.0.1:8080"
|
||||
M.headers = {
|
||||
["Authorization"] = "Bearer " .. M.token,
|
||||
["Connection"] = "keep-alive",
|
||||
["Host"] = M.host,
|
||||
}
|
||||
return M
|
||||
@@ -0,0 +1,5 @@
|
||||
-- S1: naked /ping. No auth header (the server's auth_plug exempts /ping,
|
||||
-- so sending a header would just add noise to the comparison).
|
||||
wrk.method = "GET"
|
||||
wrk.path = "/ping"
|
||||
wrk.headers["Connection"] = "keep-alive"
|
||||
@@ -0,0 +1,13 @@
|
||||
-- S2: single-route GET with full middleware (logger + request_id + auth).
|
||||
-- :id is spread across 10_000 values to defeat per-id caching.
|
||||
|
||||
local common = require("common")
|
||||
wrk.method = "GET"
|
||||
wrk.headers = common.headers
|
||||
|
||||
math.randomseed(os.time() + os.getpid())
|
||||
|
||||
request = function()
|
||||
local id = math.random(1, 10000)
|
||||
return wrk.format(nil, "/api/v1/users/" .. id)
|
||||
end
|
||||
@@ -0,0 +1,30 @@
|
||||
-- S3 (+S4): 80% GET single / 15% GET list / 5% POST.
|
||||
-- The mix exposes the store-actor channel round-trip on urus, mutex
|
||||
-- contention on axum, and gen_server message-pass on cowboy without
|
||||
-- making writes the bottleneck.
|
||||
|
||||
local common = require("common")
|
||||
wrk.headers = common.headers
|
||||
wrk.headers["Content-Type"] = "application/json"
|
||||
|
||||
math.randomseed(os.time() + os.getpid())
|
||||
|
||||
-- A small pool of pre-built JSON bodies. Building one fresh per request
|
||||
-- in Lua would taint the bench with Lua's GC overhead.
|
||||
local body_pool = {}
|
||||
for i = 1, 64 do
|
||||
body_pool[i] = string.format(
|
||||
[[{"name":"user%d","email":"u%d@example.test"}]], i, i)
|
||||
end
|
||||
|
||||
request = function()
|
||||
local r = math.random()
|
||||
if r < 0.80 then
|
||||
return wrk.format("GET", "/api/v1/users/" .. math.random(1, 10000))
|
||||
elseif r < 0.95 then
|
||||
return wrk.format("GET", "/api/v1/users")
|
||||
else
|
||||
local body = body_pool[math.random(1, #body_pool)]
|
||||
return wrk.format("POST", "/api/v1/users", nil, body)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user