Services/Sync/Server/Notes/QuotaAlgo: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Define low_threshold = quota - 1M | Define low_threshold = quota - 1M | ||
Quota results are in bytes | |||
On a write | On a write | ||
# If a user has no quota entry, grab the list from the database and put it into memcache along with the current timestamp | # If a user has no quota entry, grab the list from the database and put it into memcache along with the current timestamp | ||
# get current total and associated timestamp | # get current total and associated timestamp | ||
# if total > low_threshold and timestamp is older than 1h - refetch total from | # if total > low_threshold and timestamp is older than 1h - refetch total from dbreset total and timestamp in memcache | ||
# if total > quota, reject write | # if total > quota, reject write | ||
# add sum of incoming payloads to quota | # add sum of incoming payloads to quota |
Revision as of 17:02, 21 July 2010
Define low_threshold = quota - 1M
Quota results are in bytes
On a write
- If a user has no quota entry, grab the list from the database and put it into memcache along with the current timestamp
- get current total and associated timestamp
- if total > low_threshold and timestamp is older than 1h - refetch total from dbreset total and timestamp in memcache
- if total > quota, reject write
- add sum of incoming payloads to quota
- if total > low_threshold, add an X-Weave-Quota header
On a delete
- delete user quota record from memcache
add /info/collection_usage (requires version bump to 1.1)
- get grouped collection totals
- sum them and write overall total (and timestamp) to memcache
monitoring script
- when user total is calculated, update memcache (may be firewall issues here)