# Redis configuration file for potluck server.

################################## INCLUDES ###################################

# This file specifies the port
include potluck-redis-port.conf


################################## NETWORK #####################################

# Listen only on loopback (ipv4 or v6)
bind 127.0.0.1 ::1

# Just in case
protected-mode yes

# Port is specified in redis-port.conf

# TCP listen() backlog.
tcp-backlog 511

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

# TCP keepalive.
tcp-keepalive 300

################################# GENERAL #####################################

# Don't daemonize
daemonize no

# We write a pid file in the current directory
pidfile "potluck-redis.pid"

# Server verbosity level.
loglevel notice

# Log here
logfile "potluck-redis.log"

# Just one database is plenty
databases 1

# We don't care about the logo *that* much (it's cool though)
always-show-logo no

# Modify process title
set-proc-title yes

# Process title to use
proc-title-template "{title} (potluck) {listen-addr} {server-mode}"

################################ SNAPSHOTTING  ################################

# Slightly-more-aggressive-than-default snapshotting
save 1800 1
save 300 10
save 60 1000

# Stop accepting writes if RDB snapshots are enabled
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases.
rdbcompression yes

# Checksum .rdb files
rdbchecksum yes

# Always sanitize on restore
sanitize-dump-payload yes

# The filename where to dump the DB
dbfilename dump.rdb

# No need to delete sync files
rdb-del-sync-files no

# The working directory. This is where the DB and the AOF get written.
dir .

################################# REPLICATION #################################

# We're not using replication, but preserve these settings from the
# default config just in case.
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100

################################## SECURITY ###################################

# We handle user + password setup via an ACL file
aclfile "potluck-redis-user.acl"

# ACL log limit
acllog-max-len 128

############################## MEMORY MANAGEMENT ###############################

# We don't use a memory limit

############################# LAZY FREEING ####################################

# These are defaults
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no

############################ KERNEL OOM CONTROL ##############################

# Defaults
oom-score-adj no
oom-score-adj-values 0 200 800


#################### KERNEL transparent hugepage CONTROL ######################

# Disable transparent huge pages
disable-thp yes

############################## APPEND ONLY MODE ###############################

# We use an AOF in addition to DB snapshots
appendonly yes

# The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"

# Reasonable default for fsyncs (I hope)
# appendfsync always
appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

# Don't load truncated files
aof-load-truncated no

# Use a preamble for the AOF file
aof-use-rdb-preamble yes

################################ LUA SCRIPTING  ###############################

# Max execution time of a Lua script in milliseconds.
lua-time-limit 5000

################################## SLOW LOG ###################################

# Log slow commands
slowlog-log-slower-than 10000

# How many to remember
slowlog-max-len 128

################################ LATENCY MONITOR ##############################

# Not needed (we *really* hope)
latency-monitor-threshold 0

############################# EVENT NOTIFICATION ##############################

# Don't need event notification
notify-keyspace-events ""

############################### ADVANCED CONFIG ###############################

# These are defaults
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes

########################### ACTIVE DEFRAGMENTATION #######################

# Jemalloc background thread for purging will be enabled by default
jemalloc-bg-thread yes
