Welcome! Log In Create A New Profile

Advanced

Re: nginx cache

Vasil Mikhalenya
February 12, 2016 11:18AM
добавлю что

nginx version: nginx/1.9.10
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
built with OpenSSL 1.0.2f 28 Jan 2016
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/share/nginx
--sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx
--with-openssl=/builddir/build/BUILD/nginx-1.9.10/openssl-1.0.2f
--with-openssl-opt=enable-tlsext --with-http_secure_link_module
--with-http_random_index_module --with-http_ssl_module
--with-http_realip_module --with-http_addition_module
--with-http_sub_module --with-http_dav_module
--with-http_gzip_static_module --with-http_stub_status_module
--with-http_geoip_module --with-http_v2_module
--with-http_auth_request_module --with-debug --with-file-aio --with-stream
--with-stream_ssl_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'
--add-module=/builddir/build/BUILD/nginx-1.9.10/lua-nginx-module-0.10.0
--add-module=/builddir/build/BUILD/nginx-1.9.10/ngx_devel_kit-0.2.19
--add-module=/builddir/build/BUILD/nginx-1.9.10/nginx_accept_language_module
--add-module=/builddir/build/BUILD/nginx-1.9.10/nginx-dav-ext-module
--add-module=/builddir/build/BUILD/nginx-1.9.10/ngx_http_redis-0.3.7
--add-module=/builddir/build/BUILD/nginx-1.9.10/echo-nginx-module-0.56
--add-module=/builddir/build/BUILD/nginx-1.9.10/ngx_cache_purge
--add-module=/builddir/build/BUILD/nginx-1.9.10/nginx-push-stream-module
--add-module=/builddir/build/BUILD/nginx-1.9.10/nginx-module-vts


запросы клиентов с range, соответственно ответы 206

2016-02-12 18:38 GMT+03:00 Vasil Mikhalenya <bazilek@gmail.com>:

> проблема все еще воспроизводится с таким конфигом,
>
> location / {
> proxy_pass http://origin.example.com;
> proxy_set_header Host $proxy_host;
> proxy_cache_lock on;
> proxy_cache_lock_age 1d;
> proxy_cache_lock_timeout 1d;
> proxy_cache_revalidate on;
> proxy_cache_use_stale updating;
> proxy_cache_key "$uri";
> add_header Cache $upstream_cache_status;
> add_header X-ID "{{ ansible_hostname }}";
> }
>
> за пару часов nginx просто съедает >1Tb локального диска, помогает только
> остановка nginx, очистка tmp кеша, запуск nginx, иногда делать это нужно
> несколько раз
>
> в логах в этот момент
>
> 2016/02/11 05:08:42 [crit] 9777#9777: *54423736 cache file
> "/var/lib/nginx/cache/c1/9c9de47f28ebc598e526af36d402e8f4" has too long
> header, client: 67.11.37.88,
> 2016/02/11 05:08:44 [crit] 9777#9777: *54423724 cache file
> "/var/lib/nginx/cache/c1/9c9de47f28ebc598e526af36d402e8f4" has too long
> header, client: 67.11.37.88,
> 2016/02/11 05:08:44 [crit] 9777#9777: *54423726 cache file
> "/var/lib/nginx/cache/c1/9c9de47f28ebc598e526af36d402e8f4" has too long
> header, client: 67.11.37.88,
> 2016/02/11 05:08:44 [crit] 9777#9777: *54423729 cache file
> "/var/lib/nginx/cache/c1/9c9de47f28ebc598e526af36d402e8f4" has too long
> header, client: 67.11.37.88,
> 2016/02/11 05:08:44 [crit] 9777#9777: *54423737 cache file
> "/var/lib/nginx/cache/c1/9c9de47f28ebc598e526af36d402e8f4" has too long
> header, client: 67.11.37.88,
>
>
> 2015-04-30 14:05 GMT+03:00 Vasil Mikhalenya <bazilek@gmail.com>:
>
>> Спасибо, пробуем.
>>
>> Однако это не совсем очевидно, что во время валидации cache в tmpdir
>> начинают появляться файлы на каждый range запрос.
>>
>> 2015-04-29 14:18 GMT+03:00 Maxim Dounin <mdounin@mdounin.ru>:
>>
>>> Hello!
>>>
>>> On Wed, Apr 29, 2015 at 12:35:22PM +0300, Vasil Mikhalenya wrote:
>>>
>>> > Коллеги, подскажите что происходит
>>>
>>> [...]
>>>
>>> > proxy_cache_path /var/lib/nginx/cache keys_zone=mycdn:20m inactive=1d
>>> > use_temp_path=off;
>>> >
>>> >
>>> > server {
>>> > listen 80;
>>> > server_name mycdn.com 127.0.0.1;
>>> >
>>> > proxy_cache mycdn;
>>> >
>>> > location / {
>>> > proxy_pass http://origin;
>>> > proxy_set_header Host $proxy_host;
>>> > proxy_cache_lock on;
>>> > proxy_cache_lock_age 2h;
>>> > proxy_cache_lock_timeout 2h;
>>> > proxy_cache_key "$uri";
>>> > add_header Cache $upstream_cache_status;
>>> > }
>>> > }
>>> >
>>> >
>>> > [root@node ~]# ll /var/lib/nginx/cache/ | wc -l
>>> >
>>> > 228
>>> > т.е. у nginx в cache есть около 2 сотен популярных файлов (118G
>>> > /var/lib/nginx/cache/),
>>> > он успешно отдает несколько дней, ничего нового из origin не качает, в
>>> > какой то момент случается это
>>>
>>> Видимо, это происходит в тот момент, когда ответы в кеше
>>> expire'ятся. Имеет смысл включить "proxy_cache_use_stale
>>> updating", см. тут:
>>>
>>> http://nginx.org/r/proxy_cache_use_stale/ru
>>>
>>> Кроме того, если речь идёт о больших статических файлах - имеет
>>> смысл также использовать proxy_cache_revalidate, см. тут:
>>>
>>> http://nginx.org/r/proxy_cache_revalidate/ru
>>>
>>> > [root@node ~]# ll /var/lib/nginx/cache/temp/ | wc -l
>>> >
>>> > 5714
>>> >
>>> > Т.е. число файлов в temp растет очень быстро, хотя обычно = 0.
>>> >
>>> > restart nginx и очистка tempdir не помогает (файлы в tempdir появляются
>>> > снова), помогает только полная очистка cache
>>>
>>> Потому что proxy_cache_lock используется только при добавлении
>>> элементов в кеш. Если хочется избежать одновременных обращений на
>>> бекенд нескольких клиентов при обновлении, то надо включать
>>> "proxy_cache_use_stale updating", см. выше.
>>>
>>> --
>>> Maxim Dounin
>>> http://nginx.org/
>>>
>>> _______________________________________________
>>> nginx-ru mailing list
>>> nginx-ru@nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>>>
>>
>>
>>
>> --
>> Best regards,
>> Vasil Mikhalenya
>>
>
>
>
> --
> Best regards,
> Vasil Mikhalenya
>



--
Best regards,
Vasil Mikhalenya
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

nginx cache

Vasil Mikhalenya April 16, 2015 05:28AM

Re: nginx cache

Vasil Mikhalenya April 16, 2015 05:42AM

Re: nginx cache

Vasil Mikhalenya April 16, 2015 11:50AM

Re: nginx cache

Валентин Бартенев April 16, 2015 07:28PM

Re: nginx cache

Vasil Mikhalenya April 29, 2015 05:36AM

Re: nginx cache

Maxim Dounin April 29, 2015 07:20AM

Re: nginx cache

Vasil Mikhalenya April 30, 2015 07:06AM

Re: nginx cache

Vasil Mikhalenya February 12, 2016 10:40AM

Re: nginx cache

Vasil Mikhalenya February 12, 2016 11:18AM

Re: nginx cache

Maxim Dounin February 12, 2016 09:18PM

Re: nginx cache

Vasil Mikhalenya February 14, 2016 06:36AM

Re: nginx cache

Vasil Mikhalenya February 29, 2016 07:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 254
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