From f81efdfa34305f56ae4178566ee4a1a193c88356 Mon Sep 17 00:00:00 2001 From: k1low Date: Fri, 13 Oct 2023 20:53:00 +0900 Subject: [PATCH 1/2] Set worker_processes to cpu count --- testutil/container.go | 3 +++ testutil/templates/nginx_echo.conf.tmpl | 2 +- testutil/templates/nginx_reverse.conf.tmpl | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/testutil/container.go b/testutil/container.go index 5e7dce7..c35cd55 100644 --- a/testutil/container.go +++ b/testutil/container.go @@ -7,6 +7,7 @@ import ( "net/url" "os" "path/filepath" + "runtime" "testing" "text/template" @@ -34,6 +35,7 @@ func NewReverseProxyNGINXServer(t testing.TB, hostname string, upstreams map[str t.Fatal(err) } if err := tmpl.Execute(f, map[string]any{ + "NumCPU": runtime.NumCPU(), "Hostname": hostname, "Upstreams": upstreams, }); err != nil { @@ -59,6 +61,7 @@ func NewUpstreamEchoNGINXServer(t testing.TB, hostname string) string { t.Fatal(err) } if err := tmpl.Execute(f, map[string]any{ + "NumCPU": runtime.NumCPU(), "Hostname": hostname, }); err != nil { t.Fatal(err) diff --git a/testutil/templates/nginx_echo.conf.tmpl b/testutil/templates/nginx_echo.conf.tmpl index 975761a..eca34d1 100644 --- a/testutil/templates/nginx_echo.conf.tmpl +++ b/testutil/templates/nginx_echo.conf.tmpl @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes {{ .NumCPU }}; load_module /etc/nginx/modules/ngx_http_js_module.so; diff --git a/testutil/templates/nginx_reverse.conf.tmpl b/testutil/templates/nginx_reverse.conf.tmpl index 0e08be1..aba966f 100644 --- a/testutil/templates/nginx_reverse.conf.tmpl +++ b/testutil/templates/nginx_reverse.conf.tmpl @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes {{ .NumCPU }}; events { worker_connections 1024; From df0f309699f327dce89cdf6dc2ed5aca8619b254 Mon Sep 17 00:00:00 2001 From: k1low Date: Fri, 13 Oct 2023 21:05:21 +0900 Subject: [PATCH 2/2] revert worker_processes of echo server --- testutil/container.go | 1 - testutil/templates/nginx_echo.conf.tmpl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/testutil/container.go b/testutil/container.go index c35cd55..61acf4d 100644 --- a/testutil/container.go +++ b/testutil/container.go @@ -61,7 +61,6 @@ func NewUpstreamEchoNGINXServer(t testing.TB, hostname string) string { t.Fatal(err) } if err := tmpl.Execute(f, map[string]any{ - "NumCPU": runtime.NumCPU(), "Hostname": hostname, }); err != nil { t.Fatal(err) diff --git a/testutil/templates/nginx_echo.conf.tmpl b/testutil/templates/nginx_echo.conf.tmpl index eca34d1..975761a 100644 --- a/testutil/templates/nginx_echo.conf.tmpl +++ b/testutil/templates/nginx_echo.conf.tmpl @@ -1,4 +1,4 @@ -worker_processes {{ .NumCPU }}; +worker_processes 1; load_module /etc/nginx/modules/ngx_http_js_module.so;