# Dogpiling

**URL:** <https://www.ruby-forum.com/t/dogpiling/185950>\
**Category:** NGINX\
**Created:** [March 29, 2010, 5:11pm UTC](https://www.ruby-forum.com/t/dogpiling/185950 "2010-03-29T17:11:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 29, 2010, 5:11pm UTC](https://www.ruby-forum.com/t/dogpiling/185950/1 "2010-03-29T17:11:21Z")

</div>

Hey folks,

Can I use nginx for anti-dogpiling?

We have been using Varnish cause it has antidogpiling options, but its  
so limited in terms of what it does as to what we need, that id love to  
use nginx.

Posted at Nginx Forum:

> **[dogpiling](https://forum.nginx.org/read.php?2,69088,69088#msg-69088)**
>
> Hey folks, Can I use nginx for anti-dogpiling? We have been using Varnish cause it has antidogpiling options, but its so limited in terms of what it does as to what we need, that id love to use nginx.

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 2:15am UTC](https://www.ruby-forum.com/t/dogpiling/185950/2 "2010-03-30T02:15:40Z")

</div>

Hi, could you explain more about dogpiling? i don’t understand and  
haven’t found any term related to web except for search engine named  
‘dogpile’

–  
Regards,  
Kiswono P  
GB

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 4:44am UTC](https://www.ruby-forum.com/t/dogpiling/185950/3 "2010-03-30T04:44:20Z")

</div>

> He’s referring to a cache stampede, when an item in the proxy cache  
> expires and multiple threads simultaneously try to repopulate it causing  
> load spikes and possible locking conditions.

nginx changes status of expired cache items to “UPDATING” for the period  
of  
time when it fetches new copies. Combine this with  
“proxy\_cache\_use\_stale  
updating” and “dogpiling” shouldn’t be a problem.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 2:37am UTC](https://www.ruby-forum.com/t/dogpiling/185950/4 "2010-03-30T02:37:54Z")

</div>

He’s referring to a cache stampede, when an item in the proxy cache  
expires and multiple threads simultaneously try to repopulate it causing  
load spikes and possible locking conditions. The item below from  
memcache’s faq has a few suggestions of how to avoid this for memcached.

[http://code.google.com/p/memcached/wiki/FAQ#How\_to\_prevent\_clobbering\_updates,\_stampeding\_requests](http://code.google.com/p/memcached/wiki/FAQ#How_to_prevent_clobbering_updates,_stampeding_requests)

After a quick look I didn’t see any options to avoid stampede’s in  
nginx’s proxy caching nor in the memcached module. Does nginx have this  
built in? Or when a item in the proxy cache expires, is there a rush of  
requests to the back-end to refresh it?

A useful method (if it isn’t already built in) might be to block threads  
that have requested the resource being refreshed until the thread doing  
the refreshing completes. A configurable timeout might be helpful.

Mark.

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 12:44pm UTC](https://www.ruby-forum.com/t/dogpiling/185950/5 "2010-03-30T12:44:15Z")

</div>

Hello!

On Tue, Mar 30, 2010 at 02:06:51AM -0700, Mark M. wrote:

> I tried to update the documentation to add an explanation of the  
> ‘updating’ parameter of proxy\_cache\_use\_stale but it appears to have  
> broken the entire documentation page on the proxy module after I  
> saved my changes to the wiki. It’s now blank:
> 
> [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpProxyModule)
> 
> When I hit save the wiki server sent me an index.php file that my  
> browser wanted to save to disk (incorrect mime type set). I tried  
> several times to re-save or cancel my edit but same result.

Cliff, could you please take a look what’s going wrong? Wiki just  
closes connection on some pages (including the mentioned one).

Maxim D.

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 5:40pm UTC](https://www.ruby-forum.com/t/dogpiling/185950/6 "2010-03-30T17:40:47Z")

</div>

On Tue, 2010-03-30 at 14:43 +0400, Maxim D. wrote:

> > When I hit save the wiki server sent me an index.php file that my  
> > browser wanted to save to disk (incorrect mime type set). I tried  
> > several times to re-save or cancel my edit but same result.
> 
> Cliff, could you please take a look what’s going wrong? Wiki just  
> closes connection on some pages (including the mentioned one).

It should be fixed now. The VE was running out of tcp sockets.

Regards,  
Cliff

> Maxim D.  
> –  
> [Google Search](http://www.google.com/search?q=vonage+sucks)

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 11:07am UTC](https://www.ruby-forum.com/t/dogpiling/185950/7 "2010-03-30T11:07:54Z")

</div>

I tried to update the documentation to add an explanation of the  
‘updating’ parameter of proxy\_cache\_use\_stale but it appears to have  
broken the entire documentation page on the proxy module after I saved  
my changes to the wiki. It’s now blank:

[http://wiki.nginx.org/NginxHttpProxyModule](http://wiki.nginx.org/NginxHttpProxyModule)

When I hit save the wiki server sent me an index.php file that my  
browser wanted to save to disk (incorrect mime type set). I tried  
several times to re-save or cancel my edit but same result.

Mark.

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 5:43pm UTC](https://www.ruby-forum.com/t/dogpiling/185950/8 "2010-03-30T17:43:42Z")

</div>

On Tue, 2010-03-30 at 14:43 +0400, Maxim D. wrote:

> > When I hit save the wiki server sent me an index.php file that my  
> > browser wanted to save to disk (incorrect mime type set). I tried  
> > several times to re-save or cancel my edit but same result.
> 
> Cliff, could you please take a look what’s going wrong? Wiki just  
> closes connection on some pages (including the mentioned one).

Hm, I stand corrected, there’s still an issue. I’ll report back when  
it’s resolved.

Cliff

> Maxim D.  
> –  
> [Google Search](http://www.google.com/search?q=vonage+sucks)

---

<div class="post-metadata">

**Author:** ![vburshteyn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9d8465/32.png) [@vburshteyn](https://www.ruby-forum.com/u/vburshteyn)\
**Post date:** [March 30, 2010, 5:53pm UTC](https://www.ruby-forum.com/t/dogpiling/185950/9 "2010-03-30T17:53:05Z")

</div>

Okay, it is fixed.

Cliff

On Tue, 2010-03-30 at 14:43 +0400, Maxim D. wrote:

> > When I hit save the wiki server sent me an index.php file that my  
> > browser wanted to save to disk (incorrect mime type set). I tried  
> > several times to re-save or cancel my edit but same result.
> 
> Cliff, could you please take a look what’s going wrong? Wiki just  
> closes connection on some pages (including the mentioned one).
> 
> Maxim D.  
> –  
> [Google Search](http://www.google.com/search?q=vonage+sucks)
