What Actually Limited AuthOS on SQLite
AuthOS appeared to hit SQLite's limits at 130 requests per second. Moving Argon2 work, audit writes, activity updates, and overload control changed the result—and exposed what the benchmark still could not prove.

On this page
Audio edition
0:00 / 8:46
Ready
The first AuthOS load test made SQLite look guilty. The service flattened at roughly 130 requests per second, while P95 latency reached 17.69 seconds on the SQLite backend.
AuthOS is a Rust authentication platform that can use SQLite, PostgreSQL, or MySQL. Its SQLite path handled organization administration, webhook management, OAuth callbacks, and login. Once concurrent traffic arrived, however, the service spent far too much time waiting.
The initial diagnosis was broader than “SQLite is slow.” Argon2 work occupied Tokio worker threads, audit events were written before requests could finish, activity tracking created avoidable writes, and overloaded requests waited in an ever-growing queue.
I changed those four parts before considering a database replacement. The result was a useful recovery, but it was not evidence for the 25 million MAU claim I originally attached to it. It showed where this version of AuthOS was losing capacity and how much the tested workload improved after those losses were addressed.
What the first result told me
At about 130 requests per second, the system was saturated rather than merely slow. A request could combine CPU-heavy password verification with one or more small database writes. As concurrency increased, queued work kept those shared resources occupied and pushed latency into seconds.
SQLite mattered because writes to one database are serialized. In WAL mode, readers and a writer can proceed together, but there is still only one writer at a time . That makes short, deliberate write transactions important. It does not mean that each write blocks every read, as the earlier version of this article claimed.
The load test exposed a combined application and database problem. It did not isolate SQLite as the cause, because several parts of the application changed between the first and final runs.
Move password hashing off Tokio’s worker threads
Argon2 verification took about 50 ms in this setup. Calling that synchronous work directly from an async handler occupied a runtime worker for the duration. Under concurrent logins, other tasks had fewer workers on which to make progress.
Tokio provides spawn_blocking for this boundary. Its documentation also
recommends limiting parallelism for CPU-bound work because the blocking pool has
a large default thread limit. I put a semaphore in front of password work and
ran each verification with
spawn_blocking
.
The important part was not the specific permit count. I started with twice the CPU core count, then treated that as a tuning parameter rather than a rule. The limit protects the rest of the process from an unbounded batch of password checks. In simplified form, the boundary looks like this:
let _permit = password_limit.try_acquire()?;
let verified = tokio::task::spawn_blocking(move || {
verify_argon2(password, stored_hash)
}).await??;
This is also where overload policy begins. Waiting for a permit is reasonable at light contention. During saturation, accepting unlimited waiters only moves the failure into a longer queue.
Take audit writes off the response path
The original handler waited for each audit insert. That coupled response time to SQLite write availability even when the response itself did not depend on the audit row.
I changed the logger to send events to a background worker. The worker
collected up to 100 events or waited for a one-second flush interval, then wrote
the batch. It could retry SQLITE_BUSY away from the user-facing request.
That change has a real durability boundary. An event waiting in process memory can be lost if the process exits. A bounded channel needs an explicit policy when it fills—wait, reject the request, or drop the event—while an unbounded channel can turn sustained pressure into memory growth. A one-second in-memory buffer is only acceptable where the product’s audit requirements tolerate that window. A durable queue or synchronous write is the safer design when an audit record must survive every acknowledged request.
The useful lesson was narrower than “audit logs can be eventually consistent.” It was that AuthOS did not need to make every request wait on the audit table, given the durability trade-off chosen for this deployment.
Stop refreshing last_seen on every request
Activity tracking wrote a new last_seen value on every authenticated request.
Most of those updates added no useful information. I changed the path to write
only when the stored value was more than five minutes old.
In this load-test workload, that reduced write I/O by about 90%. The number is workload-specific: a different mix of users and requests would produce a different reduction. The five-minute window is also a product decision. It is appropriate for coarse activity reporting, not for security logic that needs an exact timestamp for every action.
Reject excess login work before it becomes latency
At 1,000 concurrent clients, the previous implementation kept requests waiting
until they hit a 30-second timeout. I changed login admission to use
try_acquire on the password semaphore and return 429 Too Many Requests when
no permit was available. I also limited how long a writer would wait for
SQLite.
This does not create more capacity. It makes saturation explicit and protects requests that the service has already admitted. Clients still need a sensible retry policy with backoff; immediate retries would recreate the same pressure at the edge.
The measured result
After all four changes, I recorded these results:
| Metric | Initial run | Moderate load | Saturation run |
|---|---|---|---|
| Throughput | ~135 req/s | 210 req/s | 467 req/s |
| P95 latency | 17,690 ms | 4.88 ms | 2,720 ms |
| Error rate | 0% | 0.00% | 0.01% |
| Observed bottleneck | CPU and write waits | None identified | DB connection pool |
The moderate-load result is the most useful one: throughput increased while P95 latency fell sharply. The saturation run found a higher throughput ceiling, but its 2.72-second P95 is not a target operating point.
These figures also have an important evidentiary limit. This article does not preserve the test duration, hardware, dataset size, endpoint mix, or load generator configuration. Without those details, the results are a record of a diagnosis, not a reproducible capacity benchmark. They should not be used to compare SQLite with PostgreSQL or to size another deployment.
Why the “25M MAU” estimate does not hold
The original estimate multiplied 210 requests per second by 86,400 seconds, assumed four authentication requests per daily active user, then assumed daily active users were 20% of monthly active users. That produces roughly 22.7 million MAU before rounding.
Each step adds an assumption the load test did not verify. Sustaining one test rate continuously is not the same as serving a real daily traffic curve. The number of authentication requests per user was assumed, as was the DAU/MAU ratio. The 467 requests-per-second saturation result cannot justify rounding the estimate upward because it came with much worse latency.
So the benchmark does not establish a 25 million MAU capacity, or even a 40-million-request daily capacity. The filename remains unchanged to preserve the published URL, but the claim should not guide an architecture decision.
What I would carry into the next test
The experiment earned a narrower conclusion: replacing SQLite would not have fixed the blocking Argon2 calls, noisy activity updates, synchronous audit path, or unbounded admission queue. Fixing those first made AuthOS substantially healthier and exposed the connection pool as the next observed limit.
A defensible database decision needs the next benchmark to record the machine, test duration, endpoint and read/write mix, database size, concurrency model, pool settings, WAL and checkpoint settings, and latency distribution. It should then run the same workload against each candidate backend.
Until that comparison exists, SQLite has neither won nor lost. It has simply stopped taking the blame for work the application was doing badly.



