Skip to content

Commit

Permalink
Configure memory allocated to vhost stats module (#170)
Browse files Browse the repository at this point in the history
* Configure memory allocated to vhost stats module

In some cases, this may need to be set to a value higher than the
default of 1 MiB, and is now configurable through the
`nginx-vhost-stats-shared-memory` flag. Default value is 1 MiB.
  • Loading branch information
alangibson01 authored Mar 14, 2018
1 parent 87715a0 commit b547279
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v1.9.1
* Introduced flag to set the amount of memory allocated to the vhost statistics module (default: 1 MiB)

# v1.9.0
* Add ability to specify health checks for merlin frontends.

Expand Down
5 changes: 5 additions & 0 deletions cmd/feed-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
nginxLogHeaders cmd.CommaSeparatedValues
nginxTrustedFrontends cmd.CommaSeparatedValues
nginxSSLPath string
nginxVhostStatsSharedMemory int
legacyBackendKeepaliveSeconds int
registrationFrontendType string
gorbIngressInstanceIP string
Expand Down Expand Up @@ -96,6 +97,7 @@ const (
defaultNginxProxyProtocol = false
defaultNginxUpdatePeriod = time.Second * 30
defaultNginxSSLPath = "/etc/ssl/default-ssl/default-ssl"
defaultNginxVhostStatsSharedMemory = 1
defaultElbLabelValue = ""
defaultDrainDelay = time.Second * 60
defaultTargetGroupDeregistrationDelay = time.Second * 300
Expand Down Expand Up @@ -198,6 +200,8 @@ func init() {
"This will typically be the ELB subnet.")
flag.StringVar(&nginxSSLPath, "ssl-path", defaultNginxSSLPath,
"Set default ssl path + name file without extension. Feed expects two files: one ending in .crt (the CA) and the other in .key (the private key).")
flag.IntVar(&nginxVhostStatsSharedMemory, "nginx-vhost-stats-shared-memory", defaultNginxVhostStatsSharedMemory,
"Memory (in MiB) which should be allocated for use by the vhost statistics module")

// elb/alb flags
flag.StringVar(&region, "region", defaultRegion,
Expand Down Expand Up @@ -316,6 +320,7 @@ func createIngressUpdaters() ([]controller.Updater, error) {
nginxConfig.SSLPath = nginxSSLPath
nginxConfig.TrustedFrontends = nginxTrustedFrontends
nginxConfig.LogHeaders = nginxLogHeaders
nginxConfig.VhostStatsSharedMemory = nginxVhostStatsSharedMemory
nginxUpdater := nginx.New(nginxConfig)

updaters := []controller.Updater{nginxUpdater}
Expand Down
1 change: 1 addition & 0 deletions nginx/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Conf struct {
AccessLogHeaders string
UpdatePeriod time.Duration
SSLPath string
VhostStatsSharedMemory int
}

type nginx struct {
Expand Down
2 changes: 1 addition & 1 deletion nginx/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ http {
default_type text/html;

# Track extended virtual host stats.
vhost_traffic_status_zone;
vhost_traffic_status_zone shared:vhost_traffic_status:{{ .VhostStatsSharedMemory }}m;

# Server names hash bucket sizes. Set based on nginx log messages.
{{ if gt .ServerNamesHashBucketSize 0 }}server_names_hash_bucket_size {{ .ServerNamesHashBucketSize }};{{ end }}
Expand Down
8 changes: 8 additions & 0 deletions nginx/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func newConf(tmpDir string, binary string) Conf {
ServerNamesHashMaxSize: -1,
ServerNamesHashBucketSize: -1,
UpdatePeriod: time.Second,
VhostStatsSharedMemory: 1,
}
}

Expand Down Expand Up @@ -319,6 +320,13 @@ func TestNginxConfig(t *testing.T) {
"listen 443 ssl default_server;",
},
},
{
"Vhost stats module has 1 MiB of shared memory",
defaultConf,
[]string{
"vhost_traffic_status_zone shared:vhost_traffic_status:1m",
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit b547279

Please sign in to comment.