Diagnostic step 1
Replace synchronous image processing with an asynchronous native library such as sharp (libvips-backed) which performs heavy work off the main thread. Test memory and CPU usage under load before rolling out.
Generated Oct 3, 2026, 12:35:03 AM
Replace synchronous image processing with an asynchronous native library such as sharp (libvips-backed) which performs heavy work off the main thread. Test memory and CPU usage under load before rolling out.
If library replacement is not immediately feasible, offload processing to worker_threads or a pool of workers using the worker_threads API, or use a small pool of child_process workers. Implement a bounded queue so you limit concurrent CPU tasks (e.g., maxWorkers = number of vCPUs).
Consider moving uploads to temporary storage (object store or shared volume) and enqueue a background job (RabbitMQ, BullMQ, or simple Redis queue) that a separate set of worker processes consumes; this decouples request latency from processing time. Return an immediate 202 Accepted with a job ID to the client if appropriate.
Instrument event-loop delay (e.g., nodejs event-loop-delay monitoring) and set alerts; add per-request timeouts and upload size limits to prevent abuse.
When migrating, do a canary rollout: enable worker offload on a subset of traffic, use feature flags, and verify behavior under load. Avoid in-place destructive changes; keep backups for configuration and test with representative traffic. If you need help designing a scalable processing pipeline for high-concurrency uploads, consider engaging a backend engineer experienced in Node.js concurrency patterns to review the migration plan.