New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
FastAPI's background tasks vanish on every redeploy. I need a job that survives one.
What you'll have at the end
A worker running in its own process, outside your web app, that finishes a job you queued even though nothing was left running to receive it during a restart.
You need
A FastAPI endpoint whose slow part is already a plain function you can call directly, and a broker your code can already reach.
Not covered
Choosing which broker sits behind the framework, and making the job safe to run twice once it gets redelivered.
Leans on
Make a background job idempotent
go there once this job might run twice after a restart or a retry, since nothing here stops a repeat run from resizing the same photo again.
Move a slow task off the request and into a background queue
go there instead for the raw broker mechanics, with no framework wrapping the publish and consume calls for you.
Email new signups without blocking your response
reach for that instead when the job is small and truly fire-and-forget, since losing it occasionally would not matter.
Checked 19 Aug 2026
Part of the Background Job Processing Systems cookbook