You are browsing a read-only backup copy of Wikitech. The primary site can be found at wikitech.wikimedia.org

Redis: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Harej
(Labs -> Cloud VPS)
imported>Giuseppe Lavagetto
(Added a few more known uses.)
Line 2: Line 2:
{{See|For the Redis service at Toolforge, see  [[Nova Resource:Tools/Redis]].}}
{{See|For the Redis service at Toolforge, see  [[Nova Resource:Tools/Redis]].}}
'''Redis''' is used in Wikimedia production for:
'''Redis''' is used in Wikimedia production for:
* the MediaWiki [[job queue]]
* changeprop (role::redis::misc)
* stashing user sessions ([[mw:Manual:$wgSessionCacheType|$wgSessionCacheType]])
* stashing user sessions ([[mw:Manual:$wgSessionCacheType|$wgSessionCacheType]]) and the data stored in the main stash ([[mw:Manual:$wgMainStash|$wgMainStash]]).
* log messages processed by [[Logstash]]
*[[Maps]]
*As a cache and queue backend in [[ORES]]
*Receiver of sampled profile data from Xenon, as part as the sampling/profiling pipeline.


Check puppet and {{config file|ProductionServices.php}} for <code>jobqueue_aggregator</code> to see where it runs (as of August 2016 the servers are rdb1001, rdb1003, rdb1005 and rdb1007).
[[mw:MediaWiki-Vagrant|MediaWiki-Vagrant]] and [[Help:MediaWiki-Vagrant in Labs|MediaWiki-Vagrant in Cloud VPS]] are configured by default to use redis for [[mw:Manual:$wgMainCacheType|$wgMainCacheType]], [[mw:Manual:$wgSessionCacheType|$wgSessionCacheType]], etc.
 
== Role redis::misc (Redis 3.x) ==
 
The role <code>redis::misc</code> is for our general purpose master-slave cluster in eqiad and codfw DCs. Each <code>rdb*</code> node has 5 instances (ports 6378, 6379, 6380, 6381, 6382) because redis is sigle threaded.


[[mw:MediaWiki-Vagrant|MediaWiki-Vagrant]] and [[Help:MediaWiki-Vagrant in Labs|MediaWiki-Vagrant in Cloud VPS]] are configured by default to use redis for [[mw:Manual:$wgMainCacheType|$wgMainCacheType]], [[mw:Manual:$wgSessionCacheType|$wgSessionCacheType]], etc.
=== Servers ===
Each master has its respected slave. Masters use odd numbers (e.g. rdb1005) and slaves an even one (e.g. rdb1006). Master-slave instances use the same ports e.g. <code>rdb1005:6379</code> is the master of <code>rdb1006:6379</code>
 
'''eqiad:'''
*rdb1005 (m) - rdb1005 (s)
*rdb1009 (m) - rdb1010 (s)
'''codfw:'''
*rdb2003 (m) - rdb2004 (s)
*rdb2005 (m) - rdb2006 (s)
 
=== Services ===
 
'''Change propagation''' (or '''changeprop''') is a service running on <code>scb*</code> servers listening to topics on Kafka for events, and translates them into http requests to various systems. It is also responsible for cache evictions to happen on all services like [[RESTBase]]. Changeprop talks to redis via [[Nutcracker]].
* <code>hieradata/role/eqiad/scb.yaml</code>
* <code>hieradata/role/codfw/scb.yaml</code>
*[https://logstash.wikimedia.org/app/kibana#/dashboard/change-prop?_g=h@44136fa&_a=h@8c02121 Kibana changeprop Dashboard]
 
=== Related puppet code ===
 
* <code>hieradata/role/common/redis/misc/master.yaml</code>
* <code>hieradata/role/common/redis/misc/slave.yaml</code>
* <code>modules/role/manifests/redis/misc/master.pp</code>
* <code>modules/role/manifests/redis/misc/slave.pp</code>
 
=== Other Info ===
 
* Instance passwords can be easily found under <code>/etc/redis/<instance>.conf</code>
* [https://grafana.wikimedia.org/d/000000174/redis?orgId=1 Grafana redis::misc Dashboard]


== Usage ==
== Using Redis ==


===Connecting===
===Connecting===
Line 28: Line 61:


<code>quit</code> closes the connection.
<code>quit</code> closes the connection.


==Other references==
==Other references==

Revision as of 12:49, 10 January 2019

Redis is used in Wikimedia production for:

  • changeprop (role::redis::misc)
  • stashing user sessions ($wgSessionCacheType) and the data stored in the main stash ($wgMainStash).
  • Maps
  • As a cache and queue backend in ORES
  • Receiver of sampled profile data from Xenon, as part as the sampling/profiling pipeline.

MediaWiki-Vagrant and MediaWiki-Vagrant in Cloud VPS are configured by default to use redis for $wgMainCacheType, $wgSessionCacheType, etc.

Role redis::misc (Redis 3.x)

The role redis::misc is for our general purpose master-slave cluster in eqiad and codfw DCs. Each rdb* node has 5 instances (ports 6378, 6379, 6380, 6381, 6382) because redis is sigle threaded.

Servers

Each master has its respected slave. Masters use odd numbers (e.g. rdb1005) and slaves an even one (e.g. rdb1006). Master-slave instances use the same ports e.g. rdb1005:6379 is the master of rdb1006:6379

eqiad:

  • rdb1005 (m) - rdb1005 (s)
  • rdb1009 (m) - rdb1010 (s)

codfw:

  • rdb2003 (m) - rdb2004 (s)
  • rdb2005 (m) - rdb2006 (s)

Services

Change propagation (or changeprop) is a service running on scb* servers listening to topics on Kafka for events, and translates them into http requests to various systems. It is also responsible for cache evictions to happen on all services like RESTBase. Changeprop talks to redis via Nutcracker.

Related puppet code

  • hieradata/role/common/redis/misc/master.yaml
  • hieradata/role/common/redis/misc/slave.yaml
  • modules/role/manifests/redis/misc/master.pp
  • modules/role/manifests/redis/misc/slave.pp

Other Info

Using Redis

Connecting

You can use the redis-cli utility to make queries against Redis. In order to make queries against Redis, you need to be on a production server such as tin that can access the servers and has redis-cli installed, and give the command.

redis-cli -a password-here -h rdb1001

(Grab the password out of /srv/mediawiki/private/PrivateSettings.php on tin, the server where it runs, look for $wmgRedisPassword in it.)

This will leave you at a redis prompt where you can enter commands interactively.

Some useful commands

info will give you a pile of status information about the server, including the number of keys near the end of the output.

keys pattern-here will give you a list of all keys matching the given pattern. Use this sparingly, there's a lot of keys in there and the query will take (at least) several seconds to complete.

quit closes the connection.


Other references

Commands are easy, they all depend on the data type (hash, set, list, etc). Here's a quick reference.

Configuration is likewise pretty straightforward with perhaps the exception of the snapshotting, aof and memory settings; here's the sample config file.

See also

  • memcached
  • nutcracker (AKA twemproxy), the proxy used by all application servers to contact memcached (but not redis as of 2015, except it does again as of 2016)