Backend & APIs

Queues, Background Jobs & Event-Driven Systems

Patterns and tools for moving slow or unreliable work out of user requests and connecting services through messages and events.

What Queues, Background Jobs & Event-Driven Systems is

Background jobs run work asynchronously outside the request-response cycle, typically pulled from a queue by worker processes. Event-driven systems go further by having services publish events that other services react to, using brokers such as RabbitMQ, Kafka, cloud queues or Redis-based job libraries.

What it solves

  • Slow user requests caused by emails, file processing, reports or external API calls
  • Lost work when an external service fails, by adding retries and dead-letter handling
  • Load spikes, by buffering work and processing it at a controlled rate
  • Tight coupling between services that should evolve independently

When it makes sense

  • Sending emails, notifications and webhooks
  • Generating reports, exports, thumbnails or document processing
  • Scheduled tasks such as billing runs and data synchronization
  • Systems where several components react to the same business event

Strengths

  • Faster, more resilient user-facing requests
  • Retries, backoff and failure isolation for unreliable dependencies
  • Independent scaling of workers according to workload
  • Looser coupling and an audit-friendly history of events

Limitations

  • Adds infrastructure (brokers, workers) that must be operated and monitored
  • Eventual consistency makes reasoning and debugging harder
  • Jobs must be designed to be idempotent because retries can run them more than once
  • Message ordering and schema evolution need explicit handling

Alternatives, and when they are better

  • Synchronous REST calls

    Direct synchronous calls are simpler and sufficient when work is fast, the user needs the result immediately and the dependency is reliable.

  • Database-backed job tables

    For small products, a job queue stored in PostgreSQL avoids running a separate broker while still providing retries and transactional enqueueing.

  • Managed workflow services

    Managed workflow or orchestration services can be better for long, multi-step business processes that need visual state tracking and built-in timeouts.

Practical examples

  • An e-commerce order flow where payment confirmation triggers invoicing, stock updates and shipping notifications as separate jobs
  • A data import that processes large uploaded CSV files in the background and reports progress
  • A nightly synchronization job between an internal system and an external CRM

How it fits into the product architecture

Queues sit between the API layer and worker processes, and between services that exchange events. The API writes to the database and enqueues work; workers consume messages, call external systems and record results. Operationally this adds queue depth, processing latency and failed-job metrics to monitoring, plus dead-letter handling and alerting for jobs that repeatedly fail.

Next step

Choosing a stack for a new product?

We start from requirements, costs of ownership and the team you will have, then recommend technology with the reasons written down.