mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 18:43:23 +01:00
fix(docker): snapshot the internal valkey hourly instead of every few minutes
The keyspace holds the Switch TitleDB and LaunchBox caches, so dump.rdb runs to hundreds of MB (424MB on a dev instance). Valkey's stock save policy rewrites all of it every ~5 minutes once 100 keys change, which idle RQ bookkeeping alone triggers, for gigabytes of disk writes per hour. Fixes #3980 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,11 @@ ENABLE_SYNC_FOLDER_WATCHER="${ENABLE_SYNC_FOLDER_WATCHER:="false"}"
|
||||
# if REDIS_HOST is set, we assume that an external redis is used
|
||||
REDIS_HOST="${REDIS_HOST:=""}"
|
||||
|
||||
# snapshot policy of the internal valkey, as "<seconds> <changes>" pairs. Saving
|
||||
# hourly keeps a graceful shutdown lossless while a hard crash can only lose an
|
||||
# hour of sessions and cached metadata. Set to an empty value to never snapshot.
|
||||
REDIS_SAVE_POLICY="${REDIS_SAVE_POLICY:="3600 1"}"
|
||||
|
||||
# logger colors
|
||||
RED='\033[0;31m'
|
||||
LIGHTMAGENTA='\033[0;95m'
|
||||
@@ -164,6 +169,16 @@ start_bin_nginx() {
|
||||
start_bin_valkey-server() {
|
||||
info_log "Starting internal valkey"
|
||||
|
||||
# Most of the keyspace is bulky, rebuildable metadata (Switch TitleDB,
|
||||
# LaunchBox), so every snapshot rewrites hundreds of MB of dump.rdb. Valkey's
|
||||
# stock policy does that every few minutes even on an idle instance, which
|
||||
# adds up to gigabytes of disk writes per hour.
|
||||
local -a save_flags=(--save "")
|
||||
if [[ -n ${REDIS_SAVE_POLICY} ]]; then
|
||||
# shellcheck disable=SC2206 # each "<seconds> <changes>" token is its own argument
|
||||
save_flags=(--save ${REDIS_SAVE_POLICY})
|
||||
fi
|
||||
|
||||
if [[ -f /usr/local/etc/valkey/valkey.conf ]]; then
|
||||
if [[ ${LOGLEVEL} == "DEBUG" ]]; then
|
||||
valkey-server /usr/local/etc/valkey/valkey.conf &
|
||||
@@ -172,9 +187,9 @@ start_bin_valkey-server() {
|
||||
fi
|
||||
else
|
||||
if [[ ${LOGLEVEL} == "DEBUG" ]]; then
|
||||
valkey-server --dir /redis-data &
|
||||
valkey-server --dir /redis-data "${save_flags[@]}" &
|
||||
else
|
||||
valkey-server --dir /redis-data >/dev/null 2>&1 &
|
||||
valkey-server --dir /redis-data "${save_flags[@]}" >/dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -1537,14 +1537,15 @@ Falls back to `FakeRedis` in test mode.
|
||||
|
||||
#### Redis
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ---------------- | ----------- | --------------------- |
|
||||
| `REDIS_HOST` | `127.0.0.1` | Redis host |
|
||||
| `REDIS_PORT` | `6379` | Redis port |
|
||||
| `REDIS_USERNAME` | | Redis username (ACL) |
|
||||
| `REDIS_PASSWORD` | | Redis password |
|
||||
| `REDIS_DB` | `0` | Redis database number |
|
||||
| `REDIS_SSL` | `false` | Enable SSL |
|
||||
| Variable | Default | Description |
|
||||
| ------------------- | ----------- | --------------------------------------------------------------------------- |
|
||||
| `REDIS_HOST` | `127.0.0.1` | Redis host |
|
||||
| `REDIS_PORT` | `6379` | Redis port |
|
||||
| `REDIS_USERNAME` | | Redis username (ACL) |
|
||||
| `REDIS_PASSWORD` | | Redis password |
|
||||
| `REDIS_DB` | `0` | Redis database number |
|
||||
| `REDIS_SSL` | `false` | Enable SSL |
|
||||
| `REDIS_SAVE_POLICY` | `3600 1` | Internal Valkey snapshot policy, `"<seconds> <changes>"` pairs (empty: off) |
|
||||
|
||||
#### Authentication
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ REDIS_USERNAME= # Username for the Redis/Valkey instance
|
||||
REDIS_PASSWORD= # Password for the Redis/Valkey instance
|
||||
REDIS_DB=0 # Database number for the Redis/Valkey instance
|
||||
REDIS_SSL=false # Enable SSL (rediss://) for the Redis/Valkey connection
|
||||
REDIS_SAVE_POLICY=3600 1 # Snapshot policy of the internal Valkey, as "<seconds> <changes>" pairs (empty to never snapshot)
|
||||
|
||||
# Authentication
|
||||
ROMM_AUTH_SECRET_KEY= # App secret, generate with `openssl rand -hex 32` [REQUIRED]
|
||||
|
||||
Reference in New Issue
Block a user