Skip to content

Commit

Permalink
Update maxfile configuration (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiujian16 authored and GitHub Enterprise committed Feb 9, 2018
1 parent 65ad4fd commit a8173f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
10 changes: 8 additions & 2 deletions pkg/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ func NewDefault() Configuration {
defIPCIDR := make([]string, 0)
defIPCIDR = append(defIPCIDR, "0.0.0.0/0")
defBindAddress := make([]string, 0)
workerProcesses := runtime.NumCPU()
// put worker process to no more than 16
if workerProcesses > 16 {
workerProcesses = 16
}

cfg := Configuration{
AllowBackendServerHeader: false,
AccessLogPath: "/var/log/nginx/access.log",
Expand Down Expand Up @@ -488,7 +494,7 @@ func NewDefault() Configuration {
LogFormatEscapeJSON: false,
LogFormatStream: logFormatStream,
LogFormatUpstream: logFormatUpstream,
MaxWorkerConnections: 16384,
MaxWorkerConnections: 512,
MapHashBucketSize: 64,
ProxyRealIPCIDR: defIPCIDR,
ServerNameHashMaxSize: 1024,
Expand All @@ -506,7 +512,7 @@ func NewDefault() Configuration {
SSLSessionTimeout: sslSessionTimeout,
EnableBrotli: true,
UseGzip: true,
WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
WorkerProcesses: strconv.Itoa(workerProcesses),
WorkerShutdownTimeout: "10s",
LoadBalanceAlgorithm: defaultLoadBalancerAlgorithm,
VtsStatusZoneSize: "10m",
Expand Down
10 changes: 4 additions & 6 deletions pkg/ingress/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package controller

import (
"syscall"

"github.com/golang/glog"

api "k8s.io/api/core/v1"
Expand Down Expand Up @@ -51,14 +49,14 @@ func sysctlSomaxconn() int {
// sysctlFSFileMax returns the value of fs.file-max, i.e.
// maximum number of open file descriptors
func sysctlFSFileMax() int {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
fileMax, err := sysctl.New().GetSysctl("fs/file-max")
if err != nil {
glog.Errorf("unexpected error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
glog.Errorf("unexpected error reading system maximum number of open file descriptors (fs.file-max): %v", err)
// returning 0 means don't render the value
return 0
}
return int(rLimit.Max)
glog.V(3).Infof("system fs.file-max=%v", fileMax)
return fileMax
}

func intInSlice(i int, list []int) bool {
Expand Down
3 changes: 3 additions & 0 deletions rootfs/opt/ibm/router/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ daemon off;

worker_processes {{ $cfg.WorkerProcesses }};
pid /run/nginx.pid;
{{ if ne .MaxOpenFiles 0 }}
worker_rlimit_nofile {{ .MaxOpenFiles }};
{{ end}}

# Make env vars accessible from within Lua modules.
env SECRET_KEY_FILE_PATH;
Expand Down

0 comments on commit a8173f7

Please sign in to comment.