Network

Network layer #

Two independent networks exist, and they solve different problems. Confusing them is the most common architectural mistake when reading about IceFireDB.

Intra-site networkInter-site network
PurposeOne consistent copy of the dataReplicate across sites / regions
TechnologyRaft (hashicorp/raft)libp2p + pubsub (crdt, ipfs-log, ipfs-synckv drivers)
TopologyLeader + voters, quorum requiredPeer-to-peer, no leader, eventual
Configured by-a, -j, --advertise, --raft-backend, --auth, TLS--servicename, --nettopic, --datatopic
Enabled byAlwaysOnly with a P2P storage backend

A common deployment runs a Raft cluster per site (strong consistency inside), with one node per site using a P2P backend to exchange data between sites (eventual consistency across). The engine does not combine the two for you — they are separate layers, and the P2P layer is a property of the driver, not of the server.

Intra-site: Raft #

  • Each node listens on exactly one socket. Peer connections identify themselves with a transport marker plus the auth token, so replication traffic and client traffic share the port and the TLS certificate.
  • The Raft log and stable store live in <data-dir>/IceFireDB/<node-id>/store/, in leveldb (default) or bolt (--raft-backend).
  • --advertise sets the address other nodes store for this node. Without it, the bound address is used, which is wrong behind NAT or in containers.
  • Joining: -j <addr> (the node adds itself) or RAFT SERVER ADD id address from the leader.
  • Snapshots: taken by the Raft layer, written to snapshots/<id>/state.bin via writeSnapshot; the log is truncated behind them.
  • Clock: Raft drives the machine clock through the internal replicated TICK command (default every 200 ms) so that time-dependent commands agree across replicas. --localtime replaces the remote time source with the local one, which is faster and riskier.

Inter-site: P2P drivers #

The crdt, ipfs-log and ipfs-synckv drivers open a libp2p host as part of the storage layer:

DriverDiscovery / transportData modelIdentity
crdtlibp2p DHT + pubsub, namespacedicefiredb-crdt-kv CRDT map over a local Badger/LevelDB--servicename + --nettopic
ipfs-logIPFS pubsub + icefiredb-ipfs-logAppend-only operation log, merged per peer--ipfs-log-dbname
ipfs-synckvIPFS node + ipfs-log, optional AES-256Versioned KV, IPFS as source of truth, local mirror--ipfs-synckv-key for encryption

Operational consequences:

  • All three flags must match across the nodes that should see each other. --servicename, --nettopic and --datatopic are the rendezvous: a mismatch silently creates two independent networks rather than an error.
  • No quorum, no leader. Writes succeed locally and propagate when peers connect; a partitioned peer keeps accepting writes and merges on rejoin (CRDT semantics), which is a very different contract from the Raft layer above.
  • IPFS must be reachable at --ipfs-endpoint (http://localhost:5001, the API port) for ipfs, ipfs-synckv and ipfs-log. A gateway on :8080 is not an API endpoint.
  • Peers are trusted at the network level. The mesh relies on the shared discovery names; there is no per-peer authorization. See Security.

Ports in a typical deployment #

PortProtocolPurpose
11001RESP / TLSClients and Raft peers (single socket)
11002HTTP/healthz, /readyz, /metrics (--metrics)
26063HTTPpprof (--pprof)
5001HTTP APIIPFS daemon, reachable from the node (not exposed by it)
randomlibp2pP2P driver connections, egress + ephemeral inbound

What the network layer does not do #

  • No service mesh integration, no gossip-based membership beyond libp2p discovery.
  • No cross-site consistency guarantee: the P2P layer is eventual, the Raft layer is per-cluster.
  • No multi-cluster federation: two Raft clusters do not merge automatically.