Opened 3 years ago

Closed 3 years ago

#2197 closed defect (invalid)

why keepalive conf store in server conf?

Reported by: RekGRpth@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.19.x
Keywords: Cc:
uname -a: Linux nginx 5.8.0-53-generic #60-Ubuntu SMP Thu May 6 07:46:32 UTC 2021 x86_64 Linux
nginx -V: nginx version: nginx/1.21.0
built with OpenSSL 1.1.1k 25 Mar 2021
TLS SNI support enabled
configure arguments: --add-dynamic-module='modules/echo-nginx-module modules/encrypted-session-nginx-module modules/form-input-nginx-module modules/iconv-nginx-module modules/nginx-backtrace-ng modules/nginx_csrf_prevent modules/nginx-eval-module modules/nginx-http-auth-digest modules/nginx-jwt-module modules/nginx-push-stream-module modules/nginx-upload-module modules/nginx-uuid4-module modules/ngx_http_auth_basic_ldap_module modules/ngx_http_captcha_module modules/ngx_http_headers_module modules/ngx_http_htmldoc_module modules/ngx_http_json_module modules/ngx_http_mustach_module modules/ngx_http_response_body_module modules/ngx_http_sign_module modules/ngx_http_substitutions_filter_module modules/ngx_http_upstream_session_sticky_module modules/ngx_http_zip_var_module modules/ngx_postgres modules/set-misc-nginx-module modules/njs/nginx' --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --group=nginx --http-client-body-temp-path=/var/cache/nginx/client_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --lock-path=/run/nginx/nginx.lock --modules-path=/usr/local/modules --pid-path=/run/nginx/nginx.pid --prefix=/etc/nginx --sbin-path=/usr/local/bin/nginx --user=nginx --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_sub_module --with-http_v2_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads

Description

1) if I have 1 upstream conf with keepalive 10 and 100 server conf, then I have up to 10 * 100 cached in keepalive connections?
2) if I have 100 upstreams conf with keepalive 10 and 1 server conf, then ... ?
why keepalive conf store in server conf?
static ngx_http_module_t ngx_http_upstream_keepalive_module_ctx = {
...

ngx_http_upstream_keepalive_create_conf, /* create server configuration */

...
}
why keepalive conf not strore in upstream conf?

Change History (2)

comment:1 by RekGRpth@…, 3 years ago

how about such fix?

diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c b/src/http/modules/ngx_http_upstream_keepalive_module.c
index 3081919c..16056203 100644
--- a/src/http/modules/ngx_http_upstream_keepalive_module.c
+++ b/src/http/modules/ngx_http_upstream_keepalive_module.c
@@ -675,6 +675,8 @@ ngx_http_upstream_keepalive_save_session(ngx_peer_connection_t *pc, void *data)
 static void *
 ngx_http_upstream_keepalive_create_conf(ngx_conf_t *cf)
 {
+    ngx_str_t *elts = cf->args->elts;
+    if (elts[0].len != sizeof("upstream") - 1 || ngx_strncasecmp(elts[0].data, (u_char *)"upstream", sizeof("upstream") - 1)) return NULL;
     ngx_http_upstream_keepalive_srv_conf_t  *conf;
 
     conf = ngx_pcalloc(cf->pool,
Last edited 3 years ago by RekGRpth@… (previous) (diff)

comment:2 by Maxim Dounin, 3 years ago

Resolution: invalid
Status: newclosed

It looks like you are trying to understand how nginx works. You may want to start with reading the Development guide, notably Load balancing. Also, reading the relevant nginx code is usually be very helpful. If there will be questions, consider using mailing lists to ask for help.

Note: See TracTickets for help on using tickets.