Отъедает память и начинает тормозить. Помогите найти причину.

Dmytro Lavryk nginx-forum на forum.nginx.org
Пт Апр 24 08:15:13 UTC 2020


Доброго всем здоровья, в сложившейся обстановке.

Есть nginx c "замороченным конфигом". Используется для проксирования раздачи
видео по секьюрити ссылкам. Уонфиг такой достался, лично мне не везде
понятен. потому... Суть ситуации - потребление памяти процессами nginx все
время растет.. при достижении какого-то пикового значения (~1,2Гб на процесс
/их 16-ть получается/) сильно падает скорость отдачи. при этом свободная
память в ситеме все еще есть. Хотелось бы понять 2 момента:
1. Почему происходит потеря продуктивности?
2. Почему потребление памяти все время растет, а не ограничивается на
каком-то уровне?

-----------------------------
cat /etc/nginx/nginx.conf | grep -v '#'

user  www-data;
worker_processes auto;
worker_rlimit_nofile 1024000;

pid        /var/run/nginx.pid;
events {
  worker_connections    8192;
  worker_aio_requests 16;
  multi_accept on;
  use epoll;
}

thread_pool pool_0 threads=16;
thread_pool pool_1 threads=16;
thread_pool pool_2 threads=16;

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;

  log_format graylog2_json escape=json '{ "host": "$host", "remote_addr":
"$remote_addr", "ssl_protocol": "$ssl_protocol", "ssl_cipher":
"$ssl_cipher", "body_bytes_sent": "$body_bytes_sent", "status": "$status",
"request": "$request", "request_uri": "$request_uri", "request_method":
"$request_method", "request_scheme": "$scheme", "server_protocol":
"$server_protocol", "http_referer": "$http_referer", "http_version":
"$http_version", "http_user_agent": "$http_user_agent", "request_time":
"$request_time", "upstream_cache_status": "$upstream_cache_status",
"upstream_addr": "$upstream_addr"}';

  map $status $loggable {
    ~^[23]  0;
    default 1;
  }

  access_log syslog:server=graylog.insave.ovh:12201 graylog2_json
if=$loggable;
  error_log syslog:server=graylog.insave.ovh:12302;

  keepalive_timeout     15;
  keepalive_requests 1000;
  client_header_timeout 20;
  client_body_timeout 20;
  reset_timedout_connection on;
  send_timeout 20;

  variables_hash_max_size 2048;
  variables_hash_bucket_size 128;

  sendfile            on;
  tcp_nopush          on;
  tcp_nodelay         on;
  types_hash_max_size 2048;
  server_tokens       off;

  client_max_body_size    128m;
  client_body_buffer_size 128k;

  proxy_cache_path /mnt/disk0 levels=1:2 keys_zone=cache_0:1024m
max_size=1700G inactive=1d use_temp_path=off;
  proxy_cache_path /mnt/disk1 levels=1:2 keys_zone=cache_1:1024m
max_size=1700G inactive=1d use_temp_path=off;
  proxy_cache_path /mnt/disk2 levels=1:2 keys_zone=cache_2:1024m
max_size=1700G inactive=1d use_temp_path=off;

  split_clients $hls_key $disk {
    33.3%    0;
    33.3%    1;
    *        2;
  }

  proxy_connect_timeout       60s;
  proxy_send_timeout          60s;
  proxy_read_timeout          60s;
  proxy_buffer_size           64k;
  proxy_buffers               4 32k;
  proxy_busy_buffers_size     64k;
  proxy_http_version          1.1;
  proxy_max_temp_file_size    4096m;
  proxy_temp_file_write_size  4m;
  proxy_ignore_client_abort   on;

  fastcgi_buffers 16 4k;
  fastcgi_buffer_size 4k;
  fastcgi_connect_timeout 100;
  fastcgi_send_timeout 100;

  gzip          on;
  gzip_proxied  any;
  gzip_types    application/vnd.apple.mpegurl video/f4m application/dash+xml
text/xml application/x-javascript application/javascript text/css;

  brotli        on;
  brotli_comp_level 4;
  brotli_types  application/vnd.apple.mpegurl video/f4m application/dash+xml
text/xml application/x-javascript application/javascript text/css;

  vod_metadata_cache metadata_cache 4096m 30m;
  vod_response_cache response_cache 256m 30m;
  vod_cache_buffer_size 512k;

  open_file_cache max=512000 inactive=5m;
  open_file_cache_valid 2m;
  open_file_cache_min_uses 2;
  open_file_cache_errors on;
  aio on;

  include /etc/nginx/sites-enabled/*.conf;
}
------------------------------------

nginx -v
nginx version: nginx/1.16.1
------------------------------------

nginx -V (я немного отформатировал для удобства)

configure arguments:
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib/nginx/modules
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx
--with-compat
--with-file-aio
--with-threads
--with-http_addition_module
--with-http_auth_request_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-http_geoip_module
--add-module=../nginx-vod-module
--add-module=../nginx-secure-token-module
--add-module=../nginx-akamai-token-validate-module
--add-module=../ngx_devel_kit
--add-module=../ngx_brotli
--add-module=../set-misc-nginx-module
--add-module=../ngx_cache_purge
--with-cc-opt='-g -O2 -specs=/usr/share/dpkg/no-pie-compile.specs
-fstack-protector-strong -Wformat -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -fPIC'
--with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro
-Wl,-z,now -Wl,--as-needed -pie'
---------------------------

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

Posted at Nginx Forum: https://forum.nginx.org/read.php?21,287800,287800#msg-287800



Подробная информация о списке рассылки nginx-ru