I'm part of a Django project where we make many API calls to external services using the requests and zeep libraries. These calls are done sequentially and our API heavily relies on their immediate responses.
However, when our server experiences high traffic, it stops responding. It seems like all our workers become occupied, waiting for these external network calls to finish, leaving no workers available to process new incoming requests.
The project is large and converting the entire project to asynchronous isn't currently feasible. Furthermore, because of our need for immediate responses from these API calls, using a task queue system like Celery is not a solution.
As we anticipate even more traffic in the future, I'm looking for a solution that can efficiently handle these blocking network calls without blocking our server or requiring a complete rewrite to asynchronous.
I increased the number of gunicorn workers using 2*CPU+ 1 formula, but that might not be enough in the future.