[Mapserver-dev] FastCGI Implementation / connection pooling

Frank Warmerdam warmerdam at pobox.com
Thu Sep 23 13:53:09 EDT 2004


Sean Gillies wrote:
> Would you consider an approach that would support the use case of mapscript
> and shared connections?  Python and Perl's DBI modules are based on libpq,
> so there is something in there that we can transform into a mapserver
> postgis connection:
> 
>  >>> dsn = "dbname=postgis"
>  >>> dbcon = psycopg.connect(dsn)   # Python database connection
>  >>> postgis_layer.connect(dbcon)   # use existing connection
> 
> I'm not asking you to write the code under such a layerObj::connect
> method, just to not close the door on such a thing.

Sean,

I was thinking of maintaining a central connection pool and interfacing
to it with a small set of mapserver functions.  For each connection I would
keep track of the connection type, the connection string, the handle and
possibly some sort of "lifetime" indicator (whether it should be destroyed
after processing map or kept alive till application termination) and a
reference count.

Exactly what the "handle" is will vary from connection type to connection
type.   For a PostGIS/PostgreSQL database the connection handle would
presumably be the handle returned by PQconnectcb().  For OGR connections,
it would be the OGRDataSourceH handle.

I think it would make sense to expose this connection management API to
mapScript, and then (hopefully) a mapscript application could "prepopulate"
the connection pool.  This would depend on some means to turn whatever
"psycopg.connect()" returns into a proper C style pointer for the connection
string of course.  That might require a bit of custom glue for each
connection type.

I will keep this in mind, and perhaps we can work together to test it from
MapScript.

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-dev mailing list