Issue in DB pooling using cx_oracle and Flask (Python)

2/12/2020

We have develoed an APP using Angular 8 and flask-restplus(0.13.0) (Python 3.7.4) and cx_oracle(7.2.3). The Angular app is deployed on NGINX on Ubuntu server. We have created 3 micro services and have deployed it on gunicorn using docker and kubernetes pods. Production environment is having 7 kubernetes PODs per service. In Yaml file of kubernetes we have configured it to run on 4 threads using below command.

["gunicorn"]
  args: ["run_app:app","-b","0.0.0.0:8080","--threads=4","--access-logfile","-","--error-logfile","-"] 

The session pool code is as follows:

dbsession_pool = cx_Oracle.SessionPool('xxxxx', 'xxxxx', 'xxxxx.xxxxx.com/xxxxxdb', min=5, max=50, increment=5, threaded = True) 

All the services run for a while and then start giving 504 gateway timeout error after some time. But if we use cx_Oracle.connect then it works fine. Our reason to use session pool was to save time for connecting and disconnecting to DB thus improving performance.

-- Onkar Kubal
cx-oracle
flask-restful
gunicorn
kubernetes
oracle

0 Answers