| Metric / Mechanic | Pure RDB | Pure AOF | Hybrid (RDB + AOF) |
|---|---|---|---|
| Write Operation (Live) | Bypasses disk; goes directly to in-memory keyspace only. | Writes plain-text RESPcommands to an in-memory buffer, then flushes to disk. | Writes plain-text RESPcommands to an in-memory buffer, then flushes to disk. |
| Disk I/O Frequency | Periodic background bursts based on time/change rules (e.g., every 5 mins). | Continuous, controlled background flushes (typically every 1 second). | Continuous plain-text flushes + periodic background heavy compaction bursts. |
| Compaction/Fork Method | Calls fork() system call to create a child process for a full database binary snapshot. |
Calls fork() to run BGREWRITEAOF, optimizing text commands to the shortest history. |
Calls fork() to serialize memory state into a binary RDB preamble, appending live text to the tail. |
| Data Safety / RPO | Low. Maximum data loss up to the last snapshot interval. | High. Maximum data loss is bounded to 1 second of traffic. | High. Maximum data loss is bounded to 1 second of traffic. |
| Startup / Recovery Speed | Fast. Directly parses optimized, raw binary structs into memory. | Slow. Replays every logged historical text statement sequentially via the parsing engine. | Fast. Instantly bulk-loads the binary RDB preamble, then replays the short text tail. |
Select one configuration style inside this ConfigMap to drive the deployment.
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
# STRATEGY 1: PURE RDB (High performance, low storage durability)
# -------------------------------------------------------------
redis.conf: |
dir /data
dbfilename dump.rdb
save 3600 1 300 100 60 10000
appendonly no
# STRATEGY 2: PURE AOF (Safe, text-only logging)
# -----------------------------------------------
# redis.conf: |
# dir /data
# appendonly yes
# appendfilename "appendonly.aof"
# appendfsync everysec
# aof-use-rdb-preamble no
# save ""
# STRATEGY 3: HYBRID MODE (Recommended for Redis 8 - Safe & Fast)
# -------------------------------------------------------------
# redis.conf: |
# dir /data
# appendonly yes
# appendfilename "appendonly.aof"
# appendfsync everysec
# aof-use-rdb-preamble yes
# save 3600 1 300 100 60 10000
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redis-storage-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi # Set this to at least 2.5x your planned maximum in-memory dataset
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-server
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:8.0-alpine
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
ports:
- containerPort: 6379
name: redisport
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
volumeMounts:
- name: config-volume
mountPath: /usr/local/etc/redis
- name: storage-volume
mountPath: /data
resources:
requests:
cpu: "250m"
memory: "1Gi"
limits:
cpu: "1"
# WARNING: Memory limit must be 2x your max data size to absorb
# Copy-on-Write (CoW) memory inflation during background forks.
memory: "2Gi"
volumes:
- name: config-volume
configMap:
name: redis-config
- name: storage-volume
persistentVolumeClaim:
claimName: redis-storage-pvc
A durable KV configuration requires all of these:
- --appendonly
- "yes"
- --appendfsync
- everysec
- --aof-use-rdb-preamble
- "yes"
and, crucially, a PersistentVolume mounted at /data.
appendfsync everysec is Redis’s recommended balance and can lose roughly one second of writes during a severe crash. Redis persistence documentation
Provisioning a PersistentVolume creates an ongoing storage charge.