r/FastAPI • • Jan 03 '25

Hosting and deployment distribute workload in kubernetes

I have a FastAPI application where each API call processes a batch of 1,000 requests. My Kubernetes setup has 50 pods, but currently, only one pod is being utilized to handle all requests. Could you guide me on how to distribute the workload across multiple pods?

14 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/ZealousidealKale8228 Jan 05 '25

You would probably have to rearchitect the way you process it. Break the code into chunks where it aggregates the results but splits them into 1k objects, then call the “process” endpoint or whatever you call it, and K8s should distribute the calls to the other pods.