Using multiple Db connections to single Database

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using multiple Db connections to single Database

Alexander Uherek
Hello,

I am using Cayenne 3.0.2 together with the play Framework (1.2.7).
I configured the framework to use a pool of 10 DB-connections, which according to pg_stats are opened and idle.
Unfortunatly only one connection is used for my Cayenne Queries.
Do you have any hints?


Alexander Uherek
IT-Services

mackoyCONSULTING
Schloss Seefeld | Hochschloss
82229 Seefeld
Tel.    +49 8152/92989-82
Fax    +49 8152/92989-89

[hidden email]
www.mackoy.de <http://www.mackoy.de/>
Reply | Threaded
Open this post in threaded view
|

Re: Using multiple Db connections to single Database

John Huss
Are you creating a new ObjectContext for each request?  You should be.

On Thu, Jan 26, 2017 at 12:11 PM Alexander Uherek <[hidden email]> wrote:

> Hello,
>
> I am using Cayenne 3.0.2 together with the play Framework (1.2.7).
> I configured the framework to use a pool of 10 DB-connections, which
> according to pg_stats are opened and idle.
> Unfortunatly only one connection is used for my Cayenne Queries.
> Do you have any hints?
>
>
> Alexander Uherek
> IT-Services
>
> mackoyCONSULTING
> Schloss Seefeld | Hochschloss
> 82229 Seefeld
> Tel.    +49 8152/92989-82 <+49%208152%209298982>
> Fax    +49 8152/92989-89 <+49%208152%209298989>
>
> [hidden email]
> www.mackoy.de <http://www.mackoy.de/>
>
Reply | Threaded
Open this post in threaded view
|

Re: Using multiple Db connections to single Database

Michael Gentry-2
In reply to this post by Alexander Uherek
Hi Alexander,

I'm not sure which connection feature (DataSource Factory) you are using to
connect to the DB (Driver, JNDI, or DBCP), but all three of those use a
connection pooling mechanism.  When you ask an Object/Data Context to
perform a query or commit changes, it borrows a connection from the
connection pool, does some SQL, then returns the connection back to the
pool where it can be re-used later. If you don't have multiple simultaneous
query/commit changes occurring across multiple Object/Data Contexts, it
makes perfect sense to see one connection get used a lot (really depends on
the connection pooling mechanism, though) and the others to be idle.  This
is working as-designed.  If you starting doing more things in parallel,
you'll see more connections get used.

mrg



On Thu, Jan 26, 2017 at 11:05 AM, Alexander Uherek <[hidden email]>
wrote:

> Hello,
>
> I am using Cayenne 3.0.2 together with the play Framework (1.2.7).
> I configured the framework to use a pool of 10 DB-connections, which
> according to pg_stats are opened and idle.
> Unfortunatly only one connection is used for my Cayenne Queries.
> Do you have any hints?
>
>
> Alexander Uherek
> IT-Services
>
> mackoyCONSULTING
> Schloss Seefeld | Hochschloss
> 82229 Seefeld
> Tel.    +49 8152/92989-82
> Fax    +49 8152/92989-89
>
> [hidden email]
> www.mackoy.de <http://www.mackoy.de/>
>