How the Ra log architecture works
mainRa uses a shared infrastructure model to support thousands of Ra servers per Erlang node efficiently. Instead of each server writing its own log files and calling fsync(1) independently, all log entry writes are funneled through a common Write-Ahead Log (WAL).
Core Workflow
- Ra Servers write entries to their local In-Memory Tables (Memtables) and send a write request to the WAL.
- The WAL (
ra_log_wal) persists entries to disk and notifies the server when they are synced. - When a WAL file fills up, the WAL notifies the Segment Writer (
ra_log_segment_writer). - The Segment Writer reads from the memtables and flushes the data into permanent Segment Files on disk.
- Ra Workers handle long-running tasks like snapshotting and log compaction, moving data from segments to snapshots.