[examples] Update NGinx template and add wrk random paths script
This commit is contained in:
parent
95f1a119ea
commit
502d292f17
2 changed files with 40 additions and 3 deletions
|
@ -20,7 +20,7 @@ http {
|
||||||
server {
|
server {
|
||||||
|
|
||||||
|
|
||||||
listen 127.0.0.1:8080 default_server bind reuseport backlog=4096;
|
listen 127.0.0.1:8080 default_server bind backlog=65536;
|
||||||
|
|
||||||
server_name nginx;
|
server_name nginx;
|
||||||
server_name_in_redirect off;
|
server_name_in_redirect off;
|
||||||
|
@ -69,7 +69,7 @@ http {
|
||||||
|
|
||||||
|
|
||||||
worker_processes 2;
|
worker_processes 2;
|
||||||
worker_rlimit_nofile 8192;
|
worker_rlimit_nofile 131072;
|
||||||
working_directory @{nginx}/empty;
|
working_directory @{nginx}/empty;
|
||||||
|
|
||||||
error_log /dev/stderr notice;
|
error_log /dev/stderr notice;
|
||||||
|
@ -79,7 +79,7 @@ daemon off;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
use epoll;
|
use epoll;
|
||||||
worker_connections 4224;
|
worker_connections 16640;
|
||||||
accept_mutex off;
|
accept_mutex off;
|
||||||
multi_accept off;
|
multi_accept off;
|
||||||
}
|
}
|
||||||
|
|
37
examples/wrk-paths-from-file.lua
Normal file
37
examples/wrk-paths-from-file.lua
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
|
||||||
|
local _generated_requests = {}
|
||||||
|
|
||||||
|
|
||||||
|
function init (_arguments)
|
||||||
|
for _index, _argument in ipairs (_arguments) do
|
||||||
|
_generate_requests (_generated_requests, _argument)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function request ()
|
||||||
|
local _index = math.random (#_generated_requests)
|
||||||
|
return _generated_requests[_index]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function _generate_requests (_requests, _path)
|
||||||
|
local _tid = wrk.thread.tindex .. "/" .. wrk.thread.tcount
|
||||||
|
print ("[ii] [" .. _tid .. "] loading paths from `" .. _path .. "`...")
|
||||||
|
local _index = 0
|
||||||
|
local _wrk_path_prefix = wrk.path:gsub ("/$", "")
|
||||||
|
for _wrk_path_suffix in io.lines (_path) do
|
||||||
|
if math.fmod (_index, wrk.thread.tcount) == wrk.thread.tindex then
|
||||||
|
if not _wrk_path_suffix:match ("/$") then
|
||||||
|
_wrk_path_suffix = _wrk_path_suffix:gsub ("^/", "")
|
||||||
|
_wrk_path = _wrk_path_prefix .. "/" .. _wrk_path_suffix
|
||||||
|
_request = wrk.format (wrk.method, _wrk_path, wrk.headers, wrk.body)
|
||||||
|
table.insert (_generated_requests, _request)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_index = _index + 1
|
||||||
|
end
|
||||||
|
print ("[ii] [" .. _tid .. "] loaded `" .. #_generated_requests .. '` of `' .. _index .. "` paths.")
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue