Performance: Response time optimization
HIGH IMPACT
This concept affects how quickly the server responds to user requests, impacting the time users wait before seeing any content.
app.get('/data', async (req, res) => { const data = await fastDatabaseQuery(); res.send(data); });
app.get('/data', (req, res) => {
const data = slowDatabaseQuery();
res.send(data);
});| Pattern | Event Loop Blocking | Response Delay | Server Throughput | Verdict |
|---|---|---|---|---|
| Synchronous DB query | High | High | Low | [X] Bad |
| Asynchronous DB query | Low | Low | High | [OK] Good |
| Synchronous file read | High | High | Low | [X] Bad |
| Streaming file response | Low | Low | High | [OK] Good |
| CPU-heavy sync task | High | High | Low | [X] Bad |
| Worker thread offload | Low | Low | High | [OK] Good |