Production & Security
Guidelines for deploying Zettuce safely in production across RDMA fabrics, Kubernetes/Docker containers, and standard TCP networks.
RDMA host & HCA sizing
- Locked memory limit: Each RDMA connection registers pinned Memory Regions (1 MiB RX + TX + command ring ≈ 2.2 MiB per QP). Set
LimitMEMLOCK=infinityin systemd units orulimit -l unlimited. - Bound your pool: Always use a bounded pool (
ValkeyRdmaPool/Pool) withmaxTotalsized to your HCA QP budget and a shortborrowTimeout(e.g., 100–500 ms) to apply clean backpressure during spikes. Pools automatically close and evict connections whose session state changed (SELECT,AUTH,HELLO,CLIENT SETNAME) or that were left inMULTI/WATCHon release; in Java,pool.borrow()returns a single-use lease andpool.async()defaults to a bounded platform-thread pool so native FFM I/O never pins virtual-thread carriers. - Busy-poll vs hybrid spin: Use
lowLatency()(busyPoll=true) only when you have dedicated cores for ultra-low latency (< 10 µs). For dense multi-tenant microservices, keep the default hybrid mode (busyPoll=false, spinMicros=50) so idle connections sleep inepoll_waitat 0% CPU.
TCP io_uring, keepalive & container seccomp
- Automatic
io_uring→epollfallback: On Linux 5.6+, TCP connections automatically initialize a tiny 8-entryio_uringring (zero external library dependency). If Docker or Kubernetes seccomp deniesio_uring_setup(EPERM/ENOSYS), Zettuce falls back transparently to its optimized 3-syscallepollpath with zero configuration changes. - Proactive TCP keepalive: TCP sockets automatically configure
SO_KEEPALIVEwith Linux probesTCP_KEEPIDLE=30s,TCP_KEEPINTVL=10s,TCP_KEEPCNT=3(~60 s dead-peer detection on idle pooled or tracking sockets). - Environment overrides:
ZETTUCE_TCP_NO_IOURING=1— Force theepollTCP path (useful when a very small shared pool migrates connections aggressively across many CPU cores).ZETTUCE_TCP_BUSY_POLL=<us>— Opt-in socketSO_BUSY_POLLwhenbusyPoll=trueon hosts tuned withsysctl net.core.busy_poll.
Reliability, failover, Cluster scaling & ClientCache
- Reconnect replay order: On reconnect, Zettuce automatically replays
AUTH→HELLO 3→SELECT→CLIENT SETNAMEwith exponential backoff and full jitter to prevent thundering herds. Session mutations queued insideMULTIare deferred untilEXECcommits. - Retry policy & transaction guard: Keep the default
SAFE_ONLYpolicy so only read-only idempotent operations (PING,GET,HGET,MGET,ZSCORE, etc., including throughexecute/executeRawand Spring/Micronaut templates) retry mid-flight; writes (SET,INCR,LPUSH,EVAL) are never replayed mid-flight. Always runMULTI/WATCHon a dedicated connection—if it drops insideMULTIor afterWATCH, Zettuce never silently reconnects; every command fails untilEXEC/DISCARDor explicitreconnect(). ReadFrom& live Sentinel failover: UseReadFrom(MASTER,MASTER_PREFERRED,REPLICA_PREFERRED,REPLICA,ANY,LOWEST_LATENCY) acrossValkeyRdmaClusterClient,ValkeyRdmaMasterReplicaPool, andValkeyRdmaSentinelPool.ValkeyRdmaSentinelPoolsubscribes to+switch-masteracross a Sentinel quorum (with periodic polling fallback when ACLs blockSUBSCRIBE), swaps the master pool live, and refreshes automatically onREADONLYerrors.- Cluster scaling: Set
connectionsPerNode(typically 2–8) to avoid single-socket bottlenecks on hot shards, usecluster.batch()/ scatter-gather (mget/mset/del, Rustdel_multi, Pythondelete_multi) for multi-shard fan-out, and enable periodic background topology refresh (topologyRefreshInterval) to absorb slot migrations without waiting forMOVEDredirects. - RESP3 client-side caching invariant:
ZettuceClientCache/ClientCachemaintains a dedicated RESP3CLIENT TRACKING ON BCASTinvalidation socket with periodicPINGheartbeats (detecting silent blackholed peers) and flushes the entire local cache immediately on any tracking disconnect so stale entries are never served after missed invalidations. - Observability: Use built-in
LatencyHistogram(p50/p95/p99/p999, lock-free),CommandListenerSPI,conn.metrics(), andpool.metrics()—or drop inzettuce-observabilityfor Micrometer timers/gauges and OpenTelemetryCLIENTspans (keys and values are never recorded in span attributes).
Security, TLS 1.2/1.3 & framework hardening
- Native TLS 1.2/1.3 & mTLS over TCP: Configure
TlsOptions(OpenSSL dynamically loaded viadlopenin C/Java/Rust/Python, plus JSSE in the pure-Java fallback) withverifyMode = FULL(CA chain + SNI/IP-SAN hostname verification, default),minVersion = TLS_1_2orTLS_1_3, and optional client certificate/key for mTLS. Zettuce explicitly refuses cleartext RDMA when TLS is enabled (AUTOfalls back straight to TLS-over-TCP rather than silently downgrading to cleartext RDMA). - Dynamic credential rotation: Supply a
CredentialsProvider(Java),cred_cb(C), closure (Rust), or callable (Python) to fetch fresh IAM / Vault / Workload-Identity tokens on every connect and reconnect without restarting the process. - RDMA fabric isolation: Valkey-over-RDMA (RoCEv2 / InfiniBand) itself is cleartext at the RDMA layer; run RDMA traffic on an isolated private VLAN/VPC or link-encrypted fabric (MACsec/IPsec). Co-located single-host services can also use Unix domain sockets (
AF_UNIX) with filesystem permissions. - Micronaut cache deserialization safety:
zettuce-micronautenforces a conservative JEP 290ObjectInputFilterby default (allowing primitives, wrappers,String,UUID,java.time.*, and enums; rejecting all other classes with!*and failing fast onput()). Configurezettuce.cache-deserialization-filterwith your explicit DTO packages—never set an unrestricted wildcard on shared caches. - GraalVM 25+ Native Image:
zettuce-javaships verifiedMETA-INF/native-image/.../reachability-metadata.jsonandnative-image.propertiesfor GraalVM 25+ FFM native images (-H:+ForeignAPISupport -H:+SharedArenaSupport).
Verification & quality gates
Zettuce ships with strict continuous verification covering memory safety, operational server errors, parser fuzzing, GraalVM native images, and distributed linearizability:
# 1. Full C, Java (native + fallback + Spring + Micronaut + Observability), Rust, Python, and Jepsen suite
make test
# 2. AddressSanitizer + strict UndefinedBehaviorSanitizer + LeakSanitizer
# (100,000 mutated RESP2/3 fuzz frames + TCP io_uring + epoll + TLS + Cluster + Sentinel + operational errors)
make -C zettuce-c check-asan
# 3. GraalVM 25+ Native Image end-to-end smoke test
bash tests/test_graalvm_native.sh
# 4. Out-of-repo static-linking package verification (Rust .crate + Python sdist & wheel)
bash tests/test_packaging.sh
See PRODUCTION.md in the repository for the complete operations checklist.