From 7fe9a20329d50c5b927e28867d0790b8e9e09e44 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 10:28:31 -0400 Subject: [PATCH 1/8] perf: turn on multi-accept for workers --- conf/nginx.conf.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 15da2fb..2bb5480 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -8,6 +8,7 @@ error_log stderr info; events { worker_connections 1024; + multi_accept on; } # tpl__tls_yes__start From 51dd2d592b6c9104cc1fa77fb9ecfac9f20e27c5 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 10:28:37 -0400 Subject: [PATCH 2/8] perf: try turning on PCRE JIT --- conf/nginx.conf.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 2bb5480..eb85389 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -1,4 +1,5 @@ worker_processes 1; +pcre_jit on; # expose env vars to lua code env BENTO_DEBUG; From cfb1654753d0976be55238c62c00a4e88a275ec2 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 10:33:14 -0400 Subject: [PATCH 3/8] perf: bump worker_processes to 2 --- conf/nginx.conf.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index eb85389..860e22c 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes 2; pcre_jit on; # expose env vars to lua code From b77bd9aa8a86d16c933ea03e187c99f8dca963e0 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 10:37:45 -0400 Subject: [PATCH 4/8] 4 worker processes --- conf/nginx.conf.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 860e22c..902eba8 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -1,4 +1,4 @@ -worker_processes 2; +worker_processes 4; pcre_jit on; # expose env vars to lua code @@ -9,7 +9,6 @@ error_log stderr info; events { worker_connections 1024; - multi_accept on; } # tpl__tls_yes__start From f3c500906219573a4453751f4a8d9ea58cafc7de Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 10:50:58 -0400 Subject: [PATCH 5/8] chore: don't check auth for workflow-providing endpoints --- src/proxy_auth_v2.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/proxy_auth_v2.lua b/src/proxy_auth_v2.lua index 7c97766..94c897f 100644 --- a/src/proxy_auth_v2.lua +++ b/src/proxy_auth_v2.lua @@ -58,6 +58,8 @@ local uri = ngx.var.uri -- post-rewrite URI if req_method == "GET" and ( uri == "/service-info" or -- any service-info endpoint; rewritten from original /api/.../service-info + uri == "/workflows" or -- any workflow-providing endpoint; rewritten from original /api/.../workflows + uri:sub(1, 11) == "/workflows/" or -- " req_uri_no_qp == "/api/metadata/api/projects" or req_uri_no_qp == "/api/metadata/api/public" or req_uri_no_qp == "/api/metadata/api/public_overview" or From ae500a09d1d406b2951881a131d9e066db1d88d7 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 11:29:29 -0400 Subject: [PATCH 6/8] set worker processes back to 1; increase worker_connections; use epoll --- conf/nginx.conf.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 902eba8..2b5331a 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -1,4 +1,4 @@ -worker_processes 4; +worker_processes 1; pcre_jit on; # expose env vars to lua code @@ -8,7 +8,8 @@ env BENTO_AUTHZ_SERVICE_URL; error_log stderr info; events { - worker_connections 1024; + worker_connections 2048; + use epoll; # Should be default on Linux, but explicitly use it } # tpl__tls_yes__start From ce463240ebb167b66f39e62284f37493a59adbf8 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 11:44:30 -0400 Subject: [PATCH 7/8] perf: allow sendfile --- conf/nginx.conf.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 2b5331a..96f282b 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -51,6 +51,9 @@ http { # Allow SNI-based proxying proxy_ssl_server_name on; + # Allow sendfile() for sending small files directly + sendfile on; + # Set up log format log_format compression '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' From 44b5c3cc59cb97e7af4d704e6aa6df64397d029d Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Tue, 23 Apr 2024 11:56:26 -0400 Subject: [PATCH 8/8] set worker_processes to 2 to match bento container default --- conf/nginx.conf.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf.tpl b/conf/nginx.conf.tpl index 96f282b..050eb2e 100644 --- a/conf/nginx.conf.tpl +++ b/conf/nginx.conf.tpl @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes 2; pcre_jit on; # expose env vars to lua code