From 2a5a0cad963bfcec8e18d610996e9109e8ae9c9b Mon Sep 17 00:00:00 2001 From: Shoeb Chikte Date: Sat, 10 Sep 2016 11:55:26 +0530 Subject: [PATCH] [keepalive_requests] added keepalive_requests parameter in nginx.conf set it to default value of 100 as shown in nginx config Require this parameter as default value results in a huge number of TIME_WAIT connections with high QPS applications hitting nginx The check has been copied from the keepalive_timeout parameter --- manifests/config.pp | 1 + manifests/init.pp | 3 +++ spec/classes/config_spec.rb | 12 ++++++++++++ templates/conf.d/nginx.conf.erb | 1 + 4 files changed, 17 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index 9d14867ab..61ff05c37 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -68,6 +68,7 @@ $http_tcp_nodelay = 'on', $http_tcp_nopush = 'off', $keepalive_timeout = '65', + $keepalive_requests = '100', $log_format = {}, $mail = false, $stream = false, diff --git a/manifests/init.pp b/manifests/init.pp index ab8aa624a..2656b62de 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,6 +43,7 @@ $http_tcp_nodelay = undef, $http_tcp_nopush = undef, $keepalive_timeout = undef, + $keepalive_requests = undef, $mail = undef, $multi_accept = undef, $names_hash_bucket_size = undef, @@ -164,6 +165,7 @@ $http_tcp_nodelay or $http_tcp_nopush or $keepalive_timeout or + $keepalive_requests or $logdir or $log_format or $mail or @@ -247,6 +249,7 @@ http_tcp_nodelay => $http_tcp_nodelay, http_tcp_nopush => $http_tcp_nopush, keepalive_timeout => $keepalive_timeout, + keepalive_requests => $keepalive_requests, log_dir => $logdir, log_format => $log_format, mail => $mail, diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 1fbaa189b..92dee1671 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -263,6 +263,12 @@ value: '123', match: ' keepalive_timeout 123;' }, + { + title: 'should set keepalive_requests', + attr: 'keepalive_requests', + value: '345', + match: ' keepalive_requests 345;' + }, { title: 'should set tcp_nodelay', attr: 'http_tcp_nodelay', @@ -458,6 +464,12 @@ value: '123', match: ' keepalive_timeout 123;' }, + { + title: 'should set keepalive_requests', + attr: 'keepalive_requests', + value: '345', + match: ' keepalive_requests 345;' + }, { title: 'should set mail', attr: 'mail', diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 9b8368d0d..ff4b2a8ce 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -62,6 +62,7 @@ http { server_names_hash_max_size <%= @names_hash_max_size %>; keepalive_timeout <%= @keepalive_timeout %>; + keepalive_requests <%= @keepalive_requests %>; tcp_nodelay <%= @http_tcp_nodelay %>; <% if @gzip == 'on' -%>