Connection Pool Efficiency

Discussions

Performance and scalability: Connection Pool Efficiency

  1. Connection Pool Efficiency (3 messages)

    Hi Buddies,
     I'm not clear about the efficiency of the connection pooling services provided by the EJB servers. First thing I want to know is that at any moment of time if 'n' users are performing database interactions using entity beans then are there 'n' connections alloted to these users. If this is the scenario what happens in a typically peak load time. Specially in a internet scenario where there can be thousands on Online Users at one time. If the server will open so many connections at one time the issues can be:
    1) No. of max. connections supported by the database can overflow.
    2) Efficiency of App as well as Database Server will creep to ground.

    Thanks & Rgds
    Kam

    Threaded Messages (3)

  2. Connection Pool Efficiency[ Go to top ]

    The pool of connections has a limited size. Usually the
    limit is set in the configuration file. (J2EE reference implementation: config/default.properties) For the
    peak load, the users will have to wait for the resource.

    EJB server is designed not for a small amount of on-line users but for large amount of users. So when there are
    a lot of on-line requests, its advantages over the non-enterprise approaches can show up. (Otherwise, it may
    not be that efficient as the non-enterprise approaches)
  3. Connection Pool Efficiency[ Go to top ]

    One more thing - number of concurrently executing tasks is limited by a number of worker threads servicing user requests, so most likely (unless you have long-lived transactions in your application), you will not need more database connections than your threads pool size.
  4. Connection Pool Efficiency[ Go to top ]

    Hi Kam

    First of all I hope you are not exposing your entity beans directly to your Internet client layer (be it servlet or JSP)! You should use session bean facade as a intermediate; hence there won't be direct n-to-n relationship between http request and db connections.

    Second of all, I hope you are using a Connection pool and not instantiating connections directly! With a connection pool, you call Connection.close() upon completion of each of your db request (or in case of CMP, the server will do this for you). This does not physically close the connection, but rather returns the connection to the pool. Hence connections are swapped back and forth and reused between entity bean instances.

    Finally, if your EJB vendor implements entity bean caching correctly, you will NOT see a SQL request for each bean business-method invocation. Most likely you'll see a bunch of SQL calls at the beginning of a transaction (ejbLoads) and a bunch of calls at the end (ejbStores). During the transaction your entity beans will not be using connections, and these are freed up for others to use.

    So you see, you do not have to "scale-up" your db connections in order to scale up your site! And as a previous poster mentioned, it's the # of execution threads that you should be worried about as your traffic increases!

    Gene Chuang
    Teach the world... Join Kiko!