Opened 17 years ago
Closed 15 years ago
#6199 closed (wontfix)
Avoid cache stampedes
Reported by: | Jeremy Dunck | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
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: | no | UI/UX: | no |
Description
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: + http://www.djangosnippets.org/snippets/155/
This is also similar to mnot's stale-while-revalidate:
http://www.mnot.net/blog/2007/12/12/stale
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)
Change History (7)
by , 17 years ago
Attachment: | cache_avoid_stampede.diff added |
---|
comment:1 by , 17 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|
FYI, there is an other snippets that do the same : http://www.djangosnippets.org/snippets/793/
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 by , 16 years ago
Cc: | added |
---|
comment:4 by , 16 years ago
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 by , 16 years ago
milestone: | 1.1 |
---|---|
Patch needs improvement: | set |
Triage Stage: | Design decision needed → Accepted |
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 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
Implementation, test, docs included.