Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

[nginx-ingress-controller]: Adapt nginx hash sizes to the number of ingress #1596

Merged

Conversation

aledbf
Copy link
Contributor

@aledbf aledbf commented Aug 22, 2016

This change allows the tuning of 2 important NGINX variables:

  • server_names_hash_max_size
  • server_names_hash_bucket_size

The default values should be enough for most of the users but after +300 Ingress rules or long hostnames as FQDN NGINX requires tuning of this values or it will not start.

The introduced change allows the self-tuning using the Ingress information
Using --v=3 it's possible to see the changes:

...
I0822 21:42:10.517778       1 template.go:84] adjusting ServerNameHashMaxSize variable from 4096 to 16384
...

fixes #1487


This change is Reviewable

@aledbf aledbf changed the title Adapt nginx has sizes to the number of ingress [nginx-ingress-controller]: Adapt nginx has sizes to the number of ingress Aug 22, 2016
@aledbf aledbf changed the title [nginx-ingress-controller]: Adapt nginx has sizes to the number of ingress [nginx-ingress-controller]: Adapt nginx hash sizes to the number of ingress Aug 22, 2016
@@ -64,6 +64,27 @@ func (ngx *Manager) loadTemplate() error {
}

func (ngx *Manager) writeCfg(cfg config.Configuration, ingressCfg IngressConfig) (bool, error) {
var longestName int
var serverNames int
for _, srv := range ingressCfg.Servers {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the tradeoff in being so precise vs just defaulting it to something high, documenting the limit, and not writing this code?

Copy link
Contributor Author

@aledbf aledbf Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the tradeoff in being so precise

Using a small value means nginx cannot start or be restarted. This is an example of the error:

[emerg] 17617#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32

just defaulting it to something high

This depends on the amount of hostnames and FQDN length

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i mean just start off with it set to 16384, what do we lose?

Copy link
Contributor Author

@aledbf aledbf Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we lose?

Nothing, but for instance I need at least 48K :)

@k8s-github-robot
Copy link

@aledbf PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 26, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 26, 2016
@aledbf
Copy link
Contributor Author

aledbf commented Sep 1, 2016

@bprashanth ping

@bprashanth
Copy link

LGTM

@bprashanth bprashanth added the lgtm Indicates that a PR is ready to be merged. label Sep 1, 2016
@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 376e7d8 into kubernetes-retired:master Sep 1, 2016
@aledbf aledbf deleted the improve-defaults branch September 15, 2016 00:39
aledbf pushed a commit to aledbf/contrib that referenced this pull request Nov 10, 2016
Automatic merge from submit-queue

[nginx-ingress-controller]: Adapt nginx hash sizes to the number of ingress

This change allows the tuning of 2 important NGINX variables:
- server_names_hash_max_size
- server_names_hash_bucket_size

The default values should be enough for most of the users but after +300 Ingress rules or long hostnames as FQDN NGINX requires tuning of this values or it will not start.

The introduced change allows the self-tuning using the Ingress information
Using `--v=3` it's possible to see the changes:
```
...
I0822 21:42:10.517778       1 template.go:84] adjusting ServerNameHashMaxSize variable from 4096 to 16384
...
```

fixes kubernetes-retired#1487
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[nginx-ingress-controller] Improve nginx default
4 participants