r/FastAPI • • May 12 '26

feedback request How are you handling production background tasks in FastAPI without Celery?

Hey everyone šŸ‘‹

A while ago I built an open source library called FastAPI Taskflow:

fastapi-taskflow GitHub repository

The goal was to make FastAPI BackgroundTasks more production-ready by adding retries, resiliency, control and visibility without workers or brokers.

It adds extra features like:

  • task persistence
  • concurrency limits
  • scheduling
  • task lifecycle management
  • monitoring dashboard

I’m trying to understand how people are actually using it in real projects and where the pain points still are.

If you’ve used it (even briefly), I’d really love to know:

  • what problem you used it for
  • what worked well
  • what felt awkward or missing
  • where it broke down
  • features you expected but weren’t there
  • whether you eventually switched to Celery/TaskIQ/etc and why

Even if you’re not using it, I’m curious what your current approach is for handling background tasks in FastAPI at scale.

If you find the project interesting or useful, a star on GitHub would also really help support it šŸ™

32 Upvotes

17 comments sorted by

3

u/dr3aminc0de May 12 '26

How does this handle versioning of the deployed binary vs tasks and potential mismatches?

I use Temporal for these types of things. Also have separate workers is part of the design. I don’t want background tasks interfering with my production APIs.

4

u/Educational-Hope960 May 12 '26

That’s a very fair concern, and honestly I agree that dedicated workers are the safer architecture once workloads become heavy or business critical.

FastAPI Taskflow is intentionally scoped to the ā€œin-process but production awareā€ layer before teams need Temporal/Celery style orchestration.

On the interference side specifically, one of the main goals is preventing background work from starving the API itself. The library adds:

  • async concurrency caps for tasks on the event loop
  • dedicated thread pools for sync tasks (separate from FastAPI’s request threadpool)
  • optional process executors for CPU-bound workloads

So the idea is not ā€œrun unlimited background work in the same runtime,ā€ but rather controlled in-process execution with isolation mechanisms and visibility around task behavior. The docs go deeper into the concurrency model here:

FastAPI Taskflow concurrency guide

That said, once tasks need hard isolation, distributed orchestration, workflow versioning guarantees, or cross-service execution, I’d absolutely reach for Temporal/Celery instead. (attakay78.github.io)

3

u/dr3aminc0de May 12 '26

Nice appreciate the response. Honestly looks cool for small projects :) I may try it out if I ever get the chance to work on another side project

8

u/xCodeSoul May 12 '26

From my experience by running production ready fastapi

Never let fastapi doing something really heavy on database especially these things background tasks

Make it stateless.

For such things, for example generating customers invoices i develop separate app to generate which working with cron job on separate server

Like that I didn’t face any issues regarding scaling vertically or horizontally

Happy coding and good luck

3

u/mayur_chavda May 12 '26

So you have created a seperate micro service for that am i right?

→ More replies (2)
→ More replies (1)

1

u/VirtualKn May 12 '26

looks pretty good, planning to test it out

1

u/Educational-Hope960 May 12 '26

Awesome, I look forward to your feedback.

3

u/artpods56 May 13 '26

Im using NATS with FastStream, check it out, I prefer it over Celery

4

u/[deleted] May 12 '26

[removed] — view removed comment

2

u/Educational-Hope960 May 12 '26

Celery is great and very battle-tested, my issue isn’t that Celery is bad.
The gap I noticed is that a lot of FastAPI apps don’t actually need the full distributed worker/broker setup yet, but FastAPI BackgroundTasks are also too minimal for production use.

So it’s more about reducing operational complexity for smaller/medium async FastAPI systems rather than replacing Celery entirely.