altairbow / django-db-connection-pool

Database connection pool component library for Django
https://pypi.python.org/pypi/django-db-connection-pool/
MIT License
181 stars 24 forks source link

Django doesnt respect the pool configuration when using "gevent" class #51

Closed vaibhavnsingh closed 8 months ago

vaibhavnsingh commented 10 months ago

Issue : After setting all the pre-requisites with below configuration

'POOL_OPTIONS' : { 'POOL_SIZE': 10, 'MAX_OVERFLOW': 10, 'RECYCLE': 24 60 60 }

If i run below command

gunicorn your_project_name.wsgi:application -k gevent -w 4

My assumptions is it will use pool_size which I have set to 10. But I see DB connections going high based on the number of concurrent request.

altairbow commented 8 months ago

django-db-connection-pool does not support coroutine.

hosler commented 5 months ago

What would it take to support coroutines?

YPCrumble commented 3 months ago

@altairbow does the fact that this library doesn't support coroutines mean that if we set "POOL_SIZE": 10 with four gunicorn workers as in the example above, that this will essentially create up to 40 connections? So that we should set our desired number of connections to that number divided by the number of available workers?

Or does this mean that this library does not support gunicorn async workers at all? Or something else?

Thanks for maintaining this really interesting library, and thank you for your help understanding how it works!

hosler commented 3 months ago

I did a little testing on my own, and this library appeared to work fine with gevent. I am using oracle and had to greenify the oracle lib. I also looked into sqlalchemy and it appears to be OK with coroutines. this is ongoing research on my end so I would appreciate some input on this analysis.

@YPCrumble if you dont use a green db driver with gevent and this lib your gevent worker will block while the first connection is used. with pool size of 10, this library will spin up 10 connections per worker but only actually use 1 of them per worker.