Deployment · By Rivtor · Updated
Prepare FastAPI, Celery and Redis for deployment
FastAPI accepts HTTP requests, Celery processes background tasks and Redis can carry queued work. Run the API and worker separately and verify that both use the intended queue and broker.
See the Rivtor deployment workflow →
Separate requests from jobs
Return a job identifier instead of holding an HTTP request open during a long task. Give the worker an independently startable entrypoint and the correct dependency manifest. Starting a worker inside every API process can unintentionally multiply consumers.
Agree on broker configuration
Producer and consumer must share queue names, serialization settings and broker configuration. Read credentials from the environment and use the documented network endpoint. Redis queue state is not a substitute for a durable business record when losing a message would lose important work.
Design for retries
Expect repeated delivery. Use a business identifier to avoid duplicate irreversible actions, bound retries and set task timeouts. Separate invalid input from temporary provider failures. A retry loop that repeats an unsafe operation can cause more damage than the original failure.
Verify actual completion
Submit a harmless job, observe its worker log and read the result through the API. The API being healthy does not establish that a worker is listening. Confirm current workload support and plan limits before using a persistent background process in production.
Command reference
celery -A tasks worker --loglevel=info
These commands illustrate the documented workflow. Replace example addresses and identifiers with your own. Deployment and migration commands affect the selected project; confirm the target before running them.
Prove the producer and worker agree
The API and Celery worker must import the same task definitions and use the intended broker and queue. An illustrative startup command is:
celery -A tasks worker --loglevel=INFO
Replace tasks with your actual module or Celery application path. Declare celery and the required Redis integration in the worker's dependencies. A scheduler such as Celery beat is a separate process; multiple schedulers can enqueue duplicate periodic work.
Follow one synthetic task end to end
Submit a harmless test job, record its task ID, and check that the worker receives and completes it. If your application uses a result backend, confirm that result retrieval works independently from broker delivery. Pending can mean an unconsumed task or an unavailable result, depending on the application.
Use separate diagnostic steps for a missing task import, broker authentication failure, mismatched queue name and a task exception. Do not assume Redis connectivity proves worker execution.
Plan retries and shutdown
Use an idempotency key or equivalent application design when a task can be delivered again. Configure timeouts and resource limits for the workload; do not let a web request wait indefinitely for a long job. Verify termination behavior on a disposable task before relying on graceful shutdown.
Check framework support, Redis configuration and hosting cost accounting. Source: Celery first steps.
Next steps
Read the Rivtor reference for supported configuration and limitations, and use the deployment quickstart when trying Rivtor for the first time. Validate workflows with synthetic data before connecting valuable production records.