Workers & queues · 2026

Your AI app times out at 30 seconds.
The background worker, explained for founders.

If your app freezes on slow tasks, returns 502s, or charges a card before the work finishes, you are missing a background worker. Here is what that is.

Run your worker next to your app.

On Belmo Pro you add a background worker to a service from the dashboard, with no proxy or process manager to configure, and AI log monitoring sends you a Telegram alert when it starts failing.

No credit card required 1 service free forever Background workers on Pro Telegram alerts built in
Frequently asked

Quick answers

Why does my app return a 502 or 504 after 30 seconds?

A reverse proxy or load balancer sits in front of almost every production app and stops waiting after roughly 30 seconds. Your code may still finish the work, but the user's connection is already gone and they see an error. On your laptop there is no proxy, which is why it works locally.

What is a background worker?

A second process that runs the same code against the same database and only handles slow jobs. The web request writes a job to a queue ("generate PDF for user 8842") and returns immediately. The worker picks the job up and takes as long as it needs, because no proxy is timing it.

Do I need Redis for a job queue?

No. The simplest queue is a table in the database you already have, with a status column. Workers claim jobs with SELECT ... FOR UPDATE SKIP LOCKED so two workers never take the same row. Libraries like Celery, RQ, BullMQ or Sidekiq add retries and conveniences on top of the same idea.

What does it mean for a job to be idempotent?

That running it twice does no harm. A worker can crash after doing the work but before marking the job done, so the job runs again. Check whether the email was already sent, and use idempotency keys for payments, so the second run changes nothing.

How do I know if my background worker died?

Watch queue depth, not just the process. A scheduled query that counts pending jobs older than five minutes and alerts you when the count is above zero catches a dead worker, a worker that is too slow, and a job type that is jamming the line.