[ensembl-dev] database connection issure

Andy Yates ayates at ebi.ac.uk
Wed Feb 22 11:17:34 GMT 2012


Hi Xiong,

Ensembl does not use a connection pool instead it maintains a database connection for each instance of DBAdaptor. We do have two solutions to keep the number of open connections down.

1). Close the connection when you finish working with it e.g.

my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor('human', 'core');
# Do something with the DBAdaptor
$dba->dbc()->disconnect_if_idle();

Or if you were working with an adaptor e.g. a gene adaptor

my $adaptor = Bio::EnsEMBL::Registry->get_adaptor('human', 'core', 'gene');
#Do something with the adaptor
$adaptor->dbc()->disconnect_if_idle();

I would recommend doing this if you are iterating over many species and have a clearly defined point when you are finished processing a species. This is my preferred method of regulating open DB connections

2). The API can close down the connection for you automatically & reopen it when you need it again

Bio::EnsEMBL::Registry->set_disconnect_when_inactive();

I would use this version if you have a distributed setup and have no clear definition of when you have finished working with a species. Ensembl uses this version when we run pipelines. Please be aware of the associated overhead of recreating a connection. 

Hope this helps,

Andy

Andrew Yates                   Ensembl Core Software Project Leader
EMBL-EBI                       Tel: +44-(0)1223-492538
Wellcome Trust Genome Campus   Fax: +44-(0)1223-494468
Cambridge CB10 1SD, UK         http://www.ensembl.org/

On 22 Feb 2012, at 10:56, xiong zhao wrote:

> 
> 
> On 22 February 2012 18:53, xiong zhao <xiaoxiongg at gmail.com> wrote:
> hi,
> do u know the ensembl database use connection pool? if it is, what's the name of the config file? because i found the number of the database connections is too much, but we just have a few of client. 
> 
> i really appreciate if you can help me.
> 
> Thanks,
> Xiong 
> 
> _______________________________________________
> Dev mailing list    Dev at ensembl.org
> List admin (including subscribe/unsubscribe): http://lists.ensembl.org/mailman/listinfo/dev
> Ensembl Blog: http://www.ensembl.info/





More information about the Dev mailing list