[Mapserver-users] Storing database connections in a CGI session

Frank Warmerdam warmerdam at pobox.com
Tue Dec 9 11:46:50 PST 2003


Richard Holzmeier wrote:
> Currently i am testing MapServers load performance against ArcIMS using SDE
> and OracleSpatial database connections. ArcIMS displaces MapServer with a
> performance rate up to 7:1, certainly due to the overhead of creating a new
> session with every request. I´m thinking about using CGI sessions to store
> opened database sessions for a while using a library such as CGI::SESSION
> (http://search.cpan.org/~sherzodr/). Unfortunately i´m fairly new with C/C++
> and Perl and have no idea of the complexity or possibility to implement
> this. 
> 
> If anybody has, i will appreciate responses of any kind. Thanks in advance,

Richard,

I think you will need to do some C level hacking to get MapServer to
use session handles from Perl.  I'm not too familiar with the different
ways of using Mapscript.  Are you using mapscript within "modperl"?  Does
that imply that things are run within the Apache process so that (in theory
at least) sessions could be preserved and reused?

There is already some connection caching logic in MapServer.  It was
primarily aimed at allowing reuse of a session within one map rendering.
For instance, for when several layers come from the same database.  If you are
running within Apache already, it might be easier to convince MapServer's
C core to preserve and reuse these connections between map renders as well
as within a map render.

My work on FastCGI was not conclusive.  I had it working "in principle"
at one point but I hadn't done stuff like ensuring that connections were
preserved between map renders within mapserver.  Some lower level
connection caching was working (that done within GDAL such as OGR's
connection to OracleSpatial, or my OGR/FME driver's FME state.

The mapserv_fcgi.c hasn't been maintained, so I presume it is a bit out
of whack relative to the rest of the system.  Also, no work was done to
make things work better with multiple-threads in one fast cgi server.
As things were implemented there was a big lock around many of the
major subsystems like GDAL, PROJ and map parsing.

There are some project proposals out that would fund some improvements
in FastCGI and multi-threading support, but they aren't certain.  I am
unlikely to substantial work on this without funding.

However, I think if your primary concern is reusing connections and
you are already running in a persistant way (within Apache), then you
should be able to pretty easily hack the existing MapServer code to keep
sessions alive between map renders, and reuse them.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the MapServer-users mailing list