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
| Variable | Default | Description |
|---|---|---|
FYRODB_PORT | 8000 | TCP listening port (RESP protocol) |
FYRODB_BIND | 0.0.0.0 | Bind address |
FYRODB_WORKERS | 0 (auto) | Worker threads — 0 = number of CPU cores |
FYRODB_SHARDS | 0 (auto) | Hash map shards — 0 = workers × 4, rounded to power of 2 |
FYRODB_MAX_KEYS | 0 (unlimited) | Key ceiling; 0 = no limit. Reads and freeing commands always work. |
FYRODB_MAX_CLIENTS | 10000 | Max concurrent KV connections |
FYRODB_AUTH | (none) | Password for AUTH command — empty = no auth required |
FYRODB_RDB_PATH | fyrodb.rdb | RDB snapshot file path |
FYRODB_RDB_INTERVAL | 300 | Auto-save interval in seconds; 0 disables automatic snapshots |
FYRODB_IO_URING | false | Request batched socket sends at worker startup on Linux builds with the io-uring feature. |
FYRODB_BUSY_POLL_US | 0 (disabled) | Spin-poll window in microseconds before sleeping in epoll — 0 = off |
FYRODB_SOCKET_BUFFER_BYTES | 8388608 | SO_SNDBUF/SO_RCVBUF for client sockets — 0 = kernel autotuning |
FYRODB_MALLOC_PURGE_DELAY_MS | 3000 | Delay before freed allocator memory returns to the OS — 0 = immediately |
FYRODB_MALLOC_ARENA_RESERVE_MB | 0 | Allocator 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_MB | 1024 | Heap 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:latestKV 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 requireAUTH passwordfrom every client before any commands are accepted.FYRODB_SOCKET_BUFFER_BYTES— the 8 MiB default favours deep pipelines. With many mostly-idle connections, set0so 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.
| Variable | Default | Description |
|---|---|---|
FYRODB_PROXY_ENABLED | false | Set true to enable the proxy |
FYRODB_PROXY_PORT | 5433 | PostgreSQL wire protocol listen port (set 5432 to replace Postgres transparently) |
FYRODB_PROXY_BIND | 0.0.0.0 | Proxy bind address |
FYRODB_PROXY_MAX_CONNECTIONS | 4096 | Concurrent 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_POOL | 10 | Max idle authenticated upstream connections kept for reuse |
FYRODB_PROXY_UPSTREAM_IDLE_MS | 60000 | Idle upstream connection lifetime in milliseconds |
FYRODB_PROXY_TRUST_AUTH | false | Skip 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_MS | 60000 | Default cached result TTL in milliseconds |
FYRODB_PROXY_CACHE_MAX_KEYS | 100000 | Maximum number of cached query results |
FYRODB_PROXY_CACHE_TTL_JITTER | 10 | TTL jitter percentage — spreads expiry to avoid thundering herd |
FYRODB_PROXY_KEY_PREFIX | db: | Internal cache key namespace prefix |
FYRODB_PROXY_FLUSH_ON_START | true | Flush all cached results when the proxy starts (false keeps them across restarts) |
FYRODB_PROXY_MODE | dual | dual = 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:latestProxy Sizing Guide
FYRODB_PROXY_MAX_CONNECTIONS— each client connection gets its own thread. The default4096is 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 default10is 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 with30000(30 s) and tune based on your acceptable staleness window.FYRODB_PROXY_CACHE_TTL_JITTER— keeps cache entries from expiring simultaneously. Leave at10unless 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 settruein 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.