didi-lot2-backend/backend/services/data-layer/didiCache/redis.conf
2026-07-10 03:39:53 -07:00

183 lines
No EOL
4.6 KiB
Text

# ============================================================================
# DIDI Cache Service Configuration (Redis 7)
# Production-ready configuration for the DIDI Backend platform
# ============================================================================
# ============================================================================
# NETWORK & SECURITY
# ============================================================================
# Listen on all interfaces (Docker container)
bind 0.0.0.0
# Enable protected mode
protected-mode yes
# Port
port 6379
# TCP listen() backlog
tcp-backlog 511
# TCP keepalive
tcp-keepalive 300
# Timeout for idle clients (0 to disable)
timeout 0
# ============================================================================
# GENERAL
# ============================================================================
# Don't run as daemon (Docker handles this)
daemonize no
# Server verbosity (debug, verbose, notice, warning)
loglevel notice
# Log to stdout for Docker
logfile ""
# Number of databases (we use 0 for main cache)
databases 16
# ============================================================================
# MEMORY MANAGEMENT
# ============================================================================
# Maximum memory (adjust based on container limits)
maxmemory 512mb
# Eviction policy when max memory is reached
# allkeys-lru: Remove least recently used keys
maxmemory-policy allkeys-lru
# LRU samples for eviction
maxmemory-samples 5
# ============================================================================
# PERSISTENCE - RDB (Snapshots)
# ============================================================================
# Save snapshots:
# After 900 sec (15 min) if at least 1 key changed
save 900 1
# After 300 sec (5 min) if at least 10 keys changed
save 300 10
# After 60 sec if at least 10000 keys changed
save 60 10000
# Error handling for background save
stop-writes-on-bgsave-error yes
# Compress RDB dumps
rdbcompression yes
# Checksum RDB files
rdbchecksum yes
# Filename for RDB
dbfilename dump.rdb
# Directory for RDB and AOF files
dir /data
# ============================================================================
# PERSISTENCE - AOF (Append Only File)
# ============================================================================
# Enable AOF
appendonly yes
# AOF filename
appendfilename "appendonly.aof"
# AOF sync policy (everysec = good balance)
appendfsync everysec
# Don't fsync during rewrites
no-appendfsync-on-rewrite no
# Auto rewrite AOF
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
# Load truncated AOF
aof-load-truncated yes
# Use RDB format in AOF for faster loading
aof-use-rdb-preamble yes
# ============================================================================
# SLOW LOG
# ============================================================================
# Log queries slower than (microseconds)
slowlog-log-slower-than 10000
# Maximum length of slow log
slowlog-max-len 128
# ============================================================================
# LATENCY MONITORING
# ============================================================================
# Latency threshold in milliseconds
latency-monitor-threshold 100
# ============================================================================
# CLIENT HANDLING
# ============================================================================
# Maximum number of clients
maxclients 10000
# ============================================================================
# ADVANCED CONFIG
# ============================================================================
# Hash tables
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
# Lists
list-max-ziplist-size -2
list-compress-depth 0
# Sets
set-max-intset-entries 512
# Sorted sets
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
# HyperLogLog
hll-sparse-max-bytes 3000
# Streams
stream-node-max-bytes 4096
stream-node-max-entries 100
# Active rehashing
activerehashing yes
# Client output buffer limits
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
# Frequency of rehashing the main dictionary
hz 10
# LFU settings
lfu-log-factor 10
lfu-decay-time 1
# ============================================================================
# DISABLE DANGEROUS COMMANDS (Production)
# ============================================================================
# Uncomment these in production to disable dangerous commands
# rename-command FLUSHDB ""
# rename-command FLUSHALL ""
# rename-command CONFIG ""