Opened 10 years ago

Closed 8 years ago

#6199 closed (wontfix)

Avoid cache stampedes

Reported by: Jeremy Dunck Owned by: nobody
Component: Core (Cache system) Version: master
Severity: Keywords: performance scalability cache
Cc: jdunck@…, sw+django@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:


From the patch:

+    Avoids cache stampeding by missing on *one* request prior to actual
+    expiration.  That single missed requestor then refills the cache prior to
+    real expiration.  All other requestors still get hits.
+    Adapted from MintCache from gfranxman:

This is also similar to mnot's stale-while-revalidate:

The cache wrapper works with any backend, but does have a 2% access overhead. Additionally, rather than storing exactly what is asked in the backend, additional bookkeeping data is stored in a tuple alongside the original object.

Attachments (1)

cache_avoid_stampede.diff (9.2 KB) - added by Jeremy Dunck 10 years ago.
Implementation, test, docs included.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Jeremy Dunck

Attachment: cache_avoid_stampede.diff added

Implementation, test, docs included.

comment:1 Changed 10 years ago by Simon Greenhill <dev@…>

Has patch: set
Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 9 years ago by krystal

milestone: 1.1

FYI, there is an other snippets that do the same :

IMHO, this change should really be merged in the core ; dog-piling is a common and dirty problem for everyone who have a few visitors and it's not adressed in django.

If the patch is not included, we should mention this effect on the Documentation page to help people know why their server crash under load :)

(I put the milestone to 1.1 so this patch get a "design decision", sorry if I shouldn't)

comment:3 Changed 9 years ago by krystal

Cc: sw+django@… added

comment:4 Changed 9 years ago by Jeremy Dunck

krystal, in fact this is an improved version of that snippet.

However, I would be surprised if this was included in core-- it can now be accomplished with a custom CACHE_BACKEND.

comment:5 Changed 9 years ago by Russell Keith-Magee

milestone: 1.1
Patch needs improvement: set
Triage Stage: Design decision neededAccepted

I can see that there is room for a dogpiling and other cache management strategies. However, as jdunck notes, this can now be acheived with a custom cache backend. This patch would need to be recast in those terms if it were to be integrated into trunk.

Regardless, this won't be happening for v1.1

comment:6 Changed 8 years ago by Jeremy Dunck

Resolution: wontfix
Status: newclosed

I'm wontfixing my own ticket; since CACHE_BACKEND allows extension, this doesn't belong in core.

I'll see about adding this to django-extensions.

Note: See TracTickets for help on using tickets.
Back to Top