[mod_python] Session Hanging Problems

David Janes davidjanes at blogmatrix.com
Mon Nov 26 15:19:51 EST 2007


Perhaps because of Apache process cycling?

Regards, etc...

On Nov 26, 2007 3:08 PM, Harish Agarwal <harish at octopart.com> wrote:
> Not sure if this helps at all, but I'm noticing that when the problem
> appears, it affects all of the incoming requests for a short
> duration.  The time logged to complete the call to
> _apache._global_lock decreases with each subsequent 'hung' request.
>
> For instance, the last time I noticed a hang in the log files, the
> first hang took about 1000 seconds to complete (the hanging is getting
> much worse today as traffic has picked up after Thanksgiving), and the
> last hang in the 'batch' took about 70 seconds to complete.  The log
> statements were all printed out at more or less the same time, which
> makes me suspect that the requests came in at various points during
> the hang, which lasted a total of 1000 seconds, and then the hang was
> resolved at the same time for each one, at which point the log
> statements were printed.
>
> I didn't have any problems accessing the site during this period of
> time, but that could be because I didn't hit the particular mod_python
> interpreter which was hanging.
>
>
> Harish
>
>
>
> On Nov 26, 2007, at 11:50 AM, David Janes wrote:
>
> > I'd be certainly interested in a non-mod_python session handler, since
> > I'm suspecting we'll be going to a non-Apache solution soon (since we
> > don't really take advantage of any Apache features right now) and we
> > were considering writing a generic one -- or adapting mod_python's
> > handlers.
> >
> > On the other hand as Harish notes, it would be good to solve the
> > problem for mod_python as mod_python's been very good to us! I'm
> > wondering if there's any need at all to touch the Apache global lock
> > anyway, or if it can worked around another way.
> >
> > Regards, etc...
> >
> > PS: this is what I'm working on right now:
> > http://www.onaswarm.com
> >
> > On Nov 26, 2007 2:21 PM, David Lenwell <dlenwell at gmail.com> wrote:
> >> yeah .. its very broken for me too .. What I am working on is my own
> >> session handler.. I don't feel that mysql is a valid replacement
> >> because it puts unnecessary load on your database server.
> >>
> >> We are debating on open sourcing the code I am working on. if I win
> >> the argument that open source can be good for us then I will
> >> contribute my code to the project.
> >>
> >>
> >>
> >> On Nov 26, 2007, at 10:55 AM, David Janes wrote:
> >>
> >>> All I can say is "we too" -- we're using FileSession. We have not
> >>> been
> >>> able to come up with a cure, though we've minimized use of sessions
> >>> which brings the frequency down significantly.
> >>>
> >>> Regards, etc...
> >>> David
> >>>
> >>> On Nov 26, 2007 1:39 PM, Harish Agarwal <harish at octopart.com> wrote:
> >>>> I'm using session handling with ModPython 3.3.1.  Originally I was
> >>>> using DbmSession and have since transitioned to a custom MySQL
> >>>> Session
> >>>> handler.  With both session types, however, I've noticed that
> >>>> session
> >>>> initialization intermittently hangs (not forever, but takes as long
> >>>> as
> >>>> four minutes to complete), at a low-ish (a handful of times every
> >>>> hour, while receiving, say, on order of a thousand or so requests
> >>>> every hour) frequency which seems to scale with the amount of
> >>>> traffic
> >>>> we're receiving.  I had read that long DbmSession cleanups can
> >>>> cause
> >>>> problems, which is why I transitioned to the MySQL system, which
> >>>> takes
> >>>> < 1 second to complete, but I'm still noticing the long session
> >>>> init
> >>>> times.
> >>>>
> >>>>
> >>>> I put some debugging statements into the code and it seems to be
> >>>> related to session locking.  In particular, it is this function
> >>>> call
> >>>> in the lock method of the BaseSession class:
> >>>>
> >>>>
> >>>> _apache._global_lock(self._req.server, self._sid)
> >>>>
> >>>>
> >>>> which is taking some time to complete. I'm not familiar with
> >>>> _apache._global_lock (is it used to apply a mutex lock to the
> >>>> session?) and am having trouble finding information describing its
> >>>> usage - but it seems likely that this is the root cause.  In the
> >>>> past
> >>>> I've had problems with session locking but have since transitioned
> >>>> the
> >>>> code to ensure that only one session is created per request, as
> >>>> such:
> >>>>
> >>>> if not hasattr(req,'session'):
> >>>>            req.session = Session.MySQLSession(req)
> >>>>
> >>>>
> >>>> Can anyone tell me if this kind of behavior is normal or is
> >>>> indicative
> >>>> of some common configuration or coding error?  Any help would be
> >>>> greatly appreciated.
> >>>>
> >>>> Thanks,
> >>>> -Harish
> >>>> _______________________________________________
> >>>> Mod_python mailing list
> >>>> Mod_python at modpython.org
> >>>> http://mailman.modpython.org/mailman/listinfo/mod_python
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> David Janes
> >>> Founder, BlogMatrix
> >>> http://www.blogmatrix.com
> >>> http://blogmatrix.blogmatrix.com
> >>> _______________________________________________
> >>> Mod_python mailing list
> >>> Mod_python at modpython.org
> >>> http://mailman.modpython.org/mailman/listinfo/mod_python
> >>
> >>
> >
> >
> >
> > --
> > David Janes
> > Founder, BlogMatrix
> > http://www.blogmatrix.com
> > http://blogmatrix.blogmatrix.com
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>



-- 
David Janes
Founder, BlogMatrix
http://www.blogmatrix.com
http://blogmatrix.blogmatrix.com


More information about the Mod_python mailing list