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

Jan Hartmann jhart at frw.uva.nl
Wed Dec 10 05:13:47 PST 2003


Frank Warmerdam wrote:
> 
> 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. 
> 
Within *one* map all connections from several layers to the same 
database can be pooled. This mechanism has been implemented for SDE by 
Steve Lime, and I heard it resulted in much faster operation. I don't 
think it has been done for Oracle yet, but it should not be much work (a 
few dozens of lines) for someone who is able and willing to program the 
MapServer-Oracle interface.
 > ...
> 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.

When retrieving multiple maps from a database, each map requires a new 
connection. Perhaps the easiest way to pool these connection would be to 
expand the CONNECTION keyword in the LAYER object. For now it is a 
string, and MapServer itself takes al the steps to create the actual 
connection. I could imagine that in the script versions (PHP, Perl, 
Python), the CONNECTION object could also be a pointer to an already 
existing persistent connection. All three scripting languages provide 
for such persistent connection objects, most elegant perhaps in 
Zope/Python. I really don't know if this is feasible, but if it is 
possible it would require almost no further adaptations in the core 
MapServer code.

For MapServer CGI this is much harder (where would the CONNECTION point 
to in a system-independent way?). Frank's FastCGI approach looks 
promising, but also reasonably difficult to implement. Does anyone have 
any comments on the feasibility/possibility of expanding the CONNECTION 
keyword for the script versions only?

Jan




More information about the MapServer-users mailing list