Performance: Health check endpoints
Health check endpoints affect server responsiveness and overall user experience by providing quick status feedback without heavy processing.
app.get('/health', (req, res) => { res.json({ status: 'ok' }); });
app.get('/health', (req, res) => { // Simulate heavy DB query or complex logic const data = heavyDatabaseQuery(); res.json({ status: 'ok', data }); });
| Pattern | Server Load | Response Time | Event Loop Blocking | Verdict |
|---|---|---|---|---|
| Heavy synchronous logic in health check | High | Slow | Blocks event loop | [X] Bad |
| Simple static response | Minimal | Fast | Non-blocking | [OK] Good |
app.get('/health', (req, res) => {
res.status(200).send('Service is up');
});app.get('/health', (req, res) => {
res.sendStatus(200);
res.send('OK');
});Pass the test and this pattern moves unknown