Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Reduce concurrent adM requests #248

Closed
pjenvey opened this issue Aug 9, 2021 · 0 comments · Fixed by #250
Closed

Reduce concurrent adM requests #248

pjenvey opened this issue Aug 9, 2021 · 0 comments · Fixed by #250
Assignees

Comments

@pjenvey
Copy link
Member

pjenvey commented Aug 9, 2021

When first populating or refreshing contile's cache with content from adM, multiple requests for the same content can be triggered simultaneously. Many of these request are redundant, which:

  1. add extra work for contile to process and write them to the cache (see Avoid the cache "dog-piling" effect #46 for potential cache side effects)
  2. cause extra traffic to adM (particularly problematic during downtime conditions Rate limit calls to adM in downtime conditions #220)

With Contile now handling image hosting its processing task is potentially lengthier, which could result in even larger number of redundant concurrent requests triggered (since the cache doesn't fill as quickly).

To improve this: when an adM request is triggered Contile could write this event to its cache, letting subsequent requests act more intelligently. Instead of spawning more requests they could instead: wait for that adM request to finish (by simply 503ing the client or actually waiting over an spmc channel for its completion) or by simply returning stale content until the request finishes.

┆Issue is synchronized with this Jira Task

@pjenvey pjenvey changed the title Rate limit calls to adM Reduce concurrent adM requests Aug 9, 2021
pjenvey added a commit that referenced this issue Aug 9, 2021
by storing state about active adM requests in the cache

when a request's in the process of populating a cache entry for the first time,
subsequent requests will 503 until it's completed

when a request's in the process of refreshing an existing cache entry,
subsequent requests will return the stale entry until it's completed

and cache empty for BadAdmResponse errors (which haven't happened yet)

Closes #248
pjenvey added a commit that referenced this issue Aug 9, 2021
by storing state about active adM requests in the cache

when a request's in the process of populating a cache entry for the first time,
subsequent requests will 503 until it's completed

when a request's in the process of refreshing an existing cache entry,
subsequent requests will return the stale entry until it's completed

and cache empty for BadAdmResponse errors (which haven't happened yet)

Closes #248
jrconlin added a commit that referenced this issue Aug 9, 2021
by storing state about active adM requests in the cache

when a request's in the process of populating a cache entry for the first time,
subsequent requests will 503 until it's completed

when a request's in the process of refreshing an existing cache entry,
subsequent requests will return the stale entry until it's completed

and cache empty for BadAdmResponse errors (which haven't happened yet)

Closes #248

Co-authored-by: JR Conlin <jconlin+git@mozilla.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants