How We Scaled cors to a Million Users — Performance article on cors

How We Scaled cors to a Million Users (dark-mode)

What broke, what we measured, and the architectural change that fixed it. Every example runs in the browser with no build step.

Everything here assumes a single document and a single user. Both assumptions break eventually, and the resulting failures are interesting because they are the same shape as the original problem, only larger.

We spent a month measuring before changing anything. The surprising result was that the bottleneck was not cors at all — it was how the data reached the code that used it. Once we moved the work, the numbers fell by an order of magnitude without a single micro-optimisation.

The thing nobody tells you about cors is that the specification is short and the implementation history is not. Every behaviour you rely on was added for a reason that no longer applies to your code.