Services/Sync/Server/Notes/QuotaAlgo: Difference between revisions

From MozillaWiki
< Services‎ | Sync‎ | Server
Jump to navigation Jump to search
(Created page with 'Define low_threshold = quota - 1M 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 cu…')
 
No edit summary
 
(7 intermediate revisions by 3 users not shown)
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 db and reset total and timestamp in memcache
# 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
- write data
# add sum of incoming payloads to quota
- add sum of incoming payloads to quota
# if total > low_threshold, add an X-Weave-Quota-Remaining header (value is remaining storage space in bytes)
- if total > low_threshold, add an X-Weave header
 
On a delete
On a delete
- delete data
# delete user quota record from memcache
- delete user quota record from memcache


add /info/collection_usage (requires version bump to 1.1)
add /info/collection_usage (requires version bump to 1.1)
- get grouped collection totals
# get grouped collection totals
- write overall total to memcache
# sum them and write overall total (and timestamp) to memcache
   
   
monitoring script
monitoring script
- when user total is calculated, update memcache (how to do that from a different box?)
# when user total is calculated, update memcache (may be firewall issues here)

Latest revision as of 18:27, 3 September 2010

Define low_threshold = quota - 1M

Quota results are in bytes

On a write

  1. If a user has no quota entry, grab the list from the database and put it into memcache along with the current timestamp
  2. get current total and associated timestamp
  3. if total > low_threshold and timestamp is older than 1h - refetch total from dbreset total and timestamp in memcache
  4. if total > quota, reject write
  5. add sum of incoming payloads to quota
  6. if total > low_threshold, add an X-Weave-Quota-Remaining header (value is remaining storage space in bytes)

On a delete

  1. delete user quota record from memcache

add /info/collection_usage (requires version bump to 1.1)

  1. get grouped collection totals
  2. sum them and write overall total (and timestamp) to memcache

monitoring script

  1. when user total is calculated, update memcache (may be firewall issues here)