Start here. This is the direct spoken answer to practice first.
Why this question matters
Decide how to handle CPU-heavy work in an API without damaging request throughput or making the system unreliable. It matters in real backend work because load, cancellation, retries, and dependency latency decide whether the API stays predictable under pressure. The practical angle is cPU-bound work, request latency, background processing, queue design, bounded concurrency, and operational ownership, tied to a concrete production decision.
I would avoid doing heavy CPU work directly inside the request if it can take significant time. For small calculations it may be fine, but report generation or image processing can tie up server resources and slow other requests. A better design is often to enqueue the work, return a job ID, and let a background worker process it with controlled concurrency. The API can expose status and download endpoints.