You are browsing a read-only backup copy of Wikitech. The live site can be found at


From Wikitech-static
Revision as of 17:47, 18 April 2020 by imported>Addshore (→‎WANObjectCache: How to lookup revison from SqlBlobStore-blob wan cache entry)
Jump to navigation Jump to search

Memcached is deployed in several clusters on our infrastructure:

  • MediaWiki Object Cache (mc10XX, mc20XX)
  • Thumbor
  • WMCS
  • Wikitech on Cloud/Labs
  • Swift

This page contains information about the MediaWiki Object cache, running on mc10XX hosts (in eqiad) and mc20XX hosts (in codfw).

MediaWiki libraries/support

The Memcache setup changed in 2015 to be multi-datacenter aware. See also:



WANCache✌️global:SqlBlobStore-blob:<wiki>:<content address>

When you have issues with a key from SqlBlobStore-blob it is possible to figure out which page this key is for, but the process takes a while.

You will want to run these queries on the analytics DB replicas to avoid impacting production.

addshore@stat1007:~$ analytics-mysql enwiki
mysql:research@dbstore1003.eqiad.wmnet [enwiki]> select * from content where content_address = "tt:963546992";
| content_id | content_size | content_sha1                    | content_model | content_address |
|  943285896 |       186750 | 17ti8zx1nn1o0u381j04ctr9nfjwvis |             3 | tt:963546992    |
1 row in set (14 min 34.84 sec)
mysql:research@dbstore1003.eqiad.wmnet [enwiki]> select * from slots where slot_content_id = 943285896;
| slot_revision_id | slot_role_id | slot_content_id | slot_origin |
|        951705319 |            1 |       943285896 |   951705319 |
1 row in set (7 min 26.09 sec)

Then you can navigate to the revision id


Each MediaWiki api/appserver sees memcached through a local proxy called mcrouter. This daemon is configured with all the mc[1,2]0XX hosts as shards, and applies consistent hashing on the key name to know where to store it. The following example should help clarifying how things flow on this layer.

The MediaWiki translate extension stores the key WANCache:v:metawiki:translate-groups in memcached, using the WANObjectCache as library. For example, a GET command to retrieve the key's value is sent from MediaWiki to localhost:11213, where mcrouter is listening, and the command gets routed to mc1022. MediaWiki it totally ignorant about the mc[1,2]0XX host, it only knows about sending commands to a localhost port. A mcrouter admin command helps figure out where the key gets routed:

elukey@mw1345:~$ echo "get __mcrouter__.route(get,WANCache:v:metawiki:translate-groups)" | nc localhost 11213 -q 2
VALUE __mcrouter__.route(get,WANCache:v:metawiki:translate-groups) 0 16

elukey@mw1345:~$ dig -x +short

Some things to notice:

  • The special prefix __mcrouter__.route is interpreted by mcrouter as admin command, that in this case returns the proxy target of the consistent hashing of the key name.
  • mcrouter listen on port 11213 on every MediaWiki hosts, meanwhile on every mc10XX host memcached listens on 11211.

To get a key and dump it to a file it is sufficient to:

elukey@mw1345:~$ echo "get WANCache:v:metawiki:translate-groups" | nc localhost 11213 -q 2 > dump.txt
elukey@mw1345:~$ du -hs dump.txt
380K	dump.txt

In this case the key's value is pretty big, and it needs PHP to be interpreted correctly (to unserialize it), but nonetheless we got some useful information (like the size of the key). This could be useful when it is necessary to quickly get how big a key is, rather than knowing its content.

How Memcached works