From ad3f18a7a99ea11d11db281fc7bd345ed9e86b77 Mon Sep 17 00:00:00 2001 From: Robin Xiang Date: Wed, 12 Jul 2023 16:48:18 +0800 Subject: [PATCH] With a hard-coded payload size, for some use cases like uploading a big OpenAPI spec in DevPortal or updating a big config entry for plugins, they can not work as expected. With the new parameter, the user can decide the payload size to meet their needs. In this PR, a new parameter, `worker_events_max_payload` is added, which allows to specify the payload size the `worker_events` lib can accept. The default size is 64k, and the max allowed to set is 16M Bytes. The corresponding PR for `worker_events` lib is [#37](https://github.com/Kong/lua-resty-events/pull/37) FTI-4963 --- kong.conf.default | 5 +++++ kong/global.lua | 12 ++++++++---- kong/templates/kong_defaults.lua | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/kong.conf.default b/kong.conf.default index 9759a546f39..6965042abbf 100644 --- a/kong.conf.default +++ b/kong.conf.default @@ -269,6 +269,11 @@ # Similarly to `error_template_html`, the template # is required to contain one single `%s` placeholder for # the error message. + +#worker_events_max_payload = # Specifies the max payload size the `worker_events` can + # accept. + # Default is 64k - 1024 * 64. The max allowed is 16M Bytes. + #------------------------------------------------------------------------------ # HYBRID MODE #------------------------------------------------------------------------------ diff --git a/kong/global.lua b/kong/global.lua index 4b2764a38a5..eb29db15cdd 100644 --- a/kong/global.lua +++ b/kong/global.lua @@ -182,6 +182,9 @@ function _GLOBAL.init_worker_events() and configuration.prefix or require("pl.path").abspath(ngx.config.prefix()) + local max_payload_len = configuration + and configuration.worker_events_max_payload + local sock = ngx.config.subsystem == "stream" and "stream_worker_events.sock" or "worker_events.sock" @@ -189,10 +192,11 @@ function _GLOBAL.init_worker_events() local listening = "unix:" .. prefix .. "/" .. sock opts = { - unique_timeout = 5, -- life time of unique event data in lrucache - broker_id = 0, -- broker server runs in nginx worker #0 - listening = listening, -- unix socket for broker listening - max_queue_len = 1024 * 50, -- max queue len for events buffering + unique_timeout = 5, -- life time of unique event data in lrucache + broker_id = 0, -- broker server runs in nginx worker #0 + listening = listening, -- unix socket for broker listening + max_payload_len = max_payload_len, -- max payload size in bytes + max_queue_len = 1024 * 50, -- max queue len for events buffering } worker_events = require "resty.events.compat" diff --git a/kong/templates/kong_defaults.lua b/kong/templates/kong_defaults.lua index fadefe9b3a8..d10a413a129 100644 --- a/kong/templates/kong_defaults.lua +++ b/kong/templates/kong_defaults.lua @@ -42,6 +42,7 @@ cluster_dp_labels = NONE lmdb_environment_path = dbless.lmdb lmdb_map_size = 2048m mem_cache_size = 128m +worker_events_max_payload = 64k ssl_cert = NONE ssl_cert_key = NONE client_ssl = off