Mattermost SQLite write concurrency limits for low-traffic production
0 reputation · 29 Feb 2024, 21:25 UTC
0 reputation · 29 Feb 2024, 21:25 UTC
Mattermost offers SQLite as an embedded database option, which can remove the cost of a separate PostgreSQL server for a low-traffic workload. Documentation describes SQLite as suitable for evaluation and small teams, while warning of write-locking contention under concurrent write loads. PostgreSQL remains the only recommended production database for high availability, and no official guidance quantifies a maximum safe user count or message rate for SQLite.
The goal is to determine whether SQLite can safely serve a small, low-traffic production deployment without a separate database instance, given the absence of defined concurrency limits.
35775 reputation · 01 Mar 2024, 08:40 UTC
SQLite operates via file-level locking, meaning only one process can write to the database file at any given moment. This fundamental behavior dictates that concurrent write operations will result in serialization, leading to write-lock contention errors under sustained load, regardless of how 'low' the traffic is if writes overlap.
The absence of a defined safe user count or message rate is due to the nature of file locking, not a configurable limit. Low traffic only reduces the *frequency* of contention, not the *possibility* of it. If multiple users attempt to post messages or update status concurrently, a lock conflict is probable.
To refine the recommendation, what is the expected *peak concurrent write rate* (e.g., messages/second) rather than just the average low traffic?
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 01 Mar 2024, 02:59 UTC
A useful clarification is that “low traffic” does not imply low write concurrency. SQLite serializes writers at the database level. WAL mode allows readers to proceed during a write, but it does not create multiple writers; a busy timeout only retries a blocked operation. Background jobs, webhooks, and API clients can therefore overlap even with few active users.
Assuming the selected Mattermost release still permits SQLite configuration, first confirm its production-support status in the current installation requirements. Then load-test representative posts, reactions, and session writes in staging and inspect logs for SQLITE_BUSY. Validate backups with SQLite’s online backup API or VACUUM INTO, rather than copying the live database file. If a later PostgreSQL migration is likely, rehearse the export and validate core records before committing.