Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] The auto parameter of the worker_processes supports todetect the container environment.

April 24, 2018 01:38PM
Hi,Maxim

This feature is not a much needed, but it can reduce the cost of manual configuration. If there is a better implementation that can solve this problem, we are also very much looking forward to it.
I hope you can think again. Thanks.


Regards,
Agile6v


------------------ Original ------------------
From: "Maxim Dounin";<mdounin@mdounin.ru>;
Date: Apr 25, 2018
To: "nginx-devel"<nginx-devel@nginx.org>;

Subject: Re: [PATCH] The auto parameter of the worker_processes supports todetect the container environment.



Hello!

On Wed, Apr 25, 2018 at 12:47:13AM +0800, agile6v wrote:

> # HG changeset patch
> # User Agile6v <agile6v@agile6v.com>
> # Date 1524585905 -28800
> # Wed Apr 25 00:05:05 2018 +0800
> # Node ID 89793df28d1bcf2baf00e389e6806d32d7435886
> # Parent 7c614ef3c6ea330c62630d5065f961a27d0f82cd
> The auto parameter of the worker_processes supports to detect the container environment.
>
>
> Docker mounts cgroup information into container starting with version 1.8,
> so it is possible to determine the appropriate number of CPUs based on the
> cgroup information in the container. Refer to JDK related implementation:
> https://bugs.openjdk.java.net/browse/JDK-8146115
>
>
> diff -r 7c614ef3c6ea -r 89793df28d1b auto/sources
> --- a/auto/sources Wed Apr 18 16:11:41 2018 +0300
> +++ b/auto/sources Wed Apr 25 00:05:05 2018 +0800
> @@ -192,8 +192,8 @@
> FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
> FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c
>
> -LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h"
> -LINUX_SRCS=src/os/unix/ngx_linux_init.c
> +LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h src/os/unix/ngx_container.h"
> +LINUX_SRCS="src/os/unix/ngx_linux_init.c src/os/unix/ngx_container.c"
> LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c
>
>
> diff -r 7c614ef3c6ea -r 89793df28d1b src/os/unix/ngx_container.c
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/src/os/unix/ngx_container.c Wed Apr 25 00:05:05 2018 +0800
> @@ -0,0 +1,418 @@
> +
> +/*
> + * Copyright (C) agile6v
> + * Copyright (C) Xiaomi, Inc.
> + */
> +
> +#include <ngx_config.h>
> +#include <ngx_core.h>
> +
> +#define NGX_BUFFER_SIZE 8192
> +#define PER_CPU_SHARES 1024
> +
> +typedef struct {
> + ngx_str_t root;
> + ngx_str_t path;
> + ngx_str_t mount_point;
> +} cgroup_subsystem_info;
> +
> +static cgroup_subsystem_info cpu_subsystem;
> +
> +static ngx_str_t proc_cgroup_file = ngx_string("/proc/self/cgroup");
> +static ngx_str_t proc_mount_file = ngx_string("/proc/self/mountinfo");
> +static ngx_str_t cpu_cfs_period = ngx_string("/cpu.cfs_period_us");
> +static ngx_str_t cpu_cfs_quota = ngx_string("/cpu.cfs_quota_us");
> +static ngx_str_t cpu_cfs_shares = ngx_string("/cpu.shares");

[...]

400+ lines of code to obtain a number which is expected to be
directly available via the sysconf(_SC_NPROCESSORS_ONLN) call
might be a bit too many.

Thank you for your effort, but no.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] The auto parameter of the worker_processes supports to detect the container environment. Attachments

agile6v 456 April 24, 2018 12:48PM

Re: [PATCH] The auto parameter of the worker_processes supports to detect the container environment.

Maxim Dounin 165 April 24, 2018 01:02PM

Re: [PATCH] The auto parameter of the worker_processes supports todetect the container environment.

agile6v 267 April 24, 2018 01:38PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 118
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready