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
Percy
Percy•15mo ago
Project ID: 7ed272ed-0bdc-4780-9bc1-4f3c12fc5779
Brody
Brody•15mo ago
i dont know how youd do it, but i do know you will need 3 railway services
chancellorofwonder
chancellorofwonderOP•15mo ago
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
Brody
Brody•15mo ago
what are you unsure about?
chancellorofwonder
chancellorofwonderOP•15mo ago
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
Brody
Brody•15mo ago
you 100% would need 3 services
chancellorofwonder
chancellorofwonderOP•15mo ago
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?
Brody
Brody•15mo ago
I sure wish I could, I'm not a python dev 😦
Want results from more Discord servers?
Add your server