Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Pooling for Django Project #2

Open
Keda87 opened this issue Jun 2, 2021 · 4 comments
Open

Connection Pooling for Django Project #2

Keda87 opened this issue Jun 2, 2021 · 4 comments

Comments

@Keda87
Copy link

Keda87 commented Jun 2, 2021

Hi @nickjj, thank you for making this repository. I would have a look at this repo for my reference.
I'm looking for a Django project example that uses connection pooling (pgbouncer or pgpool) but seems like this repo does not use this.

My concern is because Django's DB connection is created during the request and closed after returns the response. this based on the documentation https://docs.djangoproject.com/en/3.2/ref/databases/#general-notes

I think using connection pooling would make this project better for production-ready project reference.

Thank you in advance

@nickjj
Copy link
Owner

nickjj commented Jun 2, 2021

Hi,

Have you run into a scenario where not using pgbouncer resulted in issues? Do you have an example of a configuration for it that's been known to work with a before / after comparison?

@Keda87
Copy link
Author

Keda87 commented Jun 4, 2021

Ohh ya, not yet for now.
Will get back to you after I create a load test result.

@55nevets
Copy link

I'm interested in this too. I don't see this in the django-cookiecutter setup either so maybe not that important?

@nickjj
Copy link
Owner

nickjj commented Nov 26, 2021

There's pros and cons. I'm not a DBA but my surface level understanding is for single threaded applications (such as running gunicorn with 1 thread and X workers) DB pooling may slow things down.

Realistically I can only trust the results I've seen in production. I've had single low powered servers happily serve hundreds of thousands of requests per month in Flask apps. DB connections weren't a bottleneck. Flask is similar enough to this Django app, both frameworks are using gunicorn with PostgreSQL using the psycopg2 package.

I've never operated a site that receives hundreds of millions of daily requests. Maybe it's an issue then, my philosophy around that is I'll figure it out when it happens instead of trying to optimize for it now where it looks like it would provide worse results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants