What we tested
The storefront script sends events in small batches: a visitor entering a test, viewing a page, adding to cart, ordering. The collector receives the batches, answers quickly, and records them for results. If it slows down, shoppers don't notice, because the script never waits for it. But events that never arrive are missing from your results, and if they go missing more from one version than another, the comparison is wrong.
Our target was set before the sale: handle peaks of about 500 events a second, answer 95% of requests in under 300 ms, and lose no events.
The first run: fine at 100 a second, not at 500
We ran the load test on 9 October against our staging server, which runs on the same machine as production with tighter limits (1.5 CPUs for the app), so production can do at least what staging does.
| Scenario | Events a second | Response time | Errors | Events recorded |
|---|---|---|---|---|
| Steady load | 100 | 95% under 300 ms | 0 | 61,106 of 61,106 |
| Ramp toward 500 | About 340 reached | Median 2,800 ms; 95% at the 10,000 ms timeout | 23% timed out | Not checked |
The steady run passed. The ramp did not: the app hit its CPU limit at about 130 requests a second and requests queued until they timed out. The database was nearly idle. The bottleneck was one Node.js process doing all the work on one CPU.
What we changed
- Less work per request. We profiled the collector and removed work from the hot path. On its own that saved little per request (2.4 ms of CPU before, 2.2 ms after, at 500 events a second), but under load the difference was much larger: before, a process starved of CPU timed out its own calls to the event buffer and fell back to slower inline writes, sometimes twice.
- More processes. The app now runs several worker processes, one per CPU it can use, leaving room for the database. Each worker serves requests and drains the event buffer; one of them also runs the background jobs.
- Measured limits. On a bench with half a CPU, two workers were slower than one, so the number of workers follows the CPUs actually available rather than a fixed setting.
Before and after, on a bench
We measured the changes on a local bench running the same image under a CPU limit, with the same load script. Half a CPU reproduced the staging ceiling (about 125 requests a second, then the same collapse), so we read that setup as staging. Four CPUs without a limit stand in for production; production's cores are slower than the bench's, so expect roughly a third of these rates there.
| Setup | Code | Events a second | 95th / 99th percentile (ms) | Failed |
|---|---|---|---|---|
| Half a CPU, 1 process | Before | 300 | 1,291 / 1,645 | 0 |
| Half a CPU, 1 process | Before | 400 | 10,000 / 10,000 | 94% |
| Half a CPU, 1 process | Before | 500 | 10,000 / 10,000 | 87% to 96% |
| Half a CPU, 1 process | After | 300 | 52 / 84 | 0 |
| Half a CPU, 1 process | After | 500 | 59 / 78 | 0 |
| 4 CPUs, 1 process | Before | 2,500 (45 s) | 1,834 / 10,000 | 1.8% |
| 4 CPUs, 3 workers | After | 2,500 (45 s) | 4.8 / 9.1 | 0 |
| 4 CPUs, 3 workers | After | 4,000 (45 s) | 5.3 / 8.8 | 0 |
When our server doesn't answer
Capacity is one half. The other is what happens when the server is down, slow or being redeployed during a peak. Since 11 October events have three layers of protection:
- An edge worker in front of the server. Batches go to a Cloudflare Worker first, which passes them to our server. If the server answers with an error, takes longer than 5 seconds or can't be reached, the worker stores the batch in Cloudflare R2 and answers the browser. Stored batches are replayed within about a minute of the server recovering, with their original receive time, so they count on the right day.
- Resends from the browser. The storefront script keeps each batch in the browser until the server confirms it, and resends unconfirmed batches on a later page view: up to 3 sends within 24 hours.
- Counted once. The server remembers each event's id for 48 hours, so a batch that is resent, or replayed after it did get through, changes nothing.
A drill on staging took the app down, checked that batches were stored, and checked that they were replayed with their original receive time when it came back. The limits are honest ones: an outage longer than 47 hours moves stored batches aside instead of replaying them, because the duplicate check only lasts 48 hours; and a shopper whose batch fails everywhere and who never loads another page within a day loses that batch.
What we haven't tested yet
- A sudden spike on staging. The ramp and steady runs are done; a spike from quiet to peak in seconds is still to run.
- Losing the event buffer. A drill where the buffer between the collector and the database fails during load is still to run.
- A real BFCM peak. No bench is the real thing. We will watch the same numbers during the sale: CPU, response times, the drain backlog and any stored batches.
What this means for your tests
- Your store never waits for us. The script sends events in the background; a slow collector delays recording, not your pages.
- A short outage doesn't leave a hole in your results. Batches are stored at the edge or kept in the browser and arrive late but intact, counted once.
- Check your split anyway. If events did go missing unevenly, a sample ratio mismatch check would show it. Benchmyrk runs one on every test.