How many connections do I put in the connection pool?

Discussions

EJB design: How many connections do I put in the connection pool?

  1. How many connections do I put in the connection pool? (8 messages)

    How do I find out how many connections to put in the connection pool. Is there a fixed formula for finding out the number of connection needed if the number of user at any given point of time is known.
  2. If the application is db-intensive make your connections pool size equal to the number of server worker threads.
  3. I am not sure if that formula works. TheServerSide has crashed a few times in the last few months because we were running out of db connections during peaks in load. We were running with 15 server threads and 20 db connections, and we still ran out!

       Now we are running at 20 threads and 30 connections, and things seem pretty smooth.

    Floyd
  4. Weird - it is not supposed to crash when there are no connections are availiable, the requesting thread will block until somebody else releases the connection.

    Is it possible that you obtain more than 1 connection during request processing, or have some long-lived transactions?
  5. Hi Floyd,

    What do you mean by server threads. Is this the number of thread per JVM process on the server.
  6. Ajay,

    By server threads, I mean the number of threads Weblogic will run in, so yes, number of threads per VM.

    Dimitri,

    I am also puzzled as to why it would crash, actually, it wouldn't crash, it would hang, like a deadlock or something. Maybe its the DB's fault, who knows?

    Floyd
  7. Hi Floyd,

    >>> Now we are running at 20 threads and 30 connections, and things seem pretty smooth.

    What I don't understand is that, at a time a thread could be using one connection.Let us say that a method is executing. One thread can be executing only one method at a given point of time. Therefore only one connection is required per thread at any given point of time. Who is using the other 10 connection objects.

    Ajay Amrite
  8. A thread could infact use more than one connection.
    Assume that a thread calls a EJB method which has "RequiresNew" attribute set for transaction.
    The EJB server might have to pull out new connection from the pool to execute the method.
    (since the old connection is already in the middle of a transaction and the transaction has to be commited or rolled back for the connection to execute any other statement). So whenever a transaction is suspended a new connection might be required to excute the the other sql statements!

    what do you think?

  9. Looks ok. I may have some more queries regarding the same.