Skip to main content

In-Memory Metadata Mode

Under normal circumstances, RustMailer stores all metadata using native_db files.
However, to increase throughput for email sending tasks and webhook/event callbacks, and to boost performance for handling many accounts and frequent tasks, RustMailer provides an in-memory metadata mode.

How It Works

  • Metadata in memory:
    When in-memory mode is enabled, meta and tasks databases are kept entirely in RAM during runtime, similar to how Redis works.
    This reduces disk I/O and boosts overall system performance.

  • Envelope still on disk:
    The envelope database remains file-based, as storing it on disk generally does not become a performance bottleneck and helps keep memory usage low.

  • Use case:
    This mode is optimized for scenarios such as thousands of synchronized mail accounts or high-frequency mail sending.


Snapshot Mechanism

Even in in-memory mode, RustMailer periodically takes snapshots of metadata to ensure persistence across restarts.

  1. Files generated:
    Both meta.db and tasks.db are snapshotted together.

  2. Filename format:

    {db_prefix}.{yyyy-MM-dd-HH-mm}.snapshot

    Example:

    meta.2025-08-14-19-00.snapshot
    tasks.2025-08-14-19-00.snapshot
  3. Interval: Controlled by RUSTMAILER_METADATA_SNAPSHOT_INTERVAL_SECS (default: 900 seconds). In the worst case, only changes made within the last interval could be lost.

  4. Enable/Disable: In-memory mode is enabled with:

    RUSTMAILER_METADATA_MEMORY_MODE_ENABLED=true
  5. Automatic recovery: On startup, RustMailer will automatically load the latest snapshot back into memory.