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.
-
Files generated:
Bothmeta.db
andtasks.db
are snapshotted together. -
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 -
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. -
Enable/Disable: In-memory mode is enabled with:
RUSTMAILER_METADATA_MEMORY_MODE_ENABLED=true
-
Automatic recovery: On startup, RustMailer will automatically load the latest snapshot back into memory.