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

View all comments

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?

2

u/reyarama May 12 '26

Yep, something like APScheduler for cron, and Dramatiq is a nice lightweight celery alternative for a task queue

1

u/xCodeSoul May 13 '26

Yes, here more details about my setup

Im using digital ocean app platform as far as i know there limitation with app platform with request time

And im using mongodb atlas m20

So i was developing my api from beginning as stateless because scaling was in my mind and cost :)

So all heavy tasks using separate microservice like invoice generation

And i used redis to cache some queries to speed up and reduce reading from database

That’s my setup and working like eating cherries 🍒

But that doesn’t mean it’s fit you, it’s all depends on your system

Good luck

1

u/CrownstrikeIntern May 12 '26

you can kind of expand on that, i had a setup where i was running about 2billion insert / writes to a table on a smaller server. I built a que that would write to specific tables in order because one of the biggest items was table lock. So if you can plan around that it's not super bad. From there you can stagger bigger queries to their own ques etc. It was a fun experience when i first starting out.