[bitnami/nginx] Add worker_processes env var#91159
Open
jhthompson wants to merge 6 commits intobitnami:mainfrom
Open
[bitnami/nginx] Add worker_processes env var#91159jhthompson wants to merge 6 commits intobitnami:mainfrom
jhthompson wants to merge 6 commits intobitnami:mainfrom
Conversation
Signed-off-by: Jeremy Thompson <23730407+jhthompson@users.noreply.github.com>
Author
|
Some outputs from my local testing (if relevant). All commands ran from Building the image locally:docker build -t nginx-local:$(git rev-parse --short HEAD) --build-arg TARGETARCH=amd64 .No env vardocker run nginx-local:80ceba9418a
nginx 20:28:22.37 INFO ==>
nginx 20:28:22.37 INFO ==> Welcome to the Bitnami nginx container
nginx 20:28:22.37 INFO ==>
nginx 20:28:22.38 INFO ==> ** Starting NGINX setup **
nginx 20:28:22.40 INFO ==> Validating settings in NGINX_* env vars
Certificate request self-signature ok
subject=CN = example.com
nginx 20:28:23.91 INFO ==> No custom scripts in /docker-entrypoint-initdb.d
nginx 20:28:23.92 INFO ==> Initializing NGINX
realpath: /bitnami/nginx/conf/vhosts: No such file or directory
nginx 20:28:23.96 INFO ==> ** NGINX setup finished! **
nginx 20:28:23.98 INFO ==> ** Starting NGINX **(from running container): nginx -T
nginx: the configuration file /opt/bitnami/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/bitnami/nginx/conf/nginx.conf test is successful
# configuration file /opt/bitnami/nginx/conf/nginx.conf:
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
# user www www; ## Default: nobody
worker_processes auto; # <------------------- relevant line here
error_log "/opt/bitnami/nginx/logs/error.log";
pid "/opt/bitnami/nginx/tmp/nginx.pid";
include "/opt/bitnami/nginx/conf/context.d/main/*.conf";
# ... more below ...With valid env vardocker run -e NGINX_WORKER_PROCESSES=1 nginx-local:80ceba9418a
nginx 20:33:37.26 INFO ==>
nginx 20:33:37.26 INFO ==> Welcome to the Bitnami nginx container
nginx 20:33:37.27 INFO ==>
nginx 20:33:37.27 INFO ==> ** Starting NGINX setup **
nginx 20:33:37.30 INFO ==> Validating settings in NGINX_* env vars
Certificate request self-signature ok
subject=CN = example.com
nginx 20:33:41.25 INFO ==> No custom scripts in /docker-entrypoint-initdb.d
nginx 20:33:41.25 INFO ==> Initializing NGINX
realpath: /bitnami/nginx/conf/vhosts: No such file or directory
nginx 20:33:41.30 INFO ==> ** NGINX setup finished! **
nginx 20:33:41.32 INFO ==> ** Starting NGINX **(from running container): nginx -T
nginx: the configuration file /opt/bitnami/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/bitnami/nginx/conf/nginx.conf test is successful
# configuration file /opt/bitnami/nginx/conf/nginx.conf:
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
# user www www; ## Default: nobody
worker_processes 1; # <------------------- relevant line here
error_log "/opt/bitnami/nginx/logs/error.log";
pid "/opt/bitnami/nginx/tmp/nginx.pid";
include "/opt/bitnami/nginx/conf/context.d/main/*.conf";
# ... more below ...With invalid env vardocker run -e NGINX_WORKER_PROCESSES=aut nginx-local:80ceba9418a
nginx 20:35:31.23 INFO ==>
nginx 20:35:31.23 INFO ==> Welcome to the Bitnami nginx container
nginx 20:35:31.24 INFO ==>
nginx 20:35:31.24 INFO ==> ** Starting NGINX setup **
nginx 20:35:31.26 INFO ==> Validating settings in NGINX_* env vars
nginx 20:35:31.26 ERROR ==> The allowed values for NGINX_WORKER_PROCESSES are: auto or a positive integerdocker run -e NGINX_WORKER_PROCESSES=-2 nginx-local:80ceba9418a
nginx 20:35:46.13 INFO ==>
nginx 20:35:46.13 INFO ==> Welcome to the Bitnami nginx container
nginx 20:35:46.13 INFO ==>
nginx 20:35:46.14 INFO ==> ** Starting NGINX setup **
nginx 20:35:46.16 INFO ==> Validating settings in NGINX_* env vars
nginx 20:35:46.16 ERROR ==> The allowed values for NGINX_WORKER_PROCESSES are: auto or a positive integer |
Author
|
@fmulero @carrodher sorry for the ping! Just checking in to see if anyone has had a chance to look at this yet, and if there's anything I should add/remove/change. |
Author
|
@fmulero @carrodher sorry for another ping - is there anything I can do to help move things along on this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change
Add a
NGINX_WORKER_PROCESSESenvironment variable to control the value of the Nginx worker_processes directive.Benefits
Ability to better control resource usage
Nginx's
worker_processes autocreates too many worker processes in certain deployments. This change provides an easy hook to manually set the number to a more sensible value. From a currently open issue on Nginx itself:This is a solved problem in the
docker-nginximage by providing an entrypoint script to "tune" the value to something more appropriate, but adding a similar approach here feels heavy-handed.Corrects existing documentation
It is not possible to override
worker_processesvia the listed method in the Readme, as Nginx errors with a "duplicate directive" since it ends up being present twice.Possible drawbacks
If
NGINX_WORKER_PROCESSESis currently set in any deployments that use this image, there may be unexpected behavior.Applicable issues
n/a
Additional information
Various issues across several Nginx projects are related to this:
worker_processescgroup-Compatible nginx/nginx#855