Home / Docs

Documentation

How DiffMon works across monitoring, alerts, security, and API integration.

Worker orchestration

How the worker schedules monitors, handles retries, and coordinates locks.

Worker orchestration

The worker pulls jobs from Redis-backed queues, enforces rate limits, and writes snapshots atomically.

Scheduling

  • Each monitor stores nextRunAt; jobs are enqueued accordingly.
  • Locks prevent double-processing when multiple workers run.
  • Grace windows adjust cadence automatically based on plan state.

Retries

  • Transient errors are retried with exponential backoff and jitter.
  • Retry-After headers on 429 are honored before continuing.
TypeScript
for (let attempt = 0; attempt <= retryMaxAttempts; attempt++) {
  last = await attemptOnce();
  if (!last.error && last.statusCode && last.statusCode < 400) break;
  const backoff = retryBaseDelayMs * Math.pow(2, attempt);
  await sleep(Math.min(backoff + Math.random() * retryBaseDelayMs, 30_000));
}

Processing pipeline

  • Fetch target → normalize → hash → compare → write snapshot/diff → send alerts/webhooks → update health.
  • Health evaluation uses recent snapshots to avoid flapping.