I am creating a python project using fastapi framework. There are multiple I/O operations in my project including two mssql calls and one databrick call using jdbc driver. The I/O operations taking too much time and the main thread is getting blocked due to this. I tried creating a thread pool and offload the blocking operations to the pool itself. That seems to work and not blocking main thread itself. But under load the cpu utilisation is going through the roof and the server stops responding. The reason am creating the pool in the first place because I haven’t found any async version of the mssql and databrick drivers. The project is deployed in kubernetes and the pod cpu and memory limits are 5000m and 2048Mib. The kubenetes cluster has 5 nodes with 32 vcpu each. I am using Gunicorn with 4 async uvicorn worker and in the application the threadpool size is 10. Even with autoscaling on the pods are failing. Even in the local machine under certain load the cpu utilisation is very high and after sometime the api stops processing request.
- Is there any way of accessing the mssql and databrick asynchronously ?
- And if there is no async library available for mssql and databrick for python how can I keep the cpu utilisation under control when I am offloading the I/O operations to the thread pool.
Thanks in advance