Your API times out on heavy work Background jobs in 30 days

For applications doing heavy work in API request handlers, like sending emails, processing uploads, and generating reports, that should run in the background. Most platforms cut you off long before that work finishes: serverless functions have hard time limits, and gateways return a 504 well before a long PDF render completes.

  • Working proof in 30 days
  • Fixed scope and timeline
  • 30 days From kickoff to production delivery
  • Week 1 Technical diligence and planning
  • Week 4 Production deployment and handoff

How it shows up

Report generation, email sending, file processing, and data exports should not block the user. Timeouts, lost work, and invisible failures. The longer you run heavy work in request handlers, the worse it gets.

The synchronous bottleneck

Your report endpoint crawls. Your CSV export times out on big files. Email sending adds seconds to every API response. Image processing blocks the request until it finishes. Users stare at spinners or get a 504 FUNCTION_INVOCATION_TIMEOUT. All of this work should run on a separate worker with status updates and retry logic, but your app has no job queue, so the request thread does the work it was never meant to do.

Timeout-driven user frustration

A user exports a big CSV. The request runs long and the gateway times out. The user retries. Now two exports run simultaneously. One succeeds and the other corrupts. The user gets half a file and opens a support ticket. With background jobs, the user clicks export, sees a progress bar, and downloads the file when ready.

Lost work with no recovery

An email send fails because the SMTP provider had a brief outage. The email is gone. The user never gets their password reset, invoice, or onboarding sequence. With a job queue, the failed send retries automatically with exponential backoff (1s, 2s, 4s) plus jitter so a fleet of workers does not retry in synchronized waves, and the second attempt succeeds.

Invisible failures in production

A scheduled data sync runs in a setTimeout callback. It fails silently at 2am, and the next deploy restarts the process and wipes the timer entirely. Nobody notices until a customer reports stale data days later. There are no logs, no alerts, and no retry. With proper job infrastructure, every run is durable, logged with status and duration, retried on failure, and alerted on.

Who it is for

Best for applications doing heavy or unreliable work inside API request handlers.

Best fit

You have a production application where some requests take too long, fail without recovery, or run heavy work synchronously.

  • API endpoints that timeout on report generation or data exports
  • Email or notification sending that blocks request responses
  • Scheduled tasks running in cron jobs or setTimeout with no monitoring

What happens without background job infrastructure

As your product grows, synchronous processing becomes the single biggest source of timeouts, lost work, and user complaints.

Scale makes it worse

With a few users, slow endpoints are annoying. As you grow, concurrent report generation saturates your server. The API slows down for everyone because a handful of users are generating PDFs and Puppeteer is pinning every CPU core. With a job queue, heavy work runs on separate workers with bounded concurrency, the request thread frees up immediately, and the API stays fast no matter how much background work is queued behind it.

Unreliable scheduled work

Your nightly data sync runs in a cron job with no retry logic. When it fails, the data is stale until someone notices and re-runs it manually. Each failure erodes trust in the data pipeline.

Feature development bottleneck

Every new feature that involves heavy processing requires workarounds: polling endpoints, manual retries, client-side timeouts. A proper job queue makes heavy features straightforward to build and reliable to operate.

What we do in 30 days

From synchronous timeouts to a production job queue with retry, scheduling, and monitoring in 30 days.

  1. Days 1-5: Job architecture design

    Audit all synchronous heavy work in your codebase. Categorize by type: fire-and-forget (emails), user-initiated (exports, reports), scheduled (syncs, cleanup), and event-driven (webhooks). Select the job framework based on your deployment model: BullMQ on Redis for dedicated workers, pg-boss on Postgres SKIP LOCKED if you want no extra infrastructure, Inngest or Trigger.dev for serverless. Design the job type schema, set retry caps (typically 3-5 attempts), and split non-retryable failures (4xx, malformed payloads) so they fail fast to the dead letter queue instead of burning the retry budget.

  2. Days 6-14: Core job infrastructure

    Job queue deployed with Redis or Postgres backing. Your heaviest endpoints migrated to async: user clicks, gets a job ID, polls for completion. Retry logic with exponential backoff and jitter configured per job type. Handlers made idempotent so the at-least-once delivery model never double-charges or double-sends on a retry. Proof release: your slowest endpoint returns instantly while work processes in the background.

  3. Days 15-30: Complete system

    Remaining synchronous work migrated to background jobs. Scheduled job runner for recurring tasks (cron-like). Dead letter queue for permanently failed jobs with admin replay, treated as a monitoring signal: rising DLQ depth means your processing SLO is breaking, not just a place where failures pile up. Job monitoring dashboard showing queue depth, p50/p95 processing time, failure rates, and retry status. Alert triggers for failed jobs and queue backlog.

