Page MenuHomePhabricator

Cache MessageRepository in SSR
Closed, ResolvedPublic5 Estimated Story Points

Description

Messages should be cached in process.

As a starting point I would suggest the TTL is 1min. Assuming 1request/second and only 1 instance this gives us a hit rate of around (60/59)=98% and reduces our number of hits to the API by a factor of 60. On the other hand 1 min is an acceptable delay to get new messages.

After talking on IRC with the serviceops people it sound like only having 1 instance is likely but we should be prepared for it to scale up slightly if needed with load. We would expect ca. 1-3 instances (probably 1) and not 10-50.

Notes

Technical notes:

  • can be enabled on a repo/action level (not only globally)
  • TTL can be configured on repo/action level, config coming from environment variable
  • ideally not touching existing repos but added transparently
  • independently of implementation, the cache data source should only maintain a limited number of items - hard coding this to 1000 should be a safe bet
  • do not implement your own cache solution! code for wiring up existing libraries (e.g. https://www.npmjs.com/package/lru-cache) should suffice

Event Timeline

Lea_WMDE set the point value for this task to 5.Mar 13 2019, 3:17 PM
Lea_WMDE subscribed.

The estimation is based on having separate caches per instance (if there even is more than one instance)

Change 507814 had a related patch set uploaded (by Jakob; owner: Jakob):
[wikibase/termbox@master] MessageRepository: make it cacheable

https://gerrit.wikimedia.org/r/507814

Change 507940 had a related patch set uploaded (by Jakob; owner: Jakob):
[wikibase/termbox@master] Provide a more universal way to cache repository data

https://gerrit.wikimedia.org/r/507940

Change 507814 merged by jenkins-bot:
[wikibase/termbox@master] MessageRepository: make it cacheable

https://gerrit.wikimedia.org/r/507814

Change 507940 merged by jenkins-bot:
[wikibase/termbox@master] Provide a more universal way to cache repository data

https://gerrit.wikimedia.org/r/507940