This page is under construction, please be patient :)
Memcached is deployed in several clusters on our infrastructure:
- MediaWiki Object Cache (mc10XX, mc20XX)
- Wikitech on Cloud/Labs
This page contains information about the MediaWiki Object cache, running on mc10XX hosts (in eqiad) and mc20XX hosts (in codfw).
The Memcache setup changed in 2015 to be multi-datacenter aware. See also:
nutcracker (memcached proxy on all application servers)(deprecated as of March 2019)
- Mcrouter (memcached proxy on all application servers)
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 10.64.0.83:11211 END elukey@mw1345:~$ dig -x 10.64.0.83 +short mc1022.eqiad.wmnet.
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