MediaWiki REL1_32
Wikimedia\Rdbms\LoadMonitor Class Reference

Basic DB load monitor with no external dependencies Uses memcached to cache the replication lag for a short time. More...

Inheritance diagram for Wikimedia\Rdbms\LoadMonitor:
Collaboration diagram for Wikimedia\Rdbms\LoadMonitor:

Public Member Functions

 __construct (ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache, array $options=[])
 
 getLagTimes (array $serverIndexes, $domain)
 Get an estimate of replication lag (in seconds) for each server.
 
 scaleLoads (array &$weightByServer, $domain)
 Perform load ratio adjustment before deciding which server to use.
 
 setLogger (LoggerInterface $logger)
 

Protected Member Functions

 getServerStates (array $serverIndexes, $domain)
 
 getWeightScale ( $index, IDatabase $conn=null)
 

Protected Attributes

ILoadBalancer $parent
 
LoggerInterface $replLogger
 
BagOStuff $srvCache
 
WANObjectCache $wanCache
 

Private Member Functions

 getCacheKey (array $serverIndexes)
 

Private Attributes

int $lagWarnThreshold
 Amount of replication lag in seconds before warnings are logged.
 
float $movingAveRatio
 Moving average ratio (e.g.
 

Detailed Description

Basic DB load monitor with no external dependencies Uses memcached to cache the replication lag for a short time.

Definition at line 36 of file LoadMonitor.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\LoadMonitor::__construct ( ILoadBalancer  $lb,
BagOStuff  $srvCache,
WANObjectCache  $wCache,
array  $options = [] 
)
Parameters
ILoadBalancer$lb
BagOStuff$srvCache
WANObjectCache$wCache
array$options
  • movingAveRatio: moving average constant for server weight updates based on lag
  • lagWarnThreshold: how many seconds of lag trigger warnings

Implements Wikimedia\Rdbms\ILoadMonitor.

Reimplemented in Wikimedia\Rdbms\LoadMonitorMySQL.

Definition at line 64 of file LoadMonitor.php.

References $options, and Wikimedia\Rdbms\LoadMonitor\$srvCache.

Member Function Documentation

◆ getCacheKey()

Wikimedia\Rdbms\LoadMonitor::getCacheKey ( array  $serverIndexes)
private

Definition at line 236 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ getLagTimes()

Wikimedia\Rdbms\LoadMonitor::getLagTimes ( array  $serverIndexes,
  $domain 
)
final

Get an estimate of replication lag (in seconds) for each server.

Values may be "false" if replication is too broken to estimate

Parameters
int[]$serverIndexes
string$domain
Returns
array Map of (server index => float|int|bool)

Implements Wikimedia\Rdbms\ILoadMonitor.

Definition at line 94 of file LoadMonitor.php.

References Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ getServerStates()

◆ getWeightScale()

Wikimedia\Rdbms\LoadMonitor::getWeightScale (   $index,
IDatabase  $conn = null 
)
protected
Parameters
int$indexServer index
IDatabase | null$connConnection handle or null on connection failure
Returns
float

Reimplemented in Wikimedia\Rdbms\LoadMonitorMySQL.

Definition at line 232 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ scaleLoads()

Wikimedia\Rdbms\LoadMonitor::scaleLoads ( array $weightByServer,
  $domain 
)
final

Perform load ratio adjustment before deciding which server to use.

Parameters
int[]&$weightByServerMap of (server index => float weight)
string | bool$domain

Implements Wikimedia\Rdbms\ILoadMonitor.

Definition at line 80 of file LoadMonitor.php.

References as, and Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ setLogger()

Wikimedia\Rdbms\LoadMonitor::setLogger ( LoggerInterface  $logger)

Definition at line 76 of file LoadMonitor.php.

Member Data Documentation

◆ $lagWarnThreshold

int Wikimedia\Rdbms\LoadMonitor::$lagWarnThreshold
private

Amount of replication lag in seconds before warnings are logged.

Definition at line 49 of file LoadMonitor.php.

◆ $movingAveRatio

float Wikimedia\Rdbms\LoadMonitor::$movingAveRatio
private

Moving average ratio (e.g.

0.1 for 10% weight to new weight)

Definition at line 47 of file LoadMonitor.php.

Referenced by Wikimedia\Rdbms\LoadMonitor\getServerStates().

◆ $parent

ILoadBalancer Wikimedia\Rdbms\LoadMonitor::$parent
protected

Definition at line 38 of file LoadMonitor.php.

◆ $replLogger

LoggerInterface Wikimedia\Rdbms\LoadMonitor::$replLogger
protected

Definition at line 44 of file LoadMonitor.php.

◆ $srvCache

◆ $wanCache

WANObjectCache Wikimedia\Rdbms\LoadMonitor::$wanCache
protected

Definition at line 42 of file LoadMonitor.php.


The documentation for this class was generated from the following file: