Skip to content

Commit

Permalink
feat: add Redis configuration for improved memory management (#3427)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hassanzadeh-sd authored Nov 19, 2024
1 parent be66069 commit c3814f0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ services:
test: redis-cli ping | grep PONG
volumes:
- "sentry-redis:/data"
- type: bind
read_only: true
source: ./redis.conf
target: /usr/local/etc/redis/redis.conf
ulimits:
nofile:
soft: 10032
Expand Down
26 changes: 26 additions & 0 deletions redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# redis.conf

# The 'maxmemory' directive controls the maximum amount of memory Redis is allowed to use.
# Setting 'maxmemory 0' means there is no limit on memory usage, allowing Redis to use as much
# memory as the operating system allows. This is suitable for environments where memory
# constraints are not a concern.
#
# Alternatively, you can specify a limit, such as 'maxmemory 15gb', to restrict Redis to
# using a maximum of 15 gigabytes of memory.
#
# Example:
# maxmemory 0 # Unlimited memory usage
# maxmemory 15gb # Limit memory usage to 15 GB

maxmemory 0

# maxmemory-policy allkeys-lru
#
# This setting determines how Redis evicts keys when it reaches the memory limit.
# 'allkeys-lru' evicts the least recently used keys from all keys stored in Redis,
# allowing frequently accessed data to remain in memory while older data is removed.
#
# Example:
# maxmemory-policy allkeys-lru # Use LRU eviction for all keys

maxmemory-policy allkeys-lru

0 comments on commit c3814f0

Please sign in to comment.