您的位置:首页 > 编程语言 > Go语言

The last packet successfully received from the server was XXX seconds ago

2012-04-10 13:38 656 查看

Database Connection Pools

Using a connection pool is recommended for improving the performance of your application, and to ensure that your application handles excessive concurrency without overloading your Shared Database configurations (which have a limited number of connections
available to the application). CloudBees datasources use the
Apache DBCP connection pool implementation, which has a wide set of connection options. The configuration below is a good configuration for a lightly loaded application or an application
running in the free app+db tier.

<resource name="jdbc/DATASOURCE_NAME" auth="Container" type="javax.sql.DataSource">
<param name="username" value="USERNAME" />
<param name="password" value="PASSWORD" />
<param name="url" value="JDBC_URL" />

<!-- Connection Pool settings -->
<param name="maxActive" value="5" />
<param name="maxIdle" value="2" />
<param name="maxWait" value="10000" />
<param name="removeAbandoned" value="true" />
<param name="removeAbandonedTimeout" value="60" />
<param name="logAbandoned" value="true" />
</resource>


Avoiding Database Idle Timeouts

MySQL includes a timeout that will close connections that have been idle for long periods of time. For improved Database performance, CloudBees DataSources use the Apache DBCP connection pool to reuse JDBC connections after they are closed by the application.
If you use a connection that has been in the pool idle for too long, your application will likely experience the following error: "The last packet successfully received from the server was XXX seconds ago". The connection pool includes a setting the will validate
and throw out dead connections when calling javax.sql.DataSource.getConnection(). To use this setting, add the following XML params to your DataSource definition in cloudbees-web.xml.

<param name="validationQuery" value="SELECT 1" />
<param name="testOnBorrow" value="true" />
http://wiki.cloudbees.com/bin/view/RUN/DatabaseGuide
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