MediaWiki REL1_28
docs/memcached.txt File Reference

Typedefs

using $wgMainCacheType = CACHE_MEMCACHED
 

Functions

The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array ("192.168.0.1:11211", 2))
 
storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the port (s) used for memcached servers are not publicly accessible. Otherwise
 
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a server (say, because it has twice the memory of the others and you want to spread usage evenly)
 
The wiki should then use memcached to cache various data To use multiple servers (physically separate boxes or multiple caches on one machine on a large-memory x86 box)
 

Variables

controlled by $wgMainCacheType controlled by $wgParserCacheType * $messageMemc
 
controlled by $wgMainCacheType * $parserMemc
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname
 
 $wgMemCachedServers = array( "127.0.0.1:11211" )
 
storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the anyone on the internet can put data into and read data from your cache An attacker familiar with MediaWiki internals could use this to steal passwords and email addresses
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned below
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be contacted
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Debian
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By default
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your distribution
 
storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately firewalled
 
MediaWiki has optional support for a high distributed memory object caching system For general information on it
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from epoll rt patch for Linux kernel
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still createMemCacheClient
 
MediaWiki has optional support for memcached
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in memory
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from epoll rt patch for Linux is current Memcached and libevent are under BSD style licenses The server should run on Linux and other Unix like systems you can run multiple servers on one machine or on multiple machines on a network
 
MediaWiki has optional support for a high performance
 
MediaWiki has optional support for a high distributed memory object caching system For general information on see
 
storage can be distributed across multiple servers
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from source
 
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a subarray
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control variable
 
storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the anyone on the internet can put data into and read data from your cache An attacker familiar with MediaWiki internals could use this to steal passwords and email or to make themselves a sysop and install malicious javascript on the site There may be other types of vulnerability
 
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned wikidb
 
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like Wikipedia
 

Typedef Documentation

◆ $wgMainCacheType

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for $wgMainCacheType

Definition at line 63 of file memcached.txt.

Function Documentation

◆ array()

The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array ( "192.168.0.1:11211"  ,
 
)

References by, and memcached.

◆ port()

storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the port ( )

◆ server()

The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a server ( say  ,
because it has twice the memory of the others and you want to spread usage  evenly 
)

◆ servers()

The wiki should then use memcached to cache various data To use multiple servers ( physically separate boxes or multiple caches on one machine on a large-memory x86  box)

Variable Documentation

◆ $messageMemc

controlled by $wgMainCacheType controlled by $wgParserCacheType* $messageMemc

Definition at line 86 of file memcached.txt.

◆ $parserMemc

controlled by $wgMainCacheType* $parserMemc

◆ $wgDBname

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname

◆ $wgMemCachedServers

$wgMemCachedServers = array( "127.0.0.1:11211" )

Definition at line 64 of file memcached.txt.

Referenced by McTest::execute().

◆ addresses

storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the anyone on the internet can put data into and read data from your cache An attacker familiar with MediaWiki internals could use this to steal passwords and email addresses

Definition at line 43 of file memcached.txt.

◆ below

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned below

Definition at line 94 of file memcached.txt.

Referenced by Linker::normalizeSubpageLink(), and DifferenceEngine::showDiffPage().

◆ contacted

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be contacted

Definition at line 90 of file memcached.txt.

◆ Debian

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Debian

Definition at line 12 of file memcached.txt.

Referenced by PhpHttpRequest::getCertOptions().

◆ default

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By default

Definition at line 93 of file memcached.txt.

◆ distribution

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your distribution

Definition at line 14 of file memcached.txt.

◆ firewalled

storage can be distributed across multiple and multiple web servers can use the same cache cluster********************* W A R N I N G*********************** Memcached has no security or authentication Please ensure that your server is appropriately firewalled

Definition at line 38 of file memcached.txt.

◆ it

MediaWiki has optional support for a high distributed memory object caching system For general information on it

Definition at line 3 of file memcached.txt.

◆ kernel

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from epoll rt patch for Linux kernel

