Java Reference
In-Depth Information
Pool (size 3)
can be
Database Connection
Database Connection Close
Database Servlet Task
Figure 7.3 Servlet-based programs tend to connect and disconnect from a database
repetitively, to control transactions and user context. The black boxes represent the
unnecessary connections—work that can be saved through the use of a connection pool. Note
that connection pooling will continue to pay dividends as long as the servlet runs, after the pool
is primed.
every service . Theoretically, the cost is infinite. We can take a pool of n connec-
tions of cost c and limit our total cost to n *(c1+c2). For a servlet with a theo-
retical infinite lifespan, the connection cost will approach zero over time. In
reality, once our connection pool is primed, we'll pay only for the manage-
ment of the connection pool.
We can claim additional benefits. For example, we can restrict the number
of connections in our pool to a reasonable number. Then, we can formulate a
definitive statement about the total connection cost of our system, which
makes it easier to effectively plan the capacity of our system. When we use
approaches like this one, our system performance as measured by throughput
Search WWH ::

Custom Search