You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Octavian Rasnita <or...@fcc.ro> on 2005/01/15 06:29:47 UTC

CGI::Session or CGI::Application

Hi,

If I want to use CGI::Session or CGI::Application, can I do it if I use
mod_perl or there are better modules for using with MP?

Thanks.

Teddy


Re: CGI::Session or CGI::Application

Posted by Todd Finney <tf...@boygenius.com>.
At 01:56 PM 1/17/2005 -0500, Perrin Harkins wrote:
>MySQL will be a lot faster than the tied DB_File interface in most
>situations.  BerkeleyDB, used with its own internal locking and called
>via object methods instead of the tied interface, will be a lot faster
>than MySQL, but Apache::Session::DB_File doesn't do it that way.

It wasn't a speed issue, it was a resource consumption issue, iirc.  MySQL 
was plenty fast, it was just sucking up a lot of resources for something so 
mundane as session management.





Re: CGI::Session or CGI::Application

Posted by Perrin Harkins <pe...@elem.com>.
On Sat, 2005-01-15 at 21:57 -0500, Todd Finney wrote:
> Have you checked ::MySQL against Apache::Session::DB_File?  My experience 
> is a couple of years out of date on this, but I switched away from using 
> ::MySQL for sessions because it was such a pig.

MySQL will be a lot faster than the tied DB_File interface in most
situations.  BerkeleyDB, used with its own internal locking and called
via object methods instead of the tied interface, will be a lot faster
than MySQL, but Apache::Session::DB_File doesn't do it that way.

- Perrin


Re: CGI::Session or CGI::Application

Posted by Todd Finney <tf...@boygenius.com>.
At 09:19 PM 1/15/2005 -0500, Michael Peters wrote:
>Sorry, I only use Apache::Session::MySQL (or Apache::Session::Flex with a 
>store of MySQL). I use MySQL over File because it's *so* fast for primary 
>key lookups. If you have any kind of traffic, I can guarantee that it'll 
>be faster than using a straight file, and since it's not any harder to 
>setup (except creating the table, but then they give you the sql for that) 
>I always go with the faster option :)

Have you checked ::MySQL against Apache::Session::DB_File?  My experience 
is a couple of years out of date on this, but I switched away from using 
::MySQL for sessions because it was such a pig.

We're only managing 15-20 thousand sessions per day, though.  Perhaps it 
becomes a win at higher traffic levels.



Re: CGI::Session or CGI::Application

Posted by so...@sofcorp.com.
>
> sofadmin@sofcorp.com wrote:
>> Interesting, your comments on CGI::Session vs Apache::Session as I've
>> had
>> nothing but trouble with Apache::Session::File -- session data
>> inconsistently being written to the file.
>
> I'm sorry to hear that. Did you mention those problems to the author or
> bring it up on the mod_perl list? Were you using just
> Apache::Session::File or Apache::Session::Flex? I suspect that it was
> having issues with locking the files so maybe trying another locking
> mechanism (using Flex) might have helped. But that's just a guess.

I only use the ::File implementation with a few sites where traffic is
fairly minimal & I didn't think the overhead of a MySQL db was worth it.
I'm not familiar with ::Flex. I will check it out. Thanks for the advice.

Sys


Re: CGI::Session or CGI::Application

Posted by Michael Peters <mp...@plusthree.com>.
sofadmin@sofcorp.com wrote:
> Interesting, your comments on CGI::Session vs Apache::Session as I've had
> nothing but trouble with Apache::Session::File -- session data
> inconsistently being written to the file. 

I'm sorry to hear that. Did you mention those problems to the author or 
bring it up on the mod_perl list? Were you using just 
Apache::Session::File or Apache::Session::Flex? I suspect that it was 
having issues with locking the files so maybe trying another locking 
mechanism (using Flex) might have helped. But that's just a guess.

> Several years ago I first tried
> Apache::Session, but had the problem with data being saved in the session,
> so tried CGI::Session, which at the time also used a tied hash &
> everything worked fine (used ::File & ::MySQL, both). Unfortunately, a
> recent server upgrade forced a CGI::Session module upgrade -- & the newer
> module had removed the tied hash implementation in favor of an object
> oriented one. Couldn't find the older module with tied hash implementation
> anywhere, so quickly changed to using Apache::Session for those sites that
> were using the session module. The ::MySQL module seems OK, but the ::File
> module had same problem as before - inconsistent writing of data to the
> session. So, I had to scramble to re-write code for several sites to
> implement the 'new' CGI::Session oo implementation. Do you use the
> Apache::Session::File module or one of the others?