Definition at line 23 of file memcached.txt.

◆ load

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load

Definition at line 6 of file memcached.txt.

Referenced by SiteStats::activeUsers(), User::addGroup(), User::addToDatabase(), SiteStats::articles(), User::checkAndSetTouched(), User::confirmationToken(), SiteStats::edits(), LoginSignupSpecialPage::execute(), LocalFile::exists(), MediaWiki\Interwiki\ClassicInterwikiLookup::fetch(), MessageCache::getAllMessageKeys(), OldLocalFile::getArchiveName(), LocalFile::getBitDepth(), User::getBlockedStatus(), User::getDBTouched(), LocalFile::getDescription(), User::getEmail(), User::getEmailAuthenticationTimestamp(), User::getFormerGroups(), User::getGroups(), LocalFile::getHeight(), User::getId(), LocalFile::getMediaType(), LocalFile::getMetadata(), LocalFile::getMimeType(), MessageCache::getMsgFromNamespace(), User::getName(), User::getNewtalk(), User::getRealName(), User::getRegistration(), LocalFile::getSha1(), LocalFile::getSize(), LocalFile::getTimestamp(), User::getToken(), User::getTouched(), LocalFile::getUser(), OldLocalFile::getVisibility(), LocalFile::getWidth(), SiteStats::images(), User::invalidateEmail(), LocalFile::isCacheable(), OldLocalFile::isDeleted(), User::isEmailConfirmed(), MessageCache::loadFromDB(), User::loadOptions(), SiteStats::pages(), SiteStats::recache(), User::removeGroup(), MessageCache::replace(), User::resetOptions(), User::saveSettings(), User::setCookies(), User::setEmail(), User::setEmailAuthenticationTimestamp(), User::setName(), User::setNewtalk(), User::setRealName(), User::setToken(), User::spreadBlock(), OldLocalFile::userCan(), and SiteStats::users().

◆ MemCacheClient

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a MemCacheClient

Definition at line 88 of file memcached.txt.

◆ memcached

MediaWiki has optional support for memcached

Definition at line 1 of file memcached.txt.

Referenced by array(), and mccShowUsage().

◆ memory

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in memory
Initial value:
== Installation ==
Packages are available for Fedora
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are

Definition at line 8 of file memcached.txt.

◆ network

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from epoll rt patch for Linux is current Memcached and libevent are under BSD style licenses The server should run on Linux and other Unix like systems you can run multiple servers on one machine or on multiple machines on a network

Definition at line 33 of file memcached.txt.

Referenced by PoolCounterRedis::initAndPopPoolSlotList().

◆ performance

MediaWiki has optional support for a high performance

Definition at line 1 of file memcached.txt.

◆ see

MediaWiki has optional support for a high distributed memory object caching system For general information on see

Definition at line 3 of file memcached.txt.

◆ servers

◆ source

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Ubuntu and probably other Linux distributions If there s no package available for your you can compile it from source
Initial value:
== Compilation ==
* PHP must be compiled with --enable-sockets
* libevent: http:
(as of 2003-08-11, 0.7a is current)
* optionally
Apache License January http
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by etc *css user provided css code *text plain text In PHP
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition globals.txt:10

Definition at line 14 of file memcached.txt.

◆ subarray

The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a subarray

Definition at line 71 of file memcached.txt.

◆ variable

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control variable

Definition at line 87 of file memcached.txt.

◆ vulnerability

storage can be distributed across multiple and multiple web servers can use the same cache cluster *********************W A R N I N G ***********************Memcached has no security or authentication Please ensure that your server is appropriately and that the anyone on the internet can put data into and read data from your cache An attacker familiar with MediaWiki internals could use this to steal passwords and email or to make themselves a sysop and install malicious javascript on the site There may be other types of vulnerability

Definition at line 45 of file memcached.txt.

◆ wikidb

controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned wikidb

Definition at line 139 of file memcached.txt.

◆ Wikipedia

MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like Wikipedia

Definition at line 6 of file memcached.txt.