Skip to content

Commit

Permalink
perf(timer-ng): bump the minimum/maximum threads
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP committed Jan 11, 2024
1 parent da0c609 commit 3f42575
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build_and_test.yml
Expand Up @@ -57,6 +57,13 @@ jobs:
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 8

steps:
- name: Bump max open files
run: |
sudo echo 'kong soft nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo 'kong hard nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) soft nofile 65536" | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) hard nofile 65536" | sudo tee -a /etc/security/limits.conf
- name: Checkout Kong source code
uses: actions/checkout@v4

Expand Down Expand Up @@ -160,6 +167,13 @@ jobs:
- 9411:9411

steps:
- name: Bump max open files
run: |
sudo echo 'kong soft nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo 'kong hard nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) soft nofile 65536" | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) hard nofile 65536" | sudo tee -a /etc/security/limits.conf
- name: Checkout Kong source code
uses: actions/checkout@v4

Expand Down Expand Up @@ -292,6 +306,13 @@ jobs:
- 15003:9001

steps:
- name: Bump max open files
run: |
sudo echo 'kong soft nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo 'kong hard nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) soft nofile 65536" | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) hard nofile 65536" | sudo tee -a /etc/security/limits.conf
- name: Checkout Kong source code
uses: actions/checkout@v4

Expand Down Expand Up @@ -358,6 +379,13 @@ jobs:
needs: build

steps:
- name: Bump max open files
run: |
sudo echo 'kong soft nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo 'kong hard nofile 65536' | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) soft nofile 65536" | sudo tee -a /etc/security/limits.conf
sudo echo "$(whoami) hard nofile 65536" | sudo tee -a /etc/security/limits.conf
- name: Checkout Kong source code
uses: actions/checkout@v4

Expand Down
3 changes: 3 additions & 0 deletions changelog/unreleased/kong/bump-cocurrency-of-timer-ng.yml
@@ -0,0 +1,3 @@
message: Bumped the concurrency limitation of timer.
type: performance
scope: Performance
5 changes: 4 additions & 1 deletion kong/globalpatches.lua
Expand Up @@ -99,7 +99,10 @@ return function(options)
_timerng:start()

else
_timerng = require("resty.timerng").new()
_timerng = require("resty.timerng").new({
min_threads = 512,
max_threads = 2048,
})
end

_G.timerng = _timerng
Expand Down
5 changes: 3 additions & 2 deletions kong/init.lua
Expand Up @@ -746,8 +746,9 @@ function Kong.init()
require("resty.kong.var").patch_metatable()

if config.dedicated_config_processing and is_data_plane(config) then
-- TODO: figure out if there is better value than 2048
local ok, err = process.enable_privileged_agent(2048)
-- TODO: figure out if there is better value than 4096
-- 4096 is for the cocurrency of the lua-resty-timer-ng
local ok, err = process.enable_privileged_agent(4096)
if not ok then
error(err)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/headers.conf
Expand Up @@ -18,8 +18,8 @@ anonymous_reports = off
dns_hostsfile = spec/fixtures/hosts

nginx_main_worker_processes = 1
nginx_main_worker_rlimit_nofile = NONE
nginx_events_worker_connections = NONE
nginx_main_worker_rlimit_nofile = 4096
nginx_events_worker_connections = 4096
nginx_events_multi_accept = off

prefix = servroot
Expand Down
4 changes: 2 additions & 2 deletions spec/kong_tests.conf
Expand Up @@ -30,8 +30,8 @@ dedicated_config_processing = on
dns_hostsfile = spec/fixtures/hosts

nginx_main_worker_processes = 1
nginx_main_worker_rlimit_nofile = NONE
nginx_events_worker_connections = NONE
nginx_main_worker_rlimit_nofile = 4096
nginx_events_worker_connections = 4096
nginx_events_multi_accept = off

plugins = bundled,dummy,cache,rewriter,error-handler-log,error-generator,error-generator-last,short-circuit
Expand Down

0 comments on commit 3f42575

Please sign in to comment.