From 90e18eb9cd9285c324bc70cfa7984110951468fa Mon Sep 17 00:00:00 2001 From: An Tran Date: Fri, 8 Mar 2024 15:44:43 +1000 Subject: [PATCH] [3scale_batcher] Introduce APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE In some cases, the batcher policy will run out of storage space (batched_reports) and cause metrics to not being reported. This commit adds a new environment variable to configure the batcher policy shared memory storage size --- CHANGELOG.md | 2 ++ doc/parameters.md | 7 +++++++ gateway/conf.d/backend.conf | 12 ++++++++++++ gateway/http.d/shdict.conf | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4df35d515..d74693d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Added `APICAST_CLIENT_REQUEST_HEADER_BUFFERS` variable to allow configure of the NGINX `client_request_header_buffers` directive: [PR #1446](https://github.com/3scale/APIcast/pull/1446), [THREESCALE-10164](https://issues.redhat.com/browse/THREESCALE-10164) +Added `APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE` variable to allow configure batcher policy share memory size. [PR #1452](https://github.com/3scale/APIcast/pull/1452), [THREESCALE-9537](https://issues.redhat.com/browse/THREESCALE-9537) + ## [3.14.0] 2023-07-25 ### Fixed diff --git a/doc/parameters.md b/doc/parameters.md index ac0b40809..1cdbc0f3c 100644 --- a/doc/parameters.md +++ b/doc/parameters.md @@ -517,6 +517,13 @@ Sets the maximum number and size of buffers used for reading large client reques The format for this value is defined by the [`large_client_header_buffers` NGINX directive](https://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers) +### `APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE` + +**Default:** 20m +**Value:** string + +Sets the maximum size of shared memory used by batcher policy. + ### `OPENTELEMETRY` This environment variable enables NGINX instrumentation using OpenTelemetry tracing library. diff --git a/gateway/conf.d/backend.conf b/gateway/conf.d/backend.conf index 8c9da83fa..4c116744b 100644 --- a/gateway/conf.d/backend.conf +++ b/gateway/conf.d/backend.conf @@ -21,3 +21,15 @@ location /transactions/oauth_authrep.xml { echo "transactions oauth_authrep!"; } + +location /transactions/authorize.xml { + access_by_lua_block { + local delay = tonumber(ngx.var.arg_delay) or 0 + + if delay > 0 then + ngx.sleep(delay) + end + } + + echo "transactions oauth_authrep!"; +} diff --git a/gateway/http.d/shdict.conf b/gateway/http.d/shdict.conf index 8f49fc796..ee7182ac2 100644 --- a/gateway/http.d/shdict.conf +++ b/gateway/http.d/shdict.conf @@ -8,5 +8,5 @@ lua_shared_dict limiter 1m; # This is not ideal, but they'll need to be here until we allow policies to # modify this template. lua_shared_dict cached_auths 20m; -lua_shared_dict batched_reports 20m; +lua_shared_dict batched_reports {{env.APICAST_POLICY_BATCHER_SHARED_MEMORY_SIZE | default: "20m"}}; lua_shared_dict batched_reports_locks 1m;