express.eventloop.lag
Event loop lagDimensions:None
Available on:
Prometheus (1)
Interface Metrics (1)
Dimensions:None
Technical Annotations (105)
Configuration Parameters (11)
prisma.transaction.timeoutrecommended: 5000trace.logs.limitrecommended: 25000THRESHOLD_NSrecommended: 100000000alert.eventloop.lag.thresholdrecommended: 1000chunkSizerecommended: 10000package-lock.jsonrecommended: properly locked versionsUV_THREADPOOL_SIZErecommended: 8wsEnginerecommended: uWebSocketsperMessageDeflaterecommended: true--max-semi-space-sizerecommended: larger than 4MB defaulttcp_nodelayrecommended: trueError Signatures (3)
Transaction already closed: A query cannot be executed on an expired transactionexceptionInvalid `prisma.taskAttempt.create()` invocation: Transaction API errorexceptionfs.readFileSynclog patternCLI Commands (24)
ssh -L 9221:localhost:9229 user@hostdiagnosticnode --trace-sync-io app.jsdiagnosticnpx clinic doctor -- node app.jsdiagnosticnpm install -g 0xdiagnostic0x app.jsdiagnosticnode --inspect your_app.jsdiagnosticclinic doctor -- node your_app.jsdiagnosticnpm install event-loop-lagmonitoringfunction processInChunks(data, chunkSize = 1000) { let index = 0; function nextChunk() { const end = Math.min(index + chunkSize, data.length); for (; index < end; index++) { processData(data[index]); } if (index < data.length) { setImmediate(nextChunk); } } nextChunk(); }remediationconst { Worker } = require('worker_threads'); function runWorker() { return new Promise((resolve, reject) => { const worker = new Worker('./heavy-task.js'); worker.on('message', resolve); worker.on('error', reject); worker.on('exit', code => { if (code !== 0) reject(new Error(`Worker stopped with exit code ${code}`)); }); }); }remediationconst fs = require('fs'); const readStream = fs.createReadStream('large-file.txt'); readStream.on('data', chunk => { console.log(`Received ${chunk.length} bytes`); });remediationnpm lsdiagnosticnpm auditdiagnosticnpm deduperemediationclinic doctor -- node your-app.jsdiagnosticconst { monitorEventLoopDelay } = require('perf_hooks'); const h = monitorEventLoopDelay(); h.enable(); setInterval(() => { console.log(`Event Loop Lag: ${Math.round(h.mean / 1e6)} ms`); }, 1000);monitoringnode --inspect your-app.jsdiagnosticclinic.jsdiagnostic0xdiagnosticclinic doctor - node main.jsdiagnosticclinic flame — node main.jsdiagnosticnode --trace-event-categories v8,node,node.async_hooks,node.perfdiagnosticclinic doctordiagnostic--trace-gcmonitoringTechnical References (67)
PinocomponentWinstoncomponentPM2componentfs.readFileSynccomponentevent loopconceptcrypto.pbkdf2SynccomponentPrismacomponentO(n^2) complexityconceptBig O notationconceptZodcomponentBuffer.byteLengthcomponentstream-jsoncomponentContent-Lengthprotocolnode:async_hookscomponentOpenTelemetrycomponentprocess.hrtimecomponentV8 profilercomponentprocess.hrtime.bigint()componentWorker ThreadscomponentsetImmediateconceptworker_threadscomponentfs.readFilecomponentasync/awaitconceptN+1 queriesconceptconnection poolingconceptcluster modulecomponentsetTimeoutcomponentWorkercomponentstreamcomponentfs.createReadStreamcomponentbackpressureconceptdebounceconceptthrottleconceptWebSocketsprotocolmoment.jscomponentdate-fnscomponentdayjscomponentfast-json-stringifycomponentclinic.jscomponentclinic doctorcomponentperf_hookscomponentmonitorEventLoopDelaycomponent--inspectcomponentChrome DevToolscomponentheap snapshotsconceptcallback queuecomponentJavaScript threadcomponentCPU profilercomponentreplicacomponentsingle-threadedconceptdistributed tracingcomponentSSRconceptChild Processescomponentfs.readFileSync()componentgarbage collectionconceptfs.promisescomponentPromise.allcomponentp-limitcomponentprom-clientcomponentClinic.jscomponentsetImmediate()componentSocket.IO cluster adaptercomponentWebRTC data channelsprotocolPeerJScomponentSocket.IOcomponentuWebSocketscomponentNagle's algorithmprotocolRelated Insights (48)
Synchronous logging blocks event loop in productionwarning
▸
Live debugging with Inspector pauses event loop and halts trafficcritical
▸
Event loop lag exceeds 10-20ms thresholdwarning
▸
Synchronous file system calls block event loopwarning
▸
Synchronous operations block event loop and tank throughputcritical
▸
Legacy Node.js versions reduce event loop efficiencywarning
▸
Prisma transaction timeouts due to event loop blockingcritical
▸
Nested loop over large datasets blocks event loopcritical
▸
Large unpaginated datasets cause resource exhaustioncritical
▸
Synchronous JSON parsing causes event loop lagwarning
▸
Monitor event loop blocking with async_hooksinfo
▸
High event loop lag degrades API responsivenesswarning
▸
Synchronous CPU-bound operations block event loopcritical
▸
Synchronous file I/O blocks event loop in productioncritical
▸
Poorly optimized database queries delay callback executionwarning
▸
100% CPU utilization prevents event loop processingcritical
▸
Synchronous loops block event loop causing application unresponsivenesscritical
▸
CPU-intensive tasks starve event loop requiring worker threadswarning
▸
Large file processing causes memory exhaustion and event loop lagwarning
▸
Request floods from APIs or WebSockets overload serverwarning
▸
Heavy third-party dependencies bloat application and degrade performancewarning
▸
Event loop lag detection requires monitoring toolinginfo
▸
Memory leaks indirectly cause event loop lagwarning
▸
Event loop blocking causes request latency spikes under concurrent loadcritical
▸
Event loop 100% utilization causes request latency spikes and timeoutscritical
▸
Synchronous CPU-intensive operations block event loop and cause latencycritical
▸
Horizontal scaling mitigates event loop starvation when under-provisionedwarning
▸
Event loop blocking misdiagnosed as downstream service latencywarning
▸
Response timer includes event loop wait time in observed latencyinfo
▸
Callback queue flooding from high request volume causes event loop starvationwarning
▸
Synchronous middleware operations block event loop causing throughput degradationwarning
▸
CPU-intensive tasks block event loop causing request delayscritical
▸
Synchronous file system calls stall event loopcritical
▸
Memory leaks cause garbage collection pauses and event loop latencywarning
▸
Event loop lag indicates delayed task executionwarning
▸
Poorly written dependencies introduce blocking operationswarning
▸
Event loop congestion causes severe response time degradation at scalecritical
▸
Synchronous file I/O blocks event loopwarning
▸
Unbatched concurrent promises cause event loop delayswarning
▸
CPU-intensive operations block event loop for secondscritical
▸
Event loop blocking causes health check failures and pod restartscritical
▸
Event loop lag over 300ms causes API response time degradationcritical
▸
Single-threaded Node.js process saturates one core despite multi-core availabilitycritical
▸
High-frequency real-time broadcasts flood event loop with micro-taskswarning
▸
Socket.IO abstraction overhead reduces throughput under high loadwarning
▸
Small default semi-space heap size causes frequent GC pauseswarning
▸
Nagle's algorithm batches TCP packets causing latency spikeswarning
▸
Node.js struggles to use more than 50% of single CPU before event loop laginfo
▸