Upstream keepalive time (#8319)
* nginx 1.19.10 keepalive_time parameter * nginx v1.19.10 base image * keepalive_time documentation * base image * restore base image * e2e test * replace default value in test
This commit is contained in:
parent
db4aeea723
commit
d4b9b486e6
4 changed files with 29 additions and 6 deletions
|
@ -111,6 +111,7 @@ The following table shows a configuration option's name, type, and the default v
|
||||||
|[variables-hash-bucket-size](#variables-hash-bucket-size)|int|128|
|
|[variables-hash-bucket-size](#variables-hash-bucket-size)|int|128|
|
||||||
|[variables-hash-max-size](#variables-hash-max-size)|int|2048|
|
|[variables-hash-max-size](#variables-hash-max-size)|int|2048|
|
||||||
|[upstream-keepalive-connections](#upstream-keepalive-connections)|int|320|
|
|[upstream-keepalive-connections](#upstream-keepalive-connections)|int|320|
|
||||||
|
|[upstream-keepalive-time](#upstream-keepalive-time)|string|"1h"|
|
||||||
|[upstream-keepalive-timeout](#upstream-keepalive-timeout)|int|60|
|
|[upstream-keepalive-timeout](#upstream-keepalive-timeout)|int|60|
|
||||||
|[upstream-keepalive-requests](#upstream-keepalive-requests)|int|10000|
|
|[upstream-keepalive-requests](#upstream-keepalive-requests)|int|10000|
|
||||||
|[limit-conn-zone-variable](#limit-conn-zone-variable)|string|"$binary_remote_addr"|
|
|[limit-conn-zone-variable](#limit-conn-zone-variable)|string|"$binary_remote_addr"|
|
||||||
|
@ -769,6 +770,14 @@ _References:_
|
||||||
[https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive)
|
[https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive)
|
||||||
|
|
||||||
|
|
||||||
|
## upstream-keepalive-time
|
||||||
|
|
||||||
|
Sets the maximum time during which requests can be processed through one keepalive connection.
|
||||||
|
_**default:**_ "1h"
|
||||||
|
|
||||||
|
_References:_
|
||||||
|
[http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time)
|
||||||
|
|
||||||
## upstream-keepalive-timeout
|
## upstream-keepalive-timeout
|
||||||
|
|
||||||
Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
|
Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
|
||||||
|
|
|
@ -468,6 +468,10 @@ type Configuration struct {
|
||||||
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
|
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
|
||||||
UpstreamKeepaliveConnections int `json:"upstream-keepalive-connections,omitempty"`
|
UpstreamKeepaliveConnections int `json:"upstream-keepalive-connections,omitempty"`
|
||||||
|
|
||||||
|
// Sets the maximum time during which requests can be processed through one keepalive connection
|
||||||
|
// https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time
|
||||||
|
UpstreamKeepaliveTime string `json:"upstream-keepalive-time,omitempty"`
|
||||||
|
|
||||||
// Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
|
// Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
|
||||||
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout
|
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout
|
||||||
UpstreamKeepaliveTimeout int `json:"upstream-keepalive-timeout,omitempty"`
|
UpstreamKeepaliveTimeout int `json:"upstream-keepalive-timeout,omitempty"`
|
||||||
|
@ -892,6 +896,7 @@ func NewDefault() Configuration {
|
||||||
ServiceUpstream: false,
|
ServiceUpstream: false,
|
||||||
},
|
},
|
||||||
UpstreamKeepaliveConnections: 320,
|
UpstreamKeepaliveConnections: 320,
|
||||||
|
UpstreamKeepaliveTime: "1h",
|
||||||
UpstreamKeepaliveTimeout: 60,
|
UpstreamKeepaliveTimeout: 60,
|
||||||
UpstreamKeepaliveRequests: 10000,
|
UpstreamKeepaliveRequests: 10000,
|
||||||
LimitConnZoneVariable: defaultLimitConnZoneVariable,
|
LimitConnZoneVariable: defaultLimitConnZoneVariable,
|
||||||
|
|
|
@ -508,7 +508,7 @@ http {
|
||||||
|
|
||||||
{{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
|
{{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
|
||||||
keepalive {{ $cfg.UpstreamKeepaliveConnections }};
|
keepalive {{ $cfg.UpstreamKeepaliveConnections }};
|
||||||
|
keepalive_time {{ $cfg.UpstreamKeepaliveTime }};
|
||||||
keepalive_timeout {{ $cfg.UpstreamKeepaliveTimeout }}s;
|
keepalive_timeout {{ $cfg.UpstreamKeepaliveTimeout }}s;
|
||||||
keepalive_requests {{ $cfg.UpstreamKeepaliveRequests }};
|
keepalive_requests {{ $cfg.UpstreamKeepaliveRequests }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -74,6 +74,15 @@ var _ = framework.DescribeSetting("keep-alive keep-alive-requests", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ginkgo.It("should set keepalive time to upstream server", func() {
|
||||||
|
f.UpdateNginxConfigMapData("upstream-keepalive-time", "75s")
|
||||||
|
|
||||||
|
f.WaitForNginxConfiguration(func(server string) bool {
|
||||||
|
match, _ := regexp.MatchString(`upstream\supstream_balancer\s\{[\s\S]*keepalive_time\s*75s;`, server)
|
||||||
|
return match
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.It("should set the request count to upstream server through one keep alive connection", func() {
|
ginkgo.It("should set the request count to upstream server through one keep alive connection", func() {
|
||||||
f.UpdateNginxConfigMapData("upstream-keepalive-requests", "200")
|
f.UpdateNginxConfigMapData("upstream-keepalive-requests", "200")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue