Welcome! Log In Create A New Profile

Advanced

slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy
February 25, 2016 05:04AM
Здравтсвуйте.

Наткнулся на непонятную проблему при попытке увеличить proxy_cache_min_uses
в связке co slice module. При proxy_cache_min_uses 1 все работает корректно.

Имеется фронтенд на nginx 1.9.11 который проксирует и кеширует видео с
нескольких апстримов. Используется slice module. Видео проигрывается
спомощью video.js При попытке увеличить proxy_cache_min_uses возникают
проблемы с перемоткой:

Запрос №1:
Плеер начинает играть видео. Все штатно.
https://drive.google.com/file/d/0B5-OwnlywJGhY2Rla2RTaVlsd1k/view

Запрос №2:
Перематываем на произвольную позицию. Браузер делает range-запрос, а
получает 200 и полный Content-Length
https://drive.google.com/file/d/0B5-OwnlywJGhOWZtMTdCYlQ3Z1k/view

Фрагмент debug-лога:
2016/02/25 12:16:23 [debug] 17567#17567: *10 accept: 10.0.1.1:55552 fd:16
2016/02/25 12:16:23 [debug] 17567#17567: *10 event timer add: 16:
60000:1456391843913
2016/02/25 12:16:23 [debug] 17567#17567: *10 reusable connection: 1
2016/02/25 12:16:23 [debug] 17567#17567: *10 epoll add event: fd:16 op:1
ev:80002001
2016/02/25 12:16:23 [debug] 17567#17567: *10 post event 00007FBC2167F0D0
2016/02/25 12:16:23 [debug] 17567#17567: *10 delete posted event
00007FBC2167F0D0
2016/02/25 12:16:23 [debug] 17567#17567: *10 http wait request handler
2016/02/25 12:16:23 [debug] 17567#17567: *10 malloc: 0000000000C357B0:1024
2016/02/25 12:16:23 [debug] 17567#17567: *10 recv: fd:16 1009 of 1024
2016/02/25 12:16:23 [debug] 17567#17567: *10 reusable connection: 0
2016/02/25 12:16:23 [debug] 17567#17567: *10 posix_memalign:
0000000000C35BC0:4096 @16
2016/02/25 12:16:23 [debug] 17567#17567: *10 http process request line
2016/02/25 12:16:23 [debug] 17567#17567: *10 http request line: "GET
/streams/s1.example.com/0/aa7786d88a1529d6ba636e345415b220.mp4 HTTP/1.1"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http uri: "/streams/
s1.example.com/0/aa7786d88a1529d6ba636e345415b220.mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http args: ""
2016/02/25 12:16:23 [debug] 17567#17567: *10 http exten: "mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 posix_memalign:
0000000000C280C0:4096 @16
2016/02/25 12:16:23 [debug] 17567#17567: *10 http process request header
line
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Host:
cache.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Connection:
keep-alive"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Accept-Encoding:
identity;q=1, *;q=0"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "User-Agent:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/48.0.2564.116 Safari/537.36"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Accept: */*"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Accept-Language:
ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,bg;q=0.2"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Cookie:
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "Range:
bytes=696653667-1993091904"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header: "If-Range: Sun,
07 Feb 2016 12:46:26 GMT"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http header done
2016/02/25 12:16:23 [debug] 17567#17567: *10 event timer del: 16:
1456391843913
2016/02/25 12:16:23 [debug] 17567#17567: *10 generic phase: 0
2016/02/25 12:16:23 [debug] 17567#17567: *10 rewrite phase: 1
2016/02/25 12:16:23 [debug] 17567#17567: *10 test location: "/streams/"
2016/02/25 12:16:23 [debug] 17567#17567: *10 test location: ~
"^/streams/(?<upstream_hostname>[^/]+)/(?<upstream_uri>.*)$"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http regex set
$upstream_hostname to "s1.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http regex set $upstream_uri
to "0/aa7786d88a1529d6ba636e345415b220.mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 using configuration
"^/streams/(?<upstream_hostname>[^/]+)/(?<upstream_uri>.*)$"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http cl:-1 max:1048576
2016/02/25 12:16:23 [debug] 17567#17567: *10 rewrite phase: 3
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var
2016/02/25 12:16:23 [debug] 17567#17567: *10 http map started
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "
s1.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http map: "s1.example.com" "1"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "1"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script value: "0"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script equal
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script equal: no
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script if
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script if: false
2016/02/25 12:16:23 [debug] 17567#17567: *10 post rewrite phase: 4
2016/02/25 12:16:23 [debug] 17567#17567: *10 generic phase: 5
2016/02/25 12:16:23 [debug] 17567#17567: *10 generic phase: 6
2016/02/25 12:16:23 [debug] 17567#17567: *10 generic phase: 7
2016/02/25 12:16:23 [debug] 17567#17567: *10 access phase: 8
2016/02/25 12:16:23 [debug] 17567#17567: *10 access: D52B000A FFFFFFFF
D52B000A
2016/02/25 12:16:23 [debug] 17567#17567: *10 access phase: 9
2016/02/25 12:16:23 [debug] 17567#17567: *10 access phase: 10
2016/02/25 12:16:23 [debug] 17567#17567: *10 post access phase: 11
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "http://"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "
s1.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "/"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var:
"0/aa7786d88a1529d6ba636e345415b220.mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: ""
2016/02/25 12:16:23 [debug] 17567#17567: *10 http init upstream, client
timer: 0
2016/02/25 12:16:23 [debug] 17567#17567: *10 epoll add event: fd:16 op:3
ev:80002005
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "/streams/
s1.example.com/0/aa7786d88a1529d6ba636e345415b220.mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http split: 1335405152
4294967295
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "cache_"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "ssd01"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "
s1.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var:
"0/aa7786d88a1529d6ba636e345415b220.mp4"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var:
"bytes=0-5242879"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http cache key:
"s1.example.com0/aa7786d88a1529d6ba636e345415b220.mp4bytes=0-5242879"
2016/02/25 12:16:23 [debug] 17567#17567: *10 add cleanup: 0000000000C36B98
2016/02/25 12:16:23 [debug] 17567#17567: *10 http file cache exists: -2 e:0
2016/02/25 12:16:23 [debug] 17567#17567: *10 http upstream cache: 8
2016/02/25 12:16:23 [debug] 17567#17567: *10 posix_memalign:
0000000000C290D0:4096 @16
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "Host: "
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var: "
s1.example.com"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "
"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "Range: "
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script var:
"bytes=0-5242879"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "
"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: "Connection:
close
"
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: ""
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: ""
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: ""
2016/02/25 12:16:23 [debug] 17567#17567: *10 http script copy: ""

Конфиг:

proxy_cache_path /disks/ssd01 levels=1:2 keys_zone=cache_ssd01:4m
use_temp_path=off inactive=7d max_size=230G;

split_clients $request_uri $disk {
100% ssd01;
}

location /streams/ {
location ~
^/streams/(?<upstream_hostname>[^/]+)/(?<upstream_uri>.*)$ {
if ($allowed = 0) {
return 403;
}

slice 5m;

proxy_pass http://
$upstream_hostname/$upstream_uri$is_args$args;
proxy_set_header Host $upstream_hostname;
proxy_set_header Range $slice_range;
proxy_ignore_client_abort on;

proxy_cache cache_$disk;
proxy_cache_key
$upstream_hostname$upstream_uri$slice_range;
proxy_cache_revalidate on;

proxy_cache_bypass $arg_start;
proxy_no_cache $arg_start;

proxy_cache_lock on;


proxy_cache_use_stale error timeout invalid_header
updating http_500 http_502 http_503 http_504 http_403;
}
}


# uname -a
Linux localhost.localdomain 3.16.0-4-amd64 #1 SMP Debian
3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux

# /usr/sbin/nginx -V
nginx version: nginx/1.9.11
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
--modules-path=%{_libdir}/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-http_ssl_module --with-http_realip_module
--with-http_addition_module --with-http_sub_module --with-http_dav_module
--with-http_flv_module --with-http_mp4_module --with-http_gunzip_module
--with-http_gzip_static_module --with-http_random_index_module
--with-http_secure_link_module --with-http_stub_status_module
--with-http_auth_request_module --with-threads --with-stream
--with-stream_ssl_module --with-http_slice_module --with-mail
--with-mail_ssl_module --with-file-aio --with-http_v2_module
--with-cc-opt='-g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6


Спасибо.

--
WBR,
Vadim Lazovskiy
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 25, 2016 05:04AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 25, 2016 05:54AM

Re: slice module и proxy_cache_min_uses больше единицы.

Roman Arutyunyan February 25, 2016 08:54AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 25, 2016 10:46AM

Re: slice module и proxy_cache_min_uses больше единицы.

Evgeniy Berdnikov February 25, 2016 10:54AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 25, 2016 11:28AM

Re: slice module и proxy_cache_min_uses больше единицы.

Roman Arutyunyan February 25, 2016 01:30PM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 26, 2016 02:46AM

Re: slice module и proxy_cache_min_uses больше единицы.

Roman Arutyunyan February 26, 2016 04:54AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 27, 2016 10:50AM

Re: slice module и proxy_cache_min_uses больше единицы.

Roman Arutyunyan February 27, 2016 11:10AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 27, 2016 11:58AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vadim Lazovskiy February 29, 2016 01:24AM

Re: slice module и proxy_cache_min_uses больше единицы.

Roman Arutyunyan February 29, 2016 03:48AM

Re: slice module и proxy_cache_min_uses больше единицы.

Vasiliy P. Melnik February 29, 2016 04:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 179
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready