Work / CS-01

Stopping the website falling over during email campaigns

Year
2026
Where
High Speed Training
Themes
Performance, AI
Stack
.NET 8, OrchardCore, k6, Grafana, InfluxDB, dotnet-trace, dotTrace

Result, up front

  • +422%throughput, 65 → 339 req/s locally
  • 8–14 s → <5 sproduction CPU spikes
  • 24 → 6.5 msaverage response time
  • Best use of AIcompany tech recognition, March 2026

Situation

Each big marketing email sent a traffic spike to the public course website, and the site kept falling over. As a result, Marketing had to hold back campaigns.

How I framed it

“The server is too small” was the easy answer. I didn’t trust it until I could make the crash happen on demand and see where the time went.

What I did

  • Reproduced the failure locally with k6 load tests, Grafana and InfluxDB dashboards, and profiled the app under load with dotnet-trace / dotTrace.
  • Used AI to work through the profiles and traces faster, and checked every hypothesis it suggested against real measurements.
  • Found five root causes, not one:
    1. A cache stampede on the product API cache: when it expired, every request rebuilt it at once.
    2. A second cache stampede on the CMS product query.
    3. An HTML minifier using more than 20% of CPU to save 4.7 KB per page.
    4. Per-render data fetching: one page with 188 product cards did 188 JSON deserialisations and 56,776 list iterations.
    5. A schema-markup serialiser rebuilding its reflection data on every request.
  • Fixed each one. I added a lock-protected cache so only one request rebuilds an entry, built view models once and cached them, cached the schema markup, and removed the minifier.

Result

  • Locally: 65 → 339 requests/second (+422%). Average response time went from 24 ms to 6.5 ms, and failed requests above 66 req/s from 100% to 0%. SQL connection-pool exhaustion disappeared, threads fell from 297 to under 10, and allocations from 2.6 GB/s to under 1 GB/s.
  • In QA: the courses page went from 18 to 44 req/s (+144%), and the product page and homepage both improved by +67%.
  • In production: CPU spikes fell from 8–14 s to under 5 s, p99 latency spikes of 400–600 ms flattened out, and the courses page now loads in under 100 ms.
  • Marketing could send campaigns again. The work won “Best use of AI” in the company’s March 2026 tech recognition, and colleagues asked me to turn the write-up into a dev talk.

What I took away

One symptom can hide several causes, so keep measuring until the numbers say you’re done. AI made the trace analysis much faster, but the load tests decided what was true.

→ Contact

Have a problem worth measuring?

I'm a Senior Software Engineer in the UK. The quickest way to reach me is email.