Browse documentation

FyroDB documentation

Configuration

Environment variables to tune FyroDB's KV engine and DB cache proxy.

All configuration is via environment variables. Every setting has a production-ready default. No config files required.

KV Engine

VariableDefaultDescription
FYRODB_PORT8000TCP listening port (RESP protocol)
FYRODB_BIND0.0.0.0Bind address
FYRODB_WORKERS0 (auto)Worker threads — 0 = number of CPU cores
FYRODB_SHARDS0 (auto)Hash map shards — 0 = workers × 4, rounded to power of 2
FYRODB_MAX_KEYS0 (unlimited)Key ceiling; 0 = no limit. Reads and freeing commands always work.
FYRODB_MAX_CLIENTS10000Max concurrent KV connections
FYRODB_AUTH(none)Password for AUTH command — empty = no auth required
FYRODB_RDB_PATHfyrodb.rdbRDB snapshot file path
FYRODB_RDB_INTERVAL300Auto-save interval in seconds; 0 disables automatic snapshots
FYRODB_IO_URINGfalseRequest batched socket sends at worker startup on Linux builds with the io-uring feature.
FYRODB_BUSY_POLL_US0 (disabled)Spin-poll window in microseconds before sleeping in epoll — 0 = off
FYRODB_SOCKET_BUFFER_BYTES8388608SO_SNDBUF/SO_RCVBUF for client sockets — 0 = kernel autotuning
FYRODB_MALLOC_PURGE_DELAY_MS3000Delay before freed allocator memory returns to the OS — 0 = immediately
FYRODB_MALLOC_ARENA_RESERVE_MB0Allocator arena reservation from startup. 0 maps each heap page separately (lowest peak RSS) until the heap reaches FYRODB_MALLOC_ARENA_SWITCH_MB, then switches to arenas automatically so large heaps stay far below the kernel's vm.max_map_count
FYRODB_MALLOC_ARENA_SWITCH_MB1024Heap size at which the allocator switches to arenas (see above). No tuning needed; raise vm.max_map_count only if you set this above ~3000

KV Engine Examples

# Default (unlimited keys, auto workers)
docker run -p 8000:8000 rana718/fyrodb:latest
 
# High-capacity with auth
docker run -p 6379:6379 \
  -e FYRODB_PORT=6379 \
  -e FYRODB_MAX_KEYS=10000000 \
  -e FYRODB_AUTH=strongpassword \
  rana718/fyrodb:latest
 
# Persistent data, save every 60s
docker run -p 8000:8000 \
  -e FYRODB_RDB_INTERVAL=60 \
  -e FYRODB_RDB_PATH=/data/fyrodb.rdb \
  -v fyrodb-data:/data \
  rana718/fyrodb:latest

KV Sizing Guide

  • FYRODB_WORKERS — defaults to CPU core count. Reduce to leave cores for other processes.
  • FYRODB_SHARDS — more shards = less lock contention between threads. Default (workers × 4) is optimal for most workloads.
  • FYRODB_MAX_KEYS — set to control memory use. When the limit is reached, writes that grow the keyspace return -OOM; reads, DEL, and expiry always work.
  • FYRODB_AUTH — set to require AUTH password from every client before any commands are accepted.
  • FYRODB_SOCKET_BUFFER_BYTES — the 8 MiB default favours deep pipelines. With many mostly-idle connections, set 0 so the kernel autotunes each socket's buffers and bounds kernel memory per connection.
  • FYRODB_BUSY_POLL_US — set to 50–200 on latency-sensitive workloads. Keeps the event loop spinning for a window instead of sleeping in epoll, trading CPU for lower tail latency.

DB Cache Proxy

The proxy engine speaks the full PostgreSQL wire protocol and caches SELECT results in memory. Enable it alongside the KV engine.

