I’m running two instances of FastAPI apps on the same Ubuntu EC2 server. One app is for staging and one app is for production. The server has 4 VCPUs. I’m using Nginx as a reverse proxy.
The FastAPI app would run a web app then let the user upload a file then process it in the background then send an email to the user telling him that the file has been processed, therefore each fastAPI app needs at minimum 2 workers, one to run the app and one to run the background job, otherwise the app would not work correctly.
This question has been asked before, and the answer was, in the case of VCPUs, you should have as many workers as VCPUs, so in my case 4 workers because I have for VCPUs
But my questions are:
-
Is it 4 workers per app? so 8 workers in total? or 4 workers in total? so 2 workers per app? I have 2 apps and I’m not sure what to do
-
Are you sure that multiple workers is the way to go? My app runs some FFMPEG tasks and then runs an AI model. I might be hallucinating, but it seems that if I run multiple workers, each worker is repeating the same task, the email is being sent once but FFMEG and the AI model seem to run as many times as I have workers, per file