레이블이 Tomcat인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Tomcat인 게시물을 표시합니다. 모든 게시물 표시

2013년 7월 9일 화요일

apache to tomcat: mod_jk vs apr (mod_proxy)

apache 와 tomcat 을 연동하는데 사용되는 방법별 차이..

출처: http://stackoverflow.com/questions/1081918/apache-to-tomcat-mod-jk-vs-mod-proxy

mod_proxy
* Pros:
      o No need for a separate module compilation and maintenance. mod_proxy,
        mod_proxy_http, mod_proxy_ajp and mod_proxy_balancer comes as part of 
        standard Apache 2.2+ distribution
      o Ability to use http https or AJP protocols, even within the same 
        balancer.
* Cons:
      o mod_proxy_ajp does not support large 8K+ packet sizes.
      o Basic load balancer
      o Does not support Domain model clustering
mod_jk
* Pros:
      o Advanced load balancer
      o Advanced node failure detection
      o Support for large AJP packet sizes
* Cons:
      o Need to build and maintain a separate module

2012년 2월 20일 월요일

Preventing database connection pool leaks

Preventing database connection pool leaks

http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html


A database connection pool creates and manages a pool of connections to a database. Recycling and reusing already existing connections to a database is more efficient than opening a new connection.
There is one problem with connection pooling. A web application has to explicitly close ResultSet's, Statement's, and Connection's. Failure of a web application to close these resources can result in them never being available again for reuse, a database connection pool "leak". This can eventually result in your web application database connections failing if there are no more available connections.
There is a solution to this problem. The Apache Commons DBCP can be configured to track and recover these abandoned database connections. Not only can it recover them, but also generate a stack trace for the code which opened these resources and never closed them.
To configure a DBCP DataSource so that abandoned database connections are removed and recycled add the following attribute to the Resource configuration for your DBCP DataSource:
removeAbandoned="true"
When available database connections run low DBCP will recover and recycle any abandoned database connections it finds. The default is false.
Use the removeAbandonedTimeout attribute to set the number of seconds a database connection has been idle before it is considered abandoned.
removeAbandonedTimeout="60"
The default timeout for removing abandoned connections is 300 seconds.
The logAbandoned attribute can be set to true if you want DBCP to log a stack trace of the code which abandoned the database connection resources.
logAbandoned="true"
The default is false.



POJO class sample.
-------------------------------------------
BasicDataSource bds = new BasicDataSource();
..
DB설정 부분..
..
..
아래 내용 추가.

bds.setRemoveAbandoned( true );
bds.setRemoveAbandonedTimeout( 60 );
bds.setLogAbandoned( true );