Apache::Sybase::ConPool - A Sybase connection pooling module for Apache/mod_perl


Apache-Sybase-ConPool documentation  | view source Contained in the Apache-Sybase-ConPool distribution.

Index


NAME

Top

Apache::Sybase::ConPool - A Sybase connection pooling module for Apache/mod_perl

SYNOPSIS

Top

Pre-load this module in your mod_perl startup script:

    use Apache::Sybase::ConPool (config => '/usr/local/apache/lib/conpool.cfg');

Then in your mod_perl scripts/handlers:

    use Apache::Sybase::ConPool;

    my $dbh = Apache::Sybase::ConPool::getDbh($server);
    .... use $dbh for some query or queries ....
    Apache::Sybase::ConPool::freeDbh($dbh);

DESCRIPTION

Top

Apache::Sybase::ConPool allocates a pre-defined number of connections at startup and stores them in a hash. These connections can then be shared among the httpd child processes as needed, using System V semaphores to syncronize access to each connection.

This module is useful if you have a large (5 or more) client web servers that connect to the same database server, as it reduces the number of open sockets that are needed on the database server.

I have found that allocating 10 connections for each web server works well, but you should of course experiment with this.

The connection details are handled in a configuration file (see sample conpool.cfg included in the package). The location of the configuration file is passed in when the module is use'd in the mod_perl startup script.

Apache::Sybase::ConPool defines the following calls:

$dbh = getDbh($server)

Get a connection to $server. An entry for this server has to have been defined in conpool.cfg. This returns undef if no connections are available (under heavy load, for example).

freeDbh($dbh)

Release the lock on $dbh, and return it to the pool of available connections.

clearAll()

Force the releasing of all database connections that this process may have. Usefull to be included in a cleanup handler to make sure that no stray locks are kept on a connection.

BUGS

Top

The web server(s) has to be restarted if the database server goes down.

The database handles can become unusable if a child dies while holding a lock on the handle.

AUTHOR

Top

Michael Peppler, mpeppler@peppler.org

COPYRIGHT

Top

SEE ALSO

Top

perl(1), Sybase::CTlib


Apache-Sybase-ConPool documentation  | view source Contained in the Apache-Sybase-ConPool distribution.