Sorry, I only use Apache::Session::MySQL (or Apache::Session::Flex with 
a store of MySQL). I use MySQL over File because it's *so* fast for 
primary key lookups. If you have any kind of traffic, I can guarantee 
that it'll be faster than using a straight file, and since it's not any 
harder to setup (except creating the table, but then they give you the 
sql for that) I always go with the faster option :)

-- 
Michael Peters
Developer
Plus Three, LP


Re: CGI::Session or CGI::Application

Posted by so...@sofcorp.com.
Interesting, your comments on CGI::Session vs Apache::Session as I've had
nothing but trouble with Apache::Session::File -- session data
inconsistently being written to the file. Several years ago I first tried
Apache::Session, but had the problem with data being saved in the session,
so tried CGI::Session, which at the time also used a tied hash &
everything worked fine (used ::File & ::MySQL, both). Unfortunately, a
recent server upgrade forced a CGI::Session module upgrade -- & the newer
module had removed the tied hash implementation in favor of an object
oriented one. Couldn't find the older module with tied hash implementation
anywhere, so quickly changed to using Apache::Session for those sites that
were using the session module. The ::MySQL module seems OK, but the ::File
module had same problem as before - inconsistent writing of data to the
session. So, I had to scramble to re-write code for several sites to
implement the 'new' CGI::Session oo implementation. Do you use the
Apache::Session::File module or one of the others?

Sys



>
> Octavian Rasnita wrote:
>> Hi,
>>
>> If I want to use CGI::Session or CGI::Application, can I do it if I use
>> mod_perl or there are better modules for using with MP?
>
> Just a couple of thoughts:
>    CGI::Session does not appear to be well maintained. It's very popular
> and I know many people who have tried to send in patches and fixes but
> the author has been unresponsive. There is also no way to 'guarantee'
> that no too session will have the same id with CGI::Session, especially
> in a multi-server environment (eg, load-balanced cluster).
>
> Lately I have switched to using Apache::Session (and sometimes wrapping
> it in an object interface since it's a tied-hash). It's well maintained
> and you can easily use something like mod_unique_id with Apache to
> almost absolutely guarantee that each new request will have it's own id
> and can there use that id when you start a session.
>
> On a C::A note, I wonder how hard it would be for Cees to add
> Apache::Session support to C::A::P::Session.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>



Re: CGI::Session or CGI::Application

Posted by Octavian Rasnita <or...@fcc.ro>.
And I have seen that CGI::Session is not very fast, even when there are only
a few sessions in a MySQL table, but... are there any other libraries that
can do it better?

I have seen that CGI::session is made in such a way that anyone can write a
driver for another databases or ways of storing data.
I think that someone who knows better MySQL could re-write a
CGI::Session::MySQL driver which will work better.

Teddy

----- Original Message ----- 
From: "Perrin Harkins" <pe...@elem.com>
To: "William McKee" <wi...@knowmad.com>
Cc: <mo...@perl.apache.org>
Sent: Monday, January 17, 2005 10:16 PM
Subject: Re: CGI::Session or CGI::Application


> On Mon, 2005-01-17 at 14:45 -0500, William McKee wrote:
> > On Sat, Jan 15, 2005 at 08:15:31AM -0500, Michael Peters wrote:
> > >   CGI::Session does not appear to be well maintained. It's very
popular
> > > and I know many people who have tried to send in patches and fixes but
> > > the author has been unresponsive.
> >
> > Which is really ashame since it's listed in the Phalanx 100[1].
> > Nonetheless, it's been working fine for me (via the
> > CGI::Application::Plugin::Session module).
>
> Last time I looked at it, I was scared off by some of the things I saw
> in the CGI::Session::MySQL module.  It doesn't use the most efficient
> SQL constructs (no cached statement handles, no bind_cols) and has a
> locking mechanism that adds nothing (except overhead) over the standard
> MySQL atomic operations.  The PostgreSQL one doesn't use bind variables,
> but rather manually quotes everything.  It just didn't give me much
> confidence in the module.
>
> - Perrin


Re: CGI::Session or CGI::Application

