Skip to content

Commit c3814f0

Browse files
feat: add Redis configuration for improved memory management (#3427)
As Sentry continues to evolve, effective resource management becomes crucial for maintaining performance and stability. This update includes configurations that will help optimize Redis's memory usage, ensuring that the system runs efficiently under varying loads. **Key Changes:** - **Added `maxmemory` Directive**: Configured Redis to limit its memory usage to a specified size. This prevents excessive memory consumption and helps maintain system stability. - **Set `maxmemory-policy` to `allkeys-lru`**: This policy allows Redis to evict the least recently used keys when it reaches the memory limit, ensuring that frequently accessed data remains available while older, less-used data is removed.
1 parent be66069 commit c3814f0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ services:
110110
test: redis-cli ping | grep PONG
111111
volumes:
112112
- "sentry-redis:/data"
113+
- type: bind
114+
read_only: true
115+
source: ./redis.conf
116+
target: /usr/local/etc/redis/redis.conf
113117
ulimits:
114118
nofile:
115119
soft: 10032

redis.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# redis.conf
2+
3+
# The 'maxmemory' directive controls the maximum amount of memory Redis is allowed to use.
4+
# Setting 'maxmemory 0' means there is no limit on memory usage, allowing Redis to use as much
5+
# memory as the operating system allows. This is suitable for environments where memory
6+
# constraints are not a concern.
7+
#
8+
# Alternatively, you can specify a limit, such as 'maxmemory 15gb', to restrict Redis to
9+
# using a maximum of 15 gigabytes of memory.
10+
#
11+
# Example:
12+
# maxmemory 0 # Unlimited memory usage
13+
# maxmemory 15gb # Limit memory usage to 15 GB
14+
15+
maxmemory 0
16+
17+
# maxmemory-policy allkeys-lru
18+
#
19+
# This setting determines how Redis evicts keys when it reaches the memory limit.
20+
# 'allkeys-lru' evicts the least recently used keys from all keys stored in Redis,
21+
# allowing frequently accessed data to remain in memory while older data is removed.
22+
#
23+
# Example:
24+
# maxmemory-policy allkeys-lru # Use LRU eviction for all keys
25+
26+
maxmemory-policy allkeys-lru

0 commit comments

Comments
 (0)