Sync CPU-heavy work in request path
Part of the Scalability antipatterns check · fix arrives as a guide
What it is
CPU-heavy synchronous work — image processing, PDF generation, encryption over a large payload, a big JSON parse — runs inside the request handler.
Why it matters
In a single-threaded runtime this blocks the event loop, so every other request on the instance waits behind it. One user's expensive operation becomes a latency spike for everyone sharing that process.
How to fix it
Move the work to a queue and return immediately with a job id, or push it to a worker thread or a separate service. If it must be inline, chunk it and yield between chunks so the loop can serve other requests.
Run them all on your app
Connect your repo and your live services with read-only scopes. The first scan is free, and nothing changes without your approval.