A slow operation belongs in background processing when the user should not have to keep a request open until it finishes. Moving work out of the request also creates a new promise: the application must remember the job, report its state, and deliver the result to the right person.
Choose that promise before choosing a queue product. A fast acknowledgement is misleading if the work can disappear after the web process exits.
Define what the acknowledgement guarantees
Distinguish input validated, job durably accepted, execution started, and result available. Show users the state that is actually established. A spinner saying processing should not conceal whether the system has recorded the request at all.
Include the tenant, resource, initiating actor, operation identity, input reference, status, and retry context appropriate to the job. Avoid copying unnecessary private payloads into broadly accessible queue diagnostics.
Design a fictional report-generation job
Suppose a founder requests a report from several customer studies. The application validates access, records the job, and returns a status view. A worker builds the report, stores it, and marks it ready for authorised download.
Test a worker crash before processing, during generation, and after the file is stored but before completion is recorded. Test a repeated request, a deleted study, and membership removal before download. The final behaviour should avoid duplicate reports or inappropriate access under the chosen policy.
Some work can safely retry; some cannot. Rebuilding a deterministic report differs from charging a payment method or sending an external message. Identify the side effects and their duplicate controls before applying a generic retry policy.
Keep status and recovery useful to humans
Expose pending, running, complete, failed, and cancelled states only where they have defined meaning. A stuck running job needs a recovery rule. A permanent input error needs a useful explanation rather than endless automated retries.
Support should be able to find a job through a safe reference, identify the last completed step, and determine whether another attempt could duplicate a side effect. Important manual retries should retain the real staff actor and reason.
The tradeoff is user responsiveness versus operating complexity. Synchronous work is simpler for short, bounded operations. Background work can survive longer tasks and smooth load, but adds persistence, scheduling, status, and failure-recovery responsibilities. Do not add it merely because queues are common in larger systems.
The StackFlight portfolio account provides related study-and-export context. This report job is a proposed design exercise, not a description of its internal infrastructure.
Questions about SaaS background jobs
Is returning success before work finishes acceptable?
Yes, if success means durable acceptance and the interface clearly distinguishes that from completion. The product must provide a way to observe the result.
Can every failed job be retried automatically?
No. Separate temporary failures, invalid inputs, and operations with consequential side effects. Define the retry behaviour for each.
What should a first review include?
Include crash points, repeated execution, permission changes, status recovery, and result ownership. Bring the state model to a background-work review.