Loading...

django-developers@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: MySQL connection pooling - preferred method?? Cal Leeming [Simplicity Media Ltd] Fri Feb 17 14:00:06 2012

Hi all,

Wwe actually put a patch into production about 2 weeks ago, which seems to
have reduced the connection count, whilst being stable and not having any
inconsistency problems.

# Apparently this will stop many connections to MySQL
from django.core import signals
from django.db import close_connection
signals.request_finished.disconnect(close_connection)

Although it's not connection pooling, it does stop the original problem of
lots of connections to the db.

I'd love to see this as a 'settings.py' option, does anyone else think this
would be a good idea?? Something like 'persistent' : True.. maybe?

Cal



On Sat, Jan 28, 2012 at 5:52 PM, Cal Leeming [Simplicity Media Ltd] <
[EMAIL PROTECTED]> wrote:

> Hi Russ,
>
> Thanks very much for the reply. I guess ultimately my question was "do any
> of the connection pooling solutions have an impact on the
> stability/performance of Django, or more importantly, cause any problems
> with the ORM?"
>
> I had very little luck in finding write ups by anyone on this, and it
> seems to be a question often asked.
>
> So I'm going to put time aside to test them all myself, then do a full
> write up about it - I'll reply back to the thread once done.
>
> Cheers
>
> Cal
>
>
> On Sat, Jan 28, 2012 at 2:15 AM, Russell Keith-Magee <
> [EMAIL PROTECTED]> wrote:
>
>> Hi Cal,
>>
>> I'm not exactly sure what it is you're looking for.
>>
>> The position of the core team has been fairly clear -- there are third
>> party connection pooling tools that handle connection pooling very
>> well.
>>
>> The recommendation of the core team is that you should use these tools.
>>
>> The alternative is to try an engineer a solution into Django's DB
>> connection stack. This solution would inevitably be less stable than
>> one that originates from a project whose sole purpose is implementing
>> a connection pool.
>>
>> If you're looking for a recommendation for a connection pooler for
>> MySQL, that's another matter. Unfortunately, I can't be much help
>> here; I don't keep on top of developments in the MySQL world, so I
>> can't comment with any authority.
>>
>> Yours,
>> Russ Magee %-)
>>
>> On Thu, Jan 26, 2012 at 5:01 AM, Cal Leeming [Simplicity Media Ltd]
>> <[EMAIL PROTECTED]> wrote:
>> > Damn - no thoughts on this from anyone?
>> >
>> >
>> > On Wed, Jan 25, 2012 at 12:11 AM, Cal Leeming [Simplicity Media Ltd]
>> > <[EMAIL PROTECTED]> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> After spending about 30 minutes looking through old tickets, long
>> >> discussion threads and various blogs, I'm still not clear on the MySQL
>> >> connection pooling topic.
>> >>
>> >> To quote Russ: "the capability already exists in third party tools, and
>> >> they're in a position to do a much better job at it than us because
>> it's
>> >> their sole focus" [3]
>> >>
>> >> Could a core dev (or anyone else with experience on this) clarify which
>> >> approach is recommended, on the following conditions:
>> >>
>> >> * Safety (should not cause any strangeness with query cache or ORM)
>> >> * Performance (should avoid causing Django to open a new database
>> >> connection on every request)
>> >>
>> >> I found various ways to accomplish this, one of which was to use
>> >> SQLalchemy[1], another was to stop Django from closing the database
>> >> connection after each query[2].
>> >>
>> >> I'm hoping this thread will also serve as a final answer for anyone
>> else
>> >> looking for clarification.
>> >>
>> >> Many thanks
>> >>
>> >> Cal
>> >>
>> >>
>> >> [1]
>> http://menendez.com/blog/mysql-connection-pooling-django-and-sqlalchemy/
>> >>
>> >> [2]
>> http://stackoverflow.com/questions/1125504/django-persistent-database-connection
>> >>
>> >> [3]
>> http://groups.google.com/group/django-developers/browse_thread/thread/6f1e9c6e81aff1de/bf34e546e4217277?lnk=gst&q=mysql+pooling#bf34e546e4217277
>> >>
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django developers" group.
>> > To post to this group, send email to [EMAIL PROTECTED]
>> .
>> > To unsubscribe from this group, send email to
>> > [EMAIL PROTECTED]
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-developers?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers" group.
>> To post to this group, send email to [EMAIL PROTECTED]
>> To unsubscribe from this group, send email to
>> [EMAIL PROTECTED]
>> For more options, visit this group at
>> http://groups.google.com/group/django-developers?hl=en.
>>
>>
>

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