What you get

A production job queue system, not a setTimeout with hope.

Shipped deliverables

Complete background job infrastructure with retry logic, scheduling, and monitoring.

  • Job queue with BullMQ, pg-boss, or Inngest (based on your stack)
  • Async processing for all heavy endpoints with status tracking
  • Retry logic with exponential backoff per job type

Why Pineido

We run background job systems in our own production applications.

Production job queue experience

We have built job systems for production load across multiple SaaS products. We know that BullMQ leans on Redis Lua scripts and pipelining for its throughput, and that it needs connection pooling and maxRetriesPerRequest tuning when you point it at Upstash. We know that pg-boss rides Postgres SKIP LOCKED for exactly-once delivery and is the better call when you want to avoid running Redis at all. We know that Inngest invokes each step over HTTP and checkpoints it, so a long job survives a mid-run deploy, which makes it the right choice for serverless on Vercel where every function has a time cap. We choose the tool based on your deployment, not our preference.

What people ask us first

BullMQ vs pg-boss vs Inngest: which should we use?

BullMQ with Redis for Node.js apps with dedicated worker processes, because its Lua-script and pipelining design gives it the highest throughput and it is the most mature. pg-boss if you want to avoid Redis and already use Postgres, since SKIP LOCKED gives you a reliable queue with one less piece of infrastructure, at a lower throughput ceiling that is irrelevant for most apps. Inngest or Trigger.dev for serverless on Vercel, where steps run over HTTP, no worker servers are needed, and pricing is per run. We recommend during day 1.

How do users know when background work is done?

We implement job status polling with a lightweight endpoint. The UI shows progress state (queued, processing, complete, failed) with optional progress percentage for long-running jobs. For critical notifications, we add real-time updates via WebSocket or Server-Sent Events.

Can this handle scheduled recurring tasks like cron?

Yes. Recurring schedules with cron syntax: nightly data syncs, weekly reports, hourly cleanup. Each run is logged with status, duration, and output. Failed runs retry automatically and trigger alerts. No more cron jobs running on a single server with no monitoring.

How do you handle job failures and retries?

Transient failures retry automatically with exponential backoff and jitter so workers do not retry in synchronized waves. Permanent failures, like a 4xx response or a malformed payload, fail fast straight to the dead letter queue instead of burning all 3-5 attempts. After the retry limit is reached, the job moves to the dead letter queue with its error, stack, and payload identifiers for safe replay. Your admin dashboard shows failure reasons, retry counts, and processing duration so you can identify and fix systemic issues.

Can background jobs scale with traffic spikes?

Yes. Worker concurrency is configurable per queue priority. High-priority jobs like payment processing run immediately. Low-priority jobs like report generation queue behind them. On serverless platforms like Inngest, workers scale automatically with no infrastructure management.

What types of work should move to background jobs?

Any operation that takes more than 500ms, or that calls a flaky third party, should run in the background: PDF generation with Puppeteer, email sending, image processing, third-party API syncs, and large data exports. Anything that risks crossing your platform timeout belongs there regardless of average duration. Your API responds instantly with a job ID while the work processes asynchronously. Users get notified when their job completes.

30 days From kickoff to production delivery

Stop timing out on heavy work

Every synchronous timeout is a frustrated user and lost work.

Fixed price.

You leave with

  1. Day 1: Audit all synchronous heavy work and categorize by type
  2. Day 5: Job framework selected, retry policies designed

ByFounder and Imaginator

Published Updated