How to deploy FastAPI + Celery + Redis
I have a fastapi application currently deployed on railway (ID: 7ed272ed-0bdc-4780-9bc1-4f3c12fc5779) that heavily relies on background tasks to perform time-consuming operations in the background.
I am working to restructure the deployment such that it uses celery for task queues and redis as the broker/backend.
How do I ensure that the celery server, the redis server (using docker image), and the fastapi server all integrate appropriately on the railway deployment?
8 Replies
Project ID:
7ed272ed-0bdc-4780-9bc1-4f3c12fc5779
i dont know how youd do it, but i do know you will need 3 railway services
yea that was my intuition so far...
ideally, I'd be able to use the redis db service (instead of docker image) on railway and my gh-deployment for the fastapi server, the celery server is the one I'm less sure about how to configure
what are you unsure about?
mainly, about how to configure the celery worker to start and connect to the redis service within railway. I also want to figure out if I would indeed need three services or possibly just the fastapi server and the redis service, then running a startup command on fastapi server to initialize celery. I have not used celery much before so i'm unsure of what it'll take for it to behave correctly in production
you 100% would need 3 services
like i said, that was my initial intuition but i'm unclear on why and how to ensure they integrate correctly, could you help me understand how to configure them?
I sure wish I could, I'm not a python dev 😦