Load testing a self-hosted community before launch day
Confession: the first time I launched a community site, I tested it by clicking around on my laptop and declaring it fast. Then a newsletter went out, a few hundred people arrived in the same ten minutes, and I learned what a 502 looks like from the wrong side. These days I load test before anything goes public.
The setup
The test box was a modest VPS with 2 vCPUs and 4 GB of RAM, running UNA on PHP 8 with MySQL on the same machine, plus a Next.js front end talking to it over the API. I used k6 to script a simple member journey: open the home feed, open a post, load the comments, and every tenth virtual user leaves a comment.
What broke first
Not PHP, which surprised me. At around 150 concurrent virtual users the database started queuing, because I'd left MySQL on near-default settings. Raising the InnoDB buffer pool so the working set fitted in memory roughly halved the median response time on feed requests. The second bottleneck was me: my Next.js pages fetched the feed on every request instead of caching it for even a few seconds.
What I changed
- Tuned the MySQL buffer pool and connection limits for the size of the box.
- Configured PHP OPcache properly. It was on, just with a tiny memory limit.
- Cached public feed responses in the front end for 30 seconds, while logged-in pages stay fresh.
- Moved image resizing out of the request path.
After those changes the same box handled about 400 virtual users with p95 response times under 800 ms. That's not a benchmark for anyone else's server, just proof that the defaults are rarely the ceiling.
If you're launching something this autumn, run even a crude load test first. Twenty minutes with a script beats explaining downtime to your first members. I'm happy to share my k6 script in UNA Builders; it's about forty lines, and most of them are comments apologising to future me.
Info
html
asdasdasd