VariableDefaultDescription
FYRODB_PROXY_ENABLEDfalseSet true to enable the proxy
FYRODB_PROXY_PORT5433PostgreSQL wire protocol listen port (set 5432 to replace Postgres transparently)
FYRODB_PROXY_BIND0.0.0.0Proxy bind address
FYRODB_PROXY_MAX_CONNECTIONS4096Concurrent client connections (one thread each); 0 = unlimited
FYRODB_PROXY_UPSTREAM_URL(none)postgres://user:pass@host:5432/dbname — omit for cache-only mode
FYRODB_PROXY_UPSTREAM_POOL10Max idle authenticated upstream connections kept for reuse
FYRODB_PROXY_UPSTREAM_IDLE_MS60000Idle upstream connection lifetime in milliseconds
FYRODB_PROXY_TRUST_AUTHfalseSkip client password verification — safe on internal/container networks
FYRODB_PROXY_USERS(none)Per-user passwords: alice:secret,bob:pass — checked when TRUST_AUTH is false
FYRODB_PROXY_CACHE_TTL_MS60000Default cached result TTL in milliseconds
FYRODB_PROXY_CACHE_MAX_KEYS100000Maximum number of cached query results
FYRODB_PROXY_CACHE_TTL_JITTER10TTL jitter percentage — spreads expiry to avoid thundering herd
FYRODB_PROXY_KEY_PREFIXdb:Internal cache key namespace prefix
FYRODB_PROXY_FLUSH_ON_STARTtrueFlush all cached results when the proxy starts (false keeps them across restarts)
FYRODB_PROXY_MODEdualdual = cache + upstream fallback on miss; cache-only = miss returns an error

Proxy Examples

# Proxy in front of an existing Postgres database
docker run -p 8000:8000 -p 5432:5432 \
  -e FYRODB_PROXY_ENABLED=true \
  -e FYRODB_PROXY_PORT=5432 \
  -e FYRODB_PROXY_UPSTREAM_URL=postgres://app:pass@db-host:5432/mydb \
  -e FYRODB_PROXY_TRUST_AUTH=true \
  rana718/fyrodb:latest
 
# Cache-only mode (no upstream, app pre-warms cache via API)
docker run -p 8000:8000 -p 5432:5432 \
  -e FYRODB_PROXY_ENABLED=true \
  -e FYRODB_PROXY_PORT=5432 \
  -e FYRODB_PROXY_MODE=cache-only \
  -e FYRODB_PROXY_TRUST_AUTH=true \
  rana718/fyrodb:latest
 
# Locked-down proxy with per-user auth
docker run -p 8000:8000 -p 5432:5432 \
  -e FYRODB_PROXY_ENABLED=true \
  -e FYRODB_PROXY_PORT=5432 \
  -e FYRODB_PROXY_UPSTREAM_URL=postgres://admin:secret@db:5432/prod \
  -e FYRODB_PROXY_USERS=alice:pw1,bob:pw2 \
  -e FYRODB_PROXY_CACHE_TTL_MS=30000 \
  rana718/fyrodb:latest

Proxy Sizing Guide

  • FYRODB_PROXY_MAX_CONNECTIONS — each client connection gets its own thread. The default 4096 is far above typical application pool sizes; lower it to bound memory on small hosts.
  • FYRODB_PROXY_UPSTREAM_POOL — cache hits never touch the upstream pool. Only misses and new connections use it. The default 10 is enough for most workloads; increase only if you see upstream connection wait times.
  • FYRODB_PROXY_CACHE_TTL_MS — shorter TTL = fresher data but higher miss rate. Start with 30000 (30 s) and tune based on your acceptable staleness window.
  • FYRODB_PROXY_CACHE_TTL_JITTER — keeps cache entries from expiring simultaneously. Leave at 10 unless you have a specific reason.
  • FYRODB_PROXY_MODE=cache-only — use when your application pre-populates the cache at startup. Misses return an explicit error instead of falling back to the database, giving predictable latency at the cost of needing warm-up.
  • FYRODB_PROXY_TRUST_AUTH — always set true in container networks where network-level isolation is already in place. Eliminates SCRAM round-trips on connection startup.

Memory Estimate

KV engine RSS ≈ 4 MB idle + (live keys × entry size) + payload data
Proxy cache  ≈ cached result bytes + ~200 B overhead per cached entry

Monitor with redis-cli -p 8000 INFO for the KV engine. For the proxy cache, FYRODB_PROXY_CACHE_MAX_KEYS is the primary control knob.