mpapec has asked for the wisdom of the Perl Monks concerning the following question:

I would like to build a server which should provide persistent environment per client.
Clients should be able to connect and disconnect from server but server should maintain DBI database handles and query statement handles for each client.

OO book only suggest serialization of objects but that approach wouldn't work with objects which have open sockets/filehandles. Can apache/mod_perl provide a solution for such problem? I'm long time perl user and would be happy if perl can do the magic, but I'm open to other solutions too.

tnx

Replies are listed 'Best First'.
Re: real object persistence
by jettero (Monsignor) on Aug 04, 2008 at 10:43 UTC
    Yes, mod_perl definitely can do that.

    But if I were starting from scratch, I'd go the mod_fastcgi or mod_fcgid route. I really like CGI::Fast and find it's a convenient way to upgrade regular old CGI to the point of having persistence. It also means speed boosts that put perl up there with those other dynamic languages.

    You can, of course, teach mod_perl to convert regular CGI to mod_perl CGI, but you have to then worry about things like your global my and global subs not working well together....

    UPDATE: perrin, yes, I suppose that's true. I still say fastcgi is easier (or even better), unless you really need to get at the entire http protocol layer for some reason.

    -Paul

      The persistence of variables is identical in both environments and has the same issues. If you don't like the way ModPerl::Registry converts CGI scripts, that's fine, but it's not really relevant for someone starting from scratch. It's a tool for porting legacy code.