Page MenuHomePhabricator

Evaluate need for a "local server stash"
Open, LowPublic

Description

Status quo

See also: https://www.mediawiki.org/wiki/Manual:Caching#Interfaces

Our caching primitives are:

  • local server cache (e.g. typically APCu, which has a set amount of RAM to use). Falls back to no-cache.
  • local cluster cache (e.g. typically Memcached, which uses RAM over the network from one more dedicated hosts). Can fall back to a DB table.
  • main WAN cache (local cluster cache + broadcasted purges for cross-dc).

Our stashing primitives (stash is a store with higher persistence, and little to no LRU):

  • main stash (typically replicated redis). Falls back to db-replicated.
Idea

There seem to be a number of use cases we've seen emerge over the past year for things that are expensive to compute but also fairly large in size. So large that we were uncomfortable storing them in APCu by default for MW core. Doing so might cause typical third-party configurations of APCu to stop being effective due to the limited megabytes being filled up by less commonly needed stuff. The fallback to Memcached isnt' always practical either as that leads to high network saturation which we've seen at the heart of mulitple outages at WMF. Storing in Memcached might be fine to allow re-use between servers but we'd still want something local as well.

That local component for large and higher-persisted stuff coud very well still be APCu at WMF. But from the MW perspective we might want to abstract that.

@aaron has suggested we use an sqlite3 file as the default in core for such "local server stash".

Event Timeline

Change 524657 had a related patch set uploaded (by Krinkle; owner: Aaron Schulz):
[mediawiki/core@master] objectcache: add local sqlite3 file as a getLocalServerObjectCache() fallback

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

Change 570191 had a related patch set uploaded (by Krinkle; owner: Aaron Schulz):
[mediawiki/core@master] rdbms: create a Database class that uses the Sqlite3 extension

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

Lowering priority as there is no present need, but this might change in the future when we're on k8s and/or otherwise flush php-apcu more frequently during deploys. It hasn't yet caused a notable regression in latency so perhaps it's fine, but it's worth keeping in our bag of tricks to pull from.

Change 679117 had a related patch set uploaded (by Krinkle; author: Aaron Schulz):

[mediawiki/core@master] objectcache: add BagOStuff wrapper that uses lmdb

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

Change 524657 abandoned by Aaron Schulz:

[mediawiki/core@master] objectcache: add local sqlite3 file as a getLocalServerObjectCache() fallback

Reason:

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

Change 570191 abandoned by Aaron Schulz:

[mediawiki/core@master] rdbms: create a Database class that uses the Sqlite3 extension

Reason:

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