docs/main/administration-guide/scale/redis.mdx
Redis is an open-source, in-memory data structure store used as a database, cache, message broker, and streaming engine. Mattermost uses Redis as an external cache to improve performance at scale. When properly configured, Redis can help support Mattermost installations with more than 100,000 users by providing improved performance through efficient caching.
Deploying Redis with Mattermost includes the following 2 steps: setting up the Redis server, and configuring Redis in Mattermost.
Follow these steps to configure Mattermost to use your Redis server:
redis to enable the Redis-specific settings.
- Enter Redis Address for the Redis server you set up earlier (e.g.,
redis.example.com:6379).- (Optional) Enter Redis Password if your Redis server requires authentication.
- (Optional) Enter Redis Database to specify which Redis database to use (-1 by default, which uses Redis's default database).
Alternatively, you can configure Redis in the config.json file:
"CacheSettings": {
"CacheType": "redis",
"RedisAddress": "redis.example.com:6379",
"RedisPassword": "",
"RedisCachePrefix": "",
"RedisDB": -1,
"DisableClientCache": false
}
For enterprise-scale deployments, AWS ElastiCache for Redis provides a fully managed Redis service that simplifies deployment, operation, and scaling.
When deploying Mattermost with AWS ElastiCache:
cache.m7g.2xlarge instance for deployments supporting over 100,000 users.When using Redis with Mattermost, consider the following performance insights:
Mattermost uses the rueidis library instead of the more popular go-redis, primarily because rueidis offers more performance optimizations out of the box, including:
The primary implementation files include:
platform/services/cache/provider.go - Contains the library initialization codeplatform/services/cache/redis.go - Contains the cache interface implementationWhile Redis is not required for smaller Mattermost deployments, it is highly recommended for large-scale installations. - If your installation has more than 100K users, Redis is highly recommended. Redis significantly improves performance by reducing database load and optimizing common operations. - If your installation has less than 100K users, Redis is not recommended.
It is suggested to keep an eye on the sum(rate(mattermost_cache_mem_invalidation_total[5m])) metric which indicates the rate of cache invalidations happening. A single cache invalidation will send a message across your HA cluster to all nodes, leading to database calls from all of them. So the metric, combined with the number of nodes in your cluster should be used to determine when is the right time to use Redis.
For example, if you have more than 10 nodes in your cluster, and the rate of invalidations goes beyond 10, then you should definitely start considering adding Redis.
For production deployments, we recommend running Redis on a separate machine from the Mattermost server. This separation allows for better resource allocation and improved system reliability.
When running Redis with Mattermost, monitor the following metrics:
mattermost_db_cache_time Grafana metric with labels of cache_name and operation, which can be used to further monitor the performance of Redis