Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: make the number of file is as configurable as the connections. #1098

Merged
merged 1 commit into from
Feb 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bin/apisix
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ worker_cpu_affinity auto;
error_log {* error_log *} {* error_log_level or "error" *};
pid logs/nginx.pid;

worker_rlimit_nofile 20480;
worker_rlimit_nofile {* worker_rlimit_nofile *};

events {
accept_mutex off;
Expand Down Expand Up @@ -524,6 +524,13 @@ local function init()
sys_conf[k] = v
end

local wrn = sys_conf["worker_rlimit_nofile"]
local wc = sys_conf["event"]["worker_connections"]
if not wrn or wrn <= wc then
-- ensure the number of fds is slightly larger than the number of conn
sys_conf["worker_rlimit_nofile"] = wc + 128
end

if(sys_conf["enable_dev_mode"] == true) then
sys_conf["worker_processes"] = 1
else
Expand Down
1 change: 1 addition & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ apisix:
nginx_config: # config for render the template to genarate nginx.conf
error_log: "logs/error.log"
error_log_level: "warn" # warn,error
worker_rlimit_nofile: 20480 # the number of files a worker process can open, should be larger than worker_connections
event:
worker_connections: 10620
http:
Expand Down