Performance: Why routing matters
MEDIUM IMPACT
Routing affects server response time and how quickly the browser receives content, impacting page load speed and user interaction.
app.get('/user', async (req, res) => { const userData = await fetchUserData(); res.send(userData); });
app.use((req, res, next) => {
// heavy synchronous processing
for (let i = 0; i < 1e8; i++) {}
next();
});
app.get('/user', (req, res) => {
res.send('User page');
});| Pattern | Server Processing | Response Delay | Network Impact | Verdict |
|---|---|---|---|---|
| Blocking synchronous middleware | High CPU blocking | High delay | No impact | [X] Bad |
| Async route handlers | Non-blocking | Low delay | No impact | [OK] Good |