LoomConfig provides centralized, immutable configuration for a LoomCache node. All settings ship with sensible defaults, allowing quick cluster startup with minimal overhead. The builder enforces validation rules at construction time to catch errors early.
Configuration Sources 45+ properties across 12 groups. Three ways to configure.
Builder APIapplication.yml Environment LoomConfig.builder()
.nodeId("node-1")
.port(5701)
.raftElectionTimeoutMs(3000)
.enablePersistence(true)
.build();
Categories Identity 3
Raft 8
Network 10
Persistence 4
Security 11
Observability 7
Property Type Default Description nodeIdString (required) Unique identifier for this node. Must not be blank. bindAddressString 0.0.0.0Network interface to bind. Use 127.0.0.1 for localhost only. portint 5701TCP port for node-to-node and client communication. Range: 1–65535.
Property Type Default Description clusterMembersList<String> (empty) Bootstrap peer addresses in host:port format.
Property Type Default Description raftElectionTimeoutMinMslong 300Minimum election timeout (ms). Followers wait this duration before starting election. ≥100ms. raftElectionTimeoutMaxMslong 600Maximum election timeout (ms). Randomized between min/max to prevent split votes. raftHeartbeatIntervalMslong 100Leader heartbeat interval (ms). Must be much less than election timeout. Min 10ms. raftPreVoteEnabledboolean truePre-vote phase prevents disruption from partitioned nodes with stale terms. maxEntriesPerAppendint 100Max log entries per AppendEntries RPC. replicationIntervalMslong 50Interval between replication checks per follower. replicationTimeoutMslong 5000Timeout for follower replication acknowledgments. logCompactionThresholdint 10000Entries before triggering log compaction. Higher = less I/O, more memory.
Liveness: Heartbeat interval < min election timeout ensures followers recognize live leader
Safety: Randomized timeouts prevent simultaneous elections
Default tuning: 100ms heartbeats with 300–600ms election timeout balances responsiveness with stability
Recommended: heartbeat 100ms, election 300ms (3x ratio)
Aggressive: heartbeat 50ms, election 100ms (2x ratio, lower latency)
Conservative: heartbeat 500ms, election 2000ms (4x ratio, lower churn)
Property Type Default Description phiAccrualThresholddouble 8.0Suspicion threshold. Higher = fewer false positives. Range: 7.0–10.0. enableAdaptiveThresholdboolean trueAuto-adjust threshold based on observed latency variance. discoveryRetryBackoffMslong 100Initial backoff for DNS/discovery retries. Exponential up to 500ms. discoveryMaxRetriesint 3Max retry attempts before falling back to cached addresses. discoveryTtlAwareCachingboolean trueRetain discovered addresses on transient DNS failures. discoveryHealthCheckEnabledboolean trueTCP connectivity checks on cached discovery addresses. discoveryHealthCheckIntervalMslong 30000Interval between health checks on cached addresses.
Environment tuning:
LAN: phi 8.0, adaptive disabled
WAN/cloud: phi 8.5–9.0, adaptive enabled
High churn: max retries 5, TTL-aware caching on
Property Type Default Description maxConnectionsint 10000Maximum concurrent TCP connections. tcpReadTimeoutMslong 30000Socket read timeout (ms). tcpIdleTimeoutMslong 300000Idle connection timeout (5 min default). gracefulShutdownDrainMslong 200Drain in-flight requests during shutdown. healthCheckIntervalMslong 2000Peer health check interval. Min 100ms. metricsPortint 9090Prometheus metrics HTTP endpoint port.
Property Type Default Description circuitBreakerConfig.enabledboolean truePer-peer circuit breaker isolation. circuitBreakerConfig.failureThresholdint 5Consecutive failures before OPEN. circuitBreakerConfig.recoveryTimeoutMslong 30000Time before OPEN → HALF_OPEN transition. circuitBreakerConfig.halfOpenMaxRequestsint 3Max concurrent requests in HALF_OPEN.
All writes are persisted to WAL before acknowledgment. Snapshots compact recovery logs.
Property Type Default Description dataDirPath ./dataWAL and snapshot directory. Use SSD/NVMe. snapshotThresholdint 10000Entries before creating a snapshot. enablePersistenceboolean falseEnable WAL + snapshots. Set true for production. syncOnCommitboolean truefsync after each commit. false = lower latency, higher crash risk.
WAL format: 4-byte length + 8-byte term + 8-byte index + command bytes + 4-byte CRC32
Recovery sequence:
Load latest snapshot (if exists)
Replay WAL entries after snapshot index
Rejoin cluster and participate in election
Property Type Default Description maxMapEntriesint 100000Max key-value pairs in memory. evictionPolicyString LRUEviction strategy: LRU, LFU, or Random. maxMemoryByteslong 1073741824Memory limit (1 GB default).
Container tip: Set maxMemoryBytes to 70–80% of the container’s memory limit.
Property Type Default Description tlsConfig.enabledboolean falseEnable TLS encryption. Required for production. tlsConfig.keyStorePathPath (required) PKCS12 keystore with server identity. tlsConfig.keyStorePasswordString (required) Keystore password. tlsConfig.trustStorePathPath (required) Truststore with trusted peer certificates. tlsConfig.trustStorePasswordString (required) Truststore password. tlsConfig.requireClientAuthboolean trueEnforce mTLS (client must present certificate). tlsConfig.protocolsList [TLSv1.3, TLSv1.2]Allowed TLS protocol versions.
Property Type Default Description authConfig.enabledboolean falseEnable role-based authorization. authConfig.gatewayTrustboolean trueTrust X-Auth-User and X-Auth-Roles headers. authConfig.userHeaderString X-Auth-UserHeader for authenticated username. authConfig.rolesHeaderString X-Auth-RolesHeader for comma-separated roles. authConfig.rolePrefixString ROLE_Prefix to strip from role names.
Supported permissions: MAP_GET, MAP_PUT, MAP_DELETE, QUEUE_PUSH, QUEUE_POP, QUEUE_PEEK, SET_ADD, SET_REMOVE, SET_CONTAINS, TOPIC_PUBLISH, TOPIC_SUBSCRIBE, LOCK_TRY, LOCK_UNLOCK, COUNTER_INCREMENT, COUNTER_GET, HEALTH_CHECK, METRICS_READ, CLUSTER_INFO, * (wildcard).
Property Type Default Description hotKeyConfig.enabledboolean falseEnable hot key sampling. hotKeyConfig.samplingRatedouble 0.05Sample probability (0.05 = 5%). hotKeyConfig.thresholdint 100Accesses per window to classify as hot. hotKeyConfig.windowDuration 60sEvaluation window duration. hotKeyConfig.maxTrackedKeysint 10000Max distinct keys to track. FIFO eviction.
Property Type Default Description pipelinedExecutionboolean falseBatch commands for higher throughput. commandQueueCapacityint 10000Max commands in execution queue. commandExecutorThreadsint 0Dedicated executor threads. 0 = ForkJoinPool.
Property Type Default Description auditEnabledboolean falseLog all data operations for compliance. auditQueueCapacityint 10000Max queued audit entries before dropping. Never blocks data path.
Audit format: timestamp | nodeId | clientId | command | key | result | durationMs | requestId
Strategy Configuration Use Case Static List clusterMembers in builderSmall fixed clusters Seed Nodes LOOMCACHE_NODES env varGrowing clusters with gossip Multicast Enable on LAN Local datacenter DNS/Service Discovery Consul, Eureka, DNS SRV Cloud-native and Kubernetes Hardcoded Default Empty clusterMembers Local development
Variable Purpose Example LOOMCACHE_NODESSeed node addresses node1:5701,node2:5701LOOMCACHE_PORTServer port override 6000
System properties take precedence over environment variables. Builder defaults apply if neither is set.
The builder enforces these constraints at construction:
nodeId must not be null or blank
port and metricsPort must be 1–65535
raftElectionTimeoutMs ≥ 100ms
raftHeartbeatIntervalMs ≥ 10ms
healthCheckIntervalMs ≥ 100ms
snapshotThreshold > 0
maxMapEntries > 0
maxMemoryBytes > 0
heartbeatTimeoutMs > heartbeatIntervalMs
LoomConfig config = LoomConfig . builder ()
. bindAddress ( " 192.168.1.10 " )
. raftElectionTimeoutMs ( 3000 )
. raftHeartbeatIntervalMs ( 1000 )
. maxEntriesPerAppend ( 100 )
. logCompactionThreshold ( 10000 )
. gracefulShutdownDrainMs ( 200 )
. snapshotThreshold ( 10000 )
. maxMemoryBytes ( 2_147_483_648L )
. auditQueueCapacity ( 10000 )