Skip to content

Commit

Permalink
feature: make the number of file is as configurable as the connection…
Browse files Browse the repository at this point in the history
…s. (#1098)
  • Loading branch information
spacewander authored Feb 2, 2020
1 parent 734b165 commit fda20d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit fda20d9

Please sign in to comment.