Posted by William McKee <wi...@knowmad.com>.
Hi Perrin,

Thanks for the feedback. I've been meaning to find a better alternative.
I think many programmers writing standard cgi scripts are scared off
from using the Apache::Session modules because of the chosen namespace,
although I understand that it's possible to use them outside of Apache.
Maybe someone with extra tuits could rewrite CGI::Session to use
Apache::Session for the backend.

My point of the previous message was more that CGI::Session needs some
TLC, esp. since the original author is obviously not responding. Like
others, I've submitted CPAN bug reports and even sent direct emails to
him without response over the past 12 months.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: CGI::Session or CGI::Application

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-01-17 at 14:45 -0500, William McKee wrote:
> On Sat, Jan 15, 2005 at 08:15:31AM -0500, Michael Peters wrote:
> >   CGI::Session does not appear to be well maintained. It's very popular 
> > and I know many people who have tried to send in patches and fixes but 
> > the author has been unresponsive.
> 
> Which is really ashame since it's listed in the Phalanx 100[1].
> Nonetheless, it's been working fine for me (via the
> CGI::Application::Plugin::Session module).

Last time I looked at it, I was scared off by some of the things I saw
in the CGI::Session::MySQL module.  It doesn't use the most efficient
SQL constructs (no cached statement handles, no bind_cols) and has a
locking mechanism that adds nothing (except overhead) over the standard
MySQL atomic operations.  The PostgreSQL one doesn't use bind variables,
but rather manually quotes everything.  It just didn't give me much
confidence in the module.

- Perrin


Re: CGI::Session or CGI::Application

Posted by William McKee <wi...@knowmad.com>.
On Sat, Jan 15, 2005 at 08:15:31AM -0500, Michael Peters wrote:
>   CGI::Session does not appear to be well maintained. It's very popular 
> and I know many people who have tried to send in patches and fixes but 
> the author has been unresponsive.

Which is really ashame since it's listed in the Phalanx 100[1].
Nonetheless, it's been working fine for me (via the
CGI::Application::Plugin::Session module).


William

[1] http://qa.perl.org/phalanx/distros.html

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: CGI::Session or CGI::Application

Posted by Michael Peters <mp...@plusthree.com>.
Octavian Rasnita wrote:
> Hi,
> 
> If I want to use CGI::Session or CGI::Application, can I do it if I use
> mod_perl or there are better modules for using with MP?

Just a couple of thoughts:
   CGI::Session does not appear to be well maintained. It's very popular 
and I know many people who have tried to send in patches and fixes but 
the author has been unresponsive. There is also no way to 'guarantee' 
that no too session will have the same id with CGI::Session, especially 
in a multi-server environment (eg, load-balanced cluster).

Lately I have switched to using Apache::Session (and sometimes wrapping 
it in an object interface since it's a tied-hash). It's well maintained 
and you can easily use something like mod_unique_id with Apache to 
almost absolutely guarantee that each new request will have it's own id 
and can there use that id when you start a session.

On a C::A note, I wonder how hard it would be for Cees to add 
Apache::Session support to C::A::P::Session.

-- 
Michael Peters
Developer
Plus Three, LP


Re: CGI::Session or CGI::Application

Posted by David Hodgkinson <da...@hodgkinson.org>.
On 15 Jan 2005, at 05:29, Octavian Rasnita wrote:

> Hi,
>
> If I want to use CGI::Session or CGI::Application, can I do it if I use
> mod_perl or there are better modules for using with MP?


CGI::Application JFW for me under mod_perl.

-- 
Dave Hodgkinson
CTO, Rockit Factory Ltd.
http://www.rockitfactory.com/
Web sites for rock bands


Re: CGI::Session or CGI::Application

Posted by Sean Davis <sd...@mail.nih.gov>.
On 1/15/05 0:29, "Octavian Rasnita" <or...@fcc.ro> wrote:

> Hi,
> 
> If I want to use CGI::Session or CGI::Application, can I do it if I use
> mod_perl or there are better modules for using with MP?
> 
> Thanks.
> 
> Teddy
> 

Both work quite well under mod_per.  The CGI in both of those does not refer
to needing to be used only under plain CGI.  You probably want to look at
the plugin CGI::Application::Plugin::Apache.  There is an email list for
CGI::Application that is probably a better forum for asking further
questions.

Sean