麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > Tomcat > 正文

解決tomcat頻繁死掉的問題

2024-09-06 19:01:05
字體:
來源:轉載
供稿:網友

某天在服務器上的網頁打不開了,頻繁報以下錯誤。

2007-3-18 1:08:26 org.apache.tomcat.util.threads.threadpool logfull
嚴重: all threads (150) are currently busy, waiting. increase maxthreads (150) or check the servlet status

在網上找了些回答,以下是我覺得正確的回答:
1.我想你的部分資源沒有釋放,積壓卡死的
2.連接池問題
3.應該是服務器端響應request的線程的處理時間過長導致的

分析:
當時使用網站的人數只有2個人,不可能答到到了并發線程150的上線。所以應該不是數據庫的問題。
通過對出錯的提示判斷,應該是連接池使用不合理造成的,或者根本沒設置連接池。和數據庫連接的部分是使用spring的數據源jdbc連的,如下:
<beans>
    <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">
        <!-- driver for mysql-->
        <property name="driverclassname"><value>org.gjt.mm.mysql.driver</value></property>
        <property name="url"><value>jdbc:mysql://localhost:3306/test?useunicode=true&amp;characterencoding=utf8</value></property>
        <property name="username"><value>test</value></property>
        <property name="password"><value>test</value></property>      
</beans>

問題應該出現在spring的drivermanagerdatasource上,它負責管理這些連接的。
下邊是對drivermanagerdatasource 的解釋
drivermanagerdatasource in spring framework

   javax.sql interface datasource

implementation of smartdatasource that configures a plain old jdbc driver via
bean properties, and returns a new connection every time.

useful for test or standalone environments outside of a j2ee container, either
as a datasource bean in a respective applicationcontext, or in conjunction with
a simple jndi environment. pool-assuming connection.close() calls will simply
close the connection, so any datasource-aware persistence code should work.

in a j2ee container, it is recommended to use a jndi datasource provided by the
container. such a datasource can be exported as a datasource bean in an
applicationcontext via jndiobjectfactorybean, for seamless switching to and from
a local datasource bean like this class.

if you need a "real" connection pool outside of a j2ee container, consider
apache's jakarta commons dbcp. its basicdatasource is a full connection pool
bean, supporting the same basic properties as this class plus specific settings.
it can be used as a replacement for an instance of this class just by changing
the class name of the bean definition to
"org.apache.commons.dbcp.basicdatasource".

-----------------------------------------------
many jakarta projects support interaction with a relational database. creating a
new connection for each user can be time consuming (often requiring multiple
seconds of clock time), in order to perform a database transaction that might
take milliseconds. opening a connection per user can be unfeasible in a
publicly-hosted internet application where the number of simultaneous users can
be very large. accordingly, developers often wish to share a "pool" of open
connections between all of the application's current users. the number of users
actually performing a request at any given time is usually a very small
percentage of the total number of active users, and during request processing is
the only time that a database connection is required. the application itself
logs into the dbms, and handles any user account issues internally.

there are several database connection pools already available, both within
jakarta products and elsewhere. this commons package provides an opportunity to
coordinate the efforts required to create and maintain an efficient,
feature-rich package under the asf license.

the commons-dbcp package relies on code in the commons-pool package to provide
the underlying object pool mechanisms that it utilizes.

applications can use the commons-dbcp component directly or through the existing
interface of their container / supporting framework. for example the tomcat
servlet container presents a dbcp datasource as a jndi datasource. james (java
apache mail enterprise server) has integrated dbcp into the avalon framework. a
avalon-style datasource is created by wrapping the dbcp implementation. the
pooling logic of dbcp and the configuration found in avalon's excalibur code is
what was needed to create an integrated reliable datasource.

看完了解釋,事實上是因為drivermanagerdatasource建立連接是只要有連接就新建一個connection,根本沒有連接池的作用。改為以下開源的連接池會好點。
<bean id="mydatasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close">
<property name="driverclassname">
<value>org.hsqldb.jdbcdriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9001</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>

測試通過,問題消除,如果沒有搜索引擎找答案不會這么快解決問題。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 午夜精品网站 | 91丝袜| 中文字幕精品在线视频 | 久久精品国产99国产精品亚洲 | 午夜精品成人一区二区 | 深夜毛片免费看 | www.69色 | 精精国产xxxx视频在线野外 | tube69xxxxxhd| 99国产精品自拍 | 日韩av在线资源 | hdhdhd79xxxxх| 最新av网址在线观看 | 国产精品久久久久久久久粉嫩 | 久久综合一区二区 | 外国一级黄色片 | 中文字幕四区 | 亚洲免费资源 | 亚洲精品无码不卡在线播放he | 欧美一级特黄aaaaaa在线看首页 | 91看片在线观看视频 | 国产成人在线网址 | 久久生活片 | xnxx 美女19| 欧美巨乳在线观看 | 麻豆视频观看 | 久草成人在线观看 | 欧美成人性生活片 | 免费视频xxxx | 欧美成人精品欧美一级 | 毛片毛片免费看 | 欧美日韩精品不卡一区二区三区 | 伦一区二区三区中文字幕v亚洲 | 在线成人免费观看www | 久久精品欧美一区二区 | 日日鲁一鲁视频 | 国产亚洲综合精品 | 欧美日韩色 | 成年人网站视频免费 | 成人三级电影网址 | 成人国产精品一区 |