<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div><div>Instead of doing round robin load balancing why not do a URI based load balancing? Then you ensure your cached file is only present on a single machine behind the load balancer.</div><div><br></div><div>Sure there will be moments where this is not the case – let's assume that a box goes down, and traffic will switch, but in that case I'd as a "post task" take the moment from when the machine went down, until it came online again, find all requests that expired in the meantime, and flush it to ensure the entry is updated on the machine that had been down in the meantime.</div><div><br></div><div>It will still require some work, but at least over time your "overhead" should be less.</div><div><div id="MAC_OUTLOOK_SIGNATURE"></div></div></div><div><br></div><span id="OLK_SRC_BODY_SECTION"><div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">From: </span> nginx <<a href="mailto:nginx-bounces@nginx.org">nginx-bounces@nginx.org</a>> on behalf of Joan Tomàs i Buliart <<a href="mailto:joan.tomas@marfeel.com">joan.tomas@marfeel.com</a>><br><span style="font-weight:bold">Reply-To: </span> <<a href="mailto:nginx@nginx.org">nginx@nginx.org</a>><br><span style="font-weight:bold">Date: </span> Friday, 7 July 2017 at 11.52<br><span style="font-weight:bold">To: </span> <<a href="mailto:nginx@nginx.org">nginx@nginx.org</a>><br><span style="font-weight:bold">Subject: </span> NGINX stale-while-revalidate cluster<br></div><div><br></div><span style="mso-bookmark:_MailOriginalBody"><blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;"><div>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div text="#000000" bgcolor="#FFFFFF">
<p style="font-size:12.8px"><tt>Hi,</tt><tt><br>
</tt><tt><br>
</tt><tt>We are implementing an stale-while-revalidate webserver
cluster with NGINX. </tt><tt><br>
</tt><tt><br>
</tt><tt>We are using the new proxy_cache_background_update to
answer request as soon as possible while NGINX updates the
content from the origin in the background. This solution works
perfectly when the requests for the same object are served by
the same NGINX server (when we have only one server or when we
have a previous load balancer that classifies the requests). </tt><tt><br>
</tt><tt><br>
</tt><tt>In our scenario we have a round robin load balancer (ELB)
and we need to scale the webservers layer. So, as a consequence,
only the Nginx that receive the request updates the cache
content while the others keep the old version. This means that,
we can send old versions of content due to the content not being
updated on all the webservers. The problem accentuates when we
put a CDN in front of the webservers.</tt><tt><br>
</tt><tt><br>
</tt><tt><span style="font-size:12.8px">We are thinking on
developing something that once an Nginx instance updates its
cache would let know all other instances to get a copy of the
newest content. We are thinking about processing NGINX logs
and, when it detects a MISS, EXPIRED or UPDATING cache status,
it makes a HEAD request to the other NGINXs on the cluster to
force the invalidation of this content.</span></tt><tt><br>
</tt></p>
<p style="font-size:12.8px"><tt><br>
</tt><tt>Do any of you have dealt with this problem or a similar
one?</tt><tt><br>
</tt><tt><br>
</tt></p>
<p style="font-size:12.8px"><tt>We have also tried the post_action
but it is blocking the client request until it completes. It is
not clear for us which would be the best approach. The options
that we are considering are:</tt><tt><br>
</tt><tt><br>
</tt><tt>- NGINX module</tt><tt><br>
</tt><tt>- LUA script</tt><tt><br>
</tt><tt>- External script that process syslog entries from NGINX</tt><tt><br>
</tt><tt><br>
</tt><tt>What would be your recommendation?</tt><tt><br>
</tt><tt><br>
</tt></p>
<tt>Many thanks in advance,</tt><span class="gmail-HOEnZb"><font color="#888888"><br>
<br>
<br>
</font></span>
<div class="moz-signature">-- <br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Joan Tomàs-Buliart</title>
<div align="left"><a href="http://www.marfeel.com"><img alt="www.marfeel.com" title="www.marfeel.com" src="cid:part1.479F6270.CBB4F497@marfeel.com" class="" width="284" border="0" height="44"></a><br>
</div>
Joan Tomàs-Buliart<br>
+34 931 785 950<br>
<a href="http://www.marfeel.com">www.marfeel.com</a><br>
<a href="http://blog.marfeel.com/earn-money-marfeel-referral-program/">Discover
our referral program!!</a><br>
</div>
</div></div>
_______________________________________________
nginx mailing list
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></span></span></body></html>