Django persistent database(postgres) connection.

93 views
Skip to first unread message

jai_python

unread,
Aug 27, 2010, 1:17:50 PM8/27/10
to Django users
Hi friends,
My django application runs in red hat server with apache &
mod_wsgi. We have several request which interacts with
database(postgresql), so database interaction is huge. i found that
every time django application establishing a new connection to
interact with DB. So my server hanging often due to large number of DB
connection (approximately some 200-250 connection/minute, it may
increase gradually)
Its very urgent. Hope I will get support here....
Thanks for looking my thread.


Thanks & Regards,
Jayapal D

Timothy Makobu

unread,
Aug 27, 2010, 2:35:37 PM8/27/10
to django...@googlegroups.com
Hi,
just a suggestion; try a different web-server system, like (uWSGI, gunicorn)+nginx,
then if you haven't already, do everything on this wiki http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

see if that helps.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Peter Herndon

unread,
Aug 27, 2010, 3:10:38 PM8/27/10
to django...@googlegroups.com

Hi Jayapal,

What you want is a connection pool for Postgres. Happily, such exists in the form of pgpool-2: http://pgpool.projects.postgresql.org/

The way it works is pgpool-2 runs as a separate daemon and spawns a configurable number of database connections. You configure pgpool-2 to listen for incoming database connections on whatever port you prefer, 5433 for example, and you tell it to talk to your database on e.g. port 5432. In your Django settings, you use the standard "postgresql_psycopg2" driver and tell it to connect to the database via port 5433. Django then uses the pooled connections, and you don't have to worry about the overhead of setting up new connections or tearing down old ones.

Hope that helps,

---Peter

Reply all
Reply to author
Forward
0 new messages