Performance: Health checks (Terminus)
MEDIUM IMPACT
Health checks impact server responsiveness and uptime monitoring, indirectly affecting user experience by ensuring service availability.
import { TerminusModule, HealthCheckService, HealthCheck } from '@nestjs/terminus'; import { Controller } from '@nestjs/common'; @Controller('health') export class HealthController { constructor(private health: HealthCheckService) {} @HealthCheck() check() { return this.health.check([]); // lightweight async checks } }
import { Controller, Get } from '@nestjs/common'; @Controller('health') export class HealthController { @Get() check() { // Synchronous heavy operation const result = heavySyncCheck(); return { status: result ? 'ok' : 'fail' }; } } function heavySyncCheck() { // Simulate CPU intensive task for (let i = 0; i < 1e8; i++) {} return true; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous heavy health check | 0 | 0 | 0 | [X] Bad |
| Asynchronous Terminus health check | 0 | 0 | 0 | [OK] Good |