<div dir="ltr">Hi:<div> If I want to implement this variable which returns the sum of all upstream response sizes</div>from all subrequests. This is feasible? <div><br></div><div>Thank you</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Roman Arutyunyan <<a href="mailto:arut@nginx.com">arut@nginx.com</a>> 于2019年11月27日周三 下午6:20写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Wed, Nov 27, 2019 at 09:14:09AM +0800, lx wrote:<br>
> Hi:<br>
> When we use module of slice, the nuber of bytes from upstream server<br>
> is more than the bytes which sent to client, So I want to get the number<br>
> of bytes from upstream server, How to get it?<br>
<br>
We don't have a variable that returns the sum of all upstream response sizes<br>
from all subrequests.<br>
<br>
Also, there can be multiple upstream servers. And each slice can be fetched<br>
from a different one.<br>
<br>
> Thank you<br>
> <br>
> Roman Arutyunyan <<a href="mailto:arut@nginx.com" target="_blank">arut@nginx.com</a>> 于2019年11月26日周二 下午9:10写道:<br>
> <br>
> > Hi,<br>
> ><br>
> > On Tue, Nov 26, 2019 at 07:24:00PM +0800, lx wrote:<br>
> > > hi all:<br>
> > > When I use module of slice, upstream_response_length and<br>
> > > upstream_addr can't work.<br>
> > > nginx.conf :<br>
> > > #########################################################################<br>
> > > include mime.types;<br>
> > > default_type application/octet-stream;<br>
> > ><br>
> > > log_format main<br>
> > ><br>
> > '$status^$scheme^$request^$body_bytes_sent^$request_time^$upstream_cache_status^$remote_addr^$http_referer^$http_user_agent^$content_type^$http_range^$cookie_name^$upstream_addr^$upstream_response_time^$upstream_bytes_received^$upstream_response_length^[$time_local]';<br>
> > ><br>
> > ><br>
> > > access_log logs/access.log main;<br>
> > > rewrite_log on;<br>
> > ><br>
> > > sendfile on;<br>
> > > aio threads;<br>
> > ><br>
> > > keepalive_timeout 65;<br>
> > ><br>
> > > if ($uri ~ ^/([a-zA-Z0-9\.]+)/([a-zA-Z0-9\.]+)/(.*)) {<br>
> > > set $cdn $1;<br>
> > > set $new_host $2;<br>
> > > set $new_uri $3;<br>
> > > }<br>
> > ><br>
> > > location / {<br>
> > > slice 1m;<br>
> > > proxy_cache_lock on;<br>
> > > proxy_cache my_cache;<br>
> > > proxy_cache_key $uri$is_args$args$slice_range;<br>
> > > proxy_set_header Range $slice_range;<br>
> > > proxy_cache_valid 200 206 24h;<br>
> > > proxy_pass http://$cdn/$new_uri;<br>
> > > }<br>
> > > #########################################################################<br>
> > > I Initiate a rang htttp request, for example<br>
> > > #########################################################################<br>
> > > curl -o result -H 'Range: bytes=2001-4932000' "<br>
> > ><br>
> > <a href="http://127.0.0.1:64002/A.com/B.com/appstore/developer/soft/20191008/201910081449521157660.patch" rel="noreferrer" target="_blank">http://127.0.0.1:64002/A.com/B.com/appstore/developer/soft/20191008/201910081449521157660.patch</a><br>
> > > "<br>
> > > #########################################################################<br>
> > > upstream_response_length and upstream_bytes_received is just 1 MB, not<br>
> > > 4.9MB. I find nginx build 5 http request to A.com by tcpdump, and nginx<br>
> > > implement slice by subrequest.<br>
> > ><br>
> > > This is why? How to fix it?<br>
> ><br>
> > Yes. When using the slice module, response is served by multiple<br>
> > subrequests.<br>
> > Each subrequest serves its own part. It has a separate cache key, fetches<br>
> > a<br>
> > separate cache entry and contacts the upstream server using a serparate<br>
> > connection. When you use an $upstream_XXX variable, it returns data from<br>
> > a subrequest.<br>
> ><br>
> > If you want combined numbers, use client-side variables like $bytes_sent<br>
> > instead.<br>
> ><br>
> > ><br>
> > > Thank you<br>
> ><br>
> > > _______________________________________________<br>
> > > nginx mailing list<br>
> > > <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
> > > <a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
> ><br>
> ><br>
> > --<br>
> > Roman Arutyunyan<br>
> > _______________________________________________<br>
> > nginx mailing list<br>
> > <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
> > <a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
> ><br>
<br>
> _______________________________________________<br>
> nginx mailing list<br>
> <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
> <a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
<br>
<br>
-- <br>
Roman Arutyunyan<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div>