Load-testing a password manager's backend with k6

How I load-tested OpenVireo's auth and sync servers with k6 on a small CPU budget, what saturated first, and how I turned requests per second into a daily-active-user estimate.

By 6 min read

Before putting OpenVireo’s hosted service in front of users, I wanted one number: how many people can a small server handle? Not a benchmark of one endpoint, but the whole backend doing what real clients do, on roughly the CPU I’d actually pay for.

This post covers how I set that up with k6, what a “realistic” request mix looked like, what broke first (not what I expected), and how I turned the result into a capacity estimate.

The system

Two services matter:

  • Auth (Python, Flask, gunicorn): accounts, OPAQUE sign-in, device sessions, token refresh, vault metadata and sharing. It issues short-lived EdDSA access tokens.
  • Sync (C++, Drogon): stores encrypted vault files, compares ETags, streams change events. Described in a sync server that can’t read your data.

Plus Postgres and Redis. Everything runs from one Docker Compose file locally, which made it easy to point k6 at the same stack.

Step one: what does a client actually do?

The most common mistake in load testing is hammering the endpoint you’re curious about instead of the one clients call. So I started from what an idle OpenVireo client does every time it checks for changes:

  1. GET /vaults on auth (the list of vaults and their keys, which can change when someone shares a vault with you),
  2. GET /vaults on sync,
  3. a conditional GET /vaults/{id} with If-None-Match, which is a 304 almost every time,
  4. one time in five, a PUT of a 200 KB vault (someone edited something),
  5. POST /auth/refresh whenever the access token is a minute old.

That’s one k6 iteration. The test ramps up the rate of iterations, not the number of users, because a client’s request rate is what the server feels.

What it deliberately leaves out:

  • OPAQUE sign-in and registration. People sign in rarely compared to how often clients sync. It’s worth testing on its own, but it would have dominated this test without representing real traffic.
  • The events stream. Clients keep a server-sent events connection open to hear about changes immediately. k6 has no SSE client, so those connections aren’t modelled.

Making the test honest

A few details turned out to matter more than the load script itself.

Fresh users, every run. Refresh tokens rotate: using one returns a new one and revokes the old one. Two virtual users sharing an account would keep revoking each other’s sessions, and the test would measure error handling. So a seed script creates a few hundred real accounts through the client SDK (proper OPAQUE registration, a real vault) before every run, and each virtual user owns one.

One IP per user. The auth server rate-limits per IP. In production it sits behind a proxy and reads X-Forwarded-For. If every virtual user came from the k6 container’s address, the rate limiter would kick in at a few requests per second and I’d be measuring that. Each virtual user sends its own X-Forwarded-For, so the limits apply per user, as they would for real clients.

Uploads that pass validation. The sync server can’t decrypt vaults, so it only checks the KDBX signature in the first eight bytes. The uploads are random bytes behind that signature: the right size, the right shape, and no time wasted generating real KeePass files.

A realistic CPU budget. Running everything on a laptop with no limits tells you how fast the laptop is. I capped each container with docker update to roughly what a small production host would give it:

ContainerCPUMemory
auth0.5 core700 MB
Postgres0.25 core400 MB
sync0.15 core200 MB
Redis0.1 core100 MB

Results

Two runs: one ramping to 120 iterations a second, one ramping to 600 to find the knee.

ramp to 120/sramp to 600/s
Requests37,934, 0 errors91,647, 0 errors
Auth p9512 ms1.2 s (saturated)
Sync p951.2 ms1.2 ms
Auth CPU~31% of a corepinned at its 50% cap
Sync CPU / RAM6% / 33 MB11% / 103 MB

Auth, with two gunicorn workers, tops out at about 190 requests a second on half a core. Past that, requests queue and p95 climbs from milliseconds to over a second. No errors, just waiting.

Sync didn’t notice. At the peak it used 11% of a core and about 100 MB of memory, with a p95 of 1.2 ms the whole time. Postgres was nowhere near its limit either.

Why the C++ server is idle and the Python one isn’t

It’s tempting to read that as “C++ fast, Python slow”, but most of the gap is about what each request does.

A sync request is mostly a cheap check: verify the token’s signature, compare an ETag, answer 304. The server never decrypts anything, because it can’t. The expensive part of sync, decrypting and merging, happens on the user’s device.

An auth request does real work per call. A refresh rotates the token in the database and signs a new one. Listing vaults assembles keys and grants for the user. And a Python worker handles one request at a time, so two workers on half a core is not much concurrency.

The useful finding wasn’t the number. It was that the design pushed cost to the right place. The service that holds everyone’s data is the one that barely needs CPU, and the one that’s CPU-bound is stateless apart from Postgres, so I can scale it by adding workers or instances without touching storage.

From requests per second to users

A capacity estimate needs three numbers:

  1. Sustainable rate. I don’t plan at the saturation point. I used ~100 auth requests a second per vCPU, about half of what two workers did on half a core. The headroom covers sign-ins, background jobs and the requests this test didn’t model.
  2. Requests per daily active user. About 120 auth requests per user per day, most of them token refreshes from devices that stay open.
  3. Peak-to-average ratio. Traffic isn’t flat. Assume the busiest hour runs at 5× the daily average.

Then:

100 req/s × 86,400 s/day = 8.64M requests/day of capacity
÷ 5 (peak headroom) = 1.73M requests/day sustained
÷ 120 requests per user per day ≈ 14,000 daily active users

That’s per vCPU of auth, with sync and Postgres along for the ride.

And then the surprise: CPU isn’t what runs out first. Disk is. The sync server keeps previous versions of every vault so users can restore one, and a few hundred KB per version per save adds up much faster than requests do. The history length is configurable, and that setting, not the CPU, is what decides when the server needs to grow.

What I’d do next

  • Load-test sign-in separately. OPAQUE costs real CPU on the server, and a reconnect storm after an outage means many sign-ins at once. That’s a different test with a different shape.
  • Model the event streams. Thousands of idle connections are cheap for an event-loop server, but “cheap” deserves a number.
  • Profile auth before scaling it. I know where it saturates, not yet which line of code is to blame. More workers would raise the ceiling; a profile might show a cheaper fix.

Takeaways

  • Load-test the request mix your clients send, not the endpoint you’re curious about.
  • Get the boring details right: fresh credentials, per-user IPs, payloads that pass validation. Each of those, done wrong, turns the test into a benchmark of your error handling.
  • Cap resources to what you’ll pay for. Unlimited local runs only measure your laptop.
  • Turn the result into an estimate with its assumptions written down. “190 req/s” means nothing to someone deciding what server to buy; “about 14,000 daily users per vCPU, and disk runs out first” does.