Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Add persistent per request degradation on failure #1

Merged
merged 2 commits into from Aug 24, 2016

Conversation

bourivouh
Copy link

When bad things with redis happens, it raises a lot of Timeout or Connection error. If DEGRADE_ON_FAILURE is enabled, django goes to database after every error and can get its data anyway. But for every db request it does three (and even four if redisreplica is used) queries: two for asking replica and master for a cached data, one for getting data from db, and another one for saving cache.
In this fix client will be marked as degraded if Timeout or Connection error happens. After that no queries will be executed by this client during current request. So in case which described above we will have only three queries per first fetch (asking replica and master for cached data and getting data from db), and we won't try to ask cacheops for all next queries untill request won't be finished.

It's disabled by default and can be enabled by setting CACHEOPS_DEGRADE_PERSISTENT_PER_REQUEST flag to True.

@bourivouh
Copy link
Author

@ttyS15, @tumb1er I think it can be interesting for you

@@ -15,7 +15,8 @@ class Settings(object):
CACHEOPS_DEFAULTS = {}
CACHEOPS = {}
CACHEOPS_LRU = False
CACHEOPS_DEGRADE_ON_FAILURE = False
CACHEOPS_DEGRADE_ON_FAILURE = True
CACHEOPS_DEGRADE_PERSISTENT_PER_REQUEST = False
Copy link

@tumb1er tumb1er Aug 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CACHEOPS_DEGRADE_WHOLE_REQUEST?
CACHEOPS_DEGRADE_TILL_REQUEST_FINISHED?
I read these settings like "Cacheops, honey, please, degrade on failure!" or "Cacheops, please, degrade till the end of request" :)
Or like a term:
"persistent degrade for whole request".
I mean, proper english grammar is necessary here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CACHEOPS_DEGRADE_TILL_REQUEST_FINISHED sounds ok.
Also there is an another bug here: I shouldn't change default for CACHEOPS_DEGRADE_ON_FAILURE

@tumb1er tumb1er merged commit 8002c75 into rutube:readreplica Aug 24, 2016
@bourivouh bourivouh deleted the readreplica branch August 24, 2016 15:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants