All projects

Backend job queue

Async Job Processing.

A production-style async job system in TypeScript — Express API, Postgres-backed job store, Redis coordination, and workers with leases, heartbeats, idempotency, and a dead-letter queue.

Case study

The problem

Background jobs are where backends quietly break: workers die mid-task and leave work stuck, retries process the same job twice, and failures go unnoticed until customers complain.

What I built

A TypeScript job system built for failure from the start. An Express API enqueues jobs into a PostgreSQL-backed store; Redis coordinates a pool of workers that claim work with leases and heartbeats, so no job stays stuck on a dead worker. Idempotency keys and fencing tokens make retries safe to re-run; poisoned jobs land in a dead-letter queue with manual retry. Prometheus metrics and Grafana dashboards expose throughput and failure rates, everything runs via docker-compose, and load-test scripts verify behavior under pressure.

Results

  • Lease + heartbeat model — zero stuck jobs
  • Safe retries via idempotency keys & fencing tokens
  • DLQ with manual retry + full observability

Highlights

  • Worker leases with heartbeats and automatic recovery
  • Idempotency keys, fencing tokens, and dead-letter queue
  • Prometheus metrics + Grafana dashboards, Redis coordination

Tech stack

TypeScriptExpressPostgreSQLRedisDocker

Key facts

DLQ + retriesPrometheusLoad tests