Overpass 2026 was Bracken's capture-the-flag competition, run on our own platform at ctf.bracken.sh. The night before, I had spread the challenge instances across several servers, moved the web challenges onto our own domain and fixed the challenges that wouldn't start. The challenge side was ready.
The problem came from the one part I wasn't watching: the database. A couple of hours into the event, players started getting logged out, the board stopped loading and flag submissions failed. This is how I found the cause and fixed it while the event kept running.
All times are Amman time, on 20 November 2026.
What players saw
- Logged out for no reason. Players had to log back in in the middle of a challenge.
- Pages that wouldn't load. The board, the challenge list and the scoreboard sometimes showed an error page.
- Flags that wouldn't submit. A correct flag came back as an error.
In a CTF, that last one is the worst. The scoreboard is the whole event, and a team that can't submit is losing time it won't get back.
The challenge servers were fine all morning, with low load, plenty of free memory and no errors. Everything that went wrong was between the website and its database.
Finding the cause
1. Read the logs before touching anything
The production logs showed the same two errors over and over: the database refusing new connections, and the login system failing to check sessions.
An early fix made idle connections close sooner, and the refusals stopped. The pain didn't, though. Requests now sat waiting for a free connection and timed out. So the database wasn't refusing us any more; we were holding on to too few connections for too long.
2. Work out why people were being logged out
This was the most damaging part. On every request, the site checks the player's session against the database. When the database was slow, that check failed, the site treated the failure as an invalid session, and it cleared the login cookie. A busy database became a logout.
3. Find where the load came from
I grouped requests by page and found two surprises:
- My own feature was the second-busiest page. The night before, I had added a sidebar that shows a team's running instances. It refreshed every 30 seconds, again whenever the tab got focus, and asked every challenge server each time. It was getting three times the traffic of the board.
- Every challenge file was being requested about 60 times in 7 minutes, evenly. That wasn't real downloads. It was players' browsers loading the files list whenever they opened the board. Real load, not a bug, but it added up.
On top of that, each player request cost about five database queries, and the board cost about a dozen.
4. Find the real ceiling
The database wasn't running out of processing power. It was running out of connections:
- Under event traffic, the website scales out to dozens of copies of itself.
- Each copy kept its own small pool of 3 connections.
- The database only accepted 200 connections in total.
Dozens of copies with 3 connections each fill 200 very quickly. Every slow query held a connection longer, so the problem fed itself.
The fix, step by step
The rule I set for myself: don't disturb the players. No forced logouts, no maintenance window, no restart unless there was no other way.
Step 1: Stop the bleeding (09:58)
One release with three changes:
- A slow database no longer logs anyone out. If the session check fails because the database is busy, the session is kept and checked again 15 seconds later. This had the biggest effect on players.
- Removed a lock I'd added that held a connection for the whole time a team's instance was starting.
- Slowed the sidebar down. It now refreshes every 60 seconds, only while the tab is visible, and not again on focus if it just loaded.
Within a few minutes, session errors fell from 79 a minute to 3 a minute.
Step 2: Stop asking the database the same question
Most of what players read changes only when an organizer edits something. So each copy of the site now keeps it in memory for a few seconds:
- The event details for 3 seconds, since every request reads them.
- The challenge and category lists for 5 seconds. This was the big one.
- The board refresh after a solve now spreads over 1–7 seconds instead of 1–3, so a first blood doesn't make every open board hit the database at the same moment.
Flag submissions also got a longer wait for a free connection, so they stopped failing after only 2 seconds.
After the list cache went live at 10:22, errors dropped by about 95%:
| Time | Errors per minute |
|---|---|
| 10:08–10:13 | 30–230 (peaks at each release) |
| 10:19–10:22 | 40–85 |
| 10:23–10:29 | 6, 9, 53 (one burst), 10, 4, 4, 2 |
Step 3: Fail gracefully when it still happens (10:38)
Even with fewer queries, the connection cap was still there at busy moments. So the next release made those moments less painful:
- Reads retry once and return a clear "busy" response instead of a generic error.
- Background requests in the browser retry quietly with growing waits.
- Error pages retry by themselves and show "Reconnecting…" instead of "Something broke."
- Flag submissions are never retried automatically. A submission must never be sent twice. If one hits a busy moment, the player is told it didn't go through and can submit again.
Step 4: Raise the ceiling (10:39–11:05)
Code could only take it so far. The connection cap came from the size of the database server, so it had to grow:
- Moved the database to a much larger server (10:54). This was the one restart I couldn't avoid. The database was down for about two minutes and errors spiked to 1,751 in one minute. Because of step 1, nobody was logged out.
- Raised connections per copy of the site from 3 to 10 (11:02). Once the database was big enough, the small pool was the bottleneck.
- Treated "database is restarting" as busy, so the next resize gets the same quiet retry.
By 11:02–11:05, errors were down to 0–2 a minute.
Step 5: Move the code next to the data (11:18)
While looking at speed, I noticed something I should have caught weeks earlier. The website's code was running in the United States, while the database and the challenge servers were in Europe and the players were in Jordan and nearby. Every query crossed the Atlantic, about 90 ms each, and a single page makes several in a row.
A one-line config change moved the code to Europe, next to the database. It was an ordinary release with no restart, and pages that read the database started responding in about 0.3 seconds.
Step 6: Keep watching (11:29)
I set up a watcher that checked production every 3 minutes for new kinds of errors, error spikes, bursts of server errors, and any challenge server that was down, overloaded or low on memory. That watcher caught the next problem quickly: a few lab challenges were pointing at an old address for the service that runs their labs. Updating their settings fixed it without stopping any running labs.
The hardest part
The hardest part wasn't any single bug. It was fixing a live system through the same pipeline that was under load:
- Every release was itself a small outage. New copies of the site opened new connections while the old ones were still draining, and the error spikes at 10:08 and 10:10 lined up exactly with releases. After that, I stopped shipping small fixes and batched them into a few larger releases.
- Moving fast meant cutting corners. One change broke four tests because I ran only part of the test suite before shipping. The next batch fixed them, and after that I ran all of the tests (more than 2,000) before every release.
- Part of the load was my own fault. The sidebar I built the night before was a feature people wanted, but nobody had tried it with a full event's worth of players. Owning that quickly made the fix quick.
Why it matters
A CTF is a timed competition. Downtime isn't just annoying. It changes the results. A team logged out for ten minutes, or one whose correct flag bounced, is at a disadvantage that no apology fixes afterwards. That's why the first fix wasn't the clever one (caching) or the expensive one (a bigger database). It was making sure nobody got logged out, and that no flag was ever submitted twice.
The broader lessons, for anyone running a live event on a web platform:
- Do the connection math before the event. The number of copies of your site times the connections each one holds has to fit under your database's limit, with room to spare.
- Keep your code and your database in the same region. It's usually one line of config and it's the cheapest speedup there is.
- Fail open on reads, carefully on writes. A busy database should mean "Reconnecting…", not a logout. Retry reads freely and never retry a submission.
- Don't ship new features the night before. If you do, check what each one costs with real traffic.
- Watch production during the event, not just before it. Most of these problems only show up under real load.
From the first look at the logs to errors at almost zero took about an hour and ten minutes, with the event live the whole time, the players still logged in, and every flag counted once.
