【问题标题】:Server response time get extremely slower during load test在负载测试期间服务器响应时间变得非常慢
【发布时间】:2014-06-16 15:45:25
【问题描述】:

我正在使用 Jmeter(Oracle、Tomcat、Spring)分析我的 Web 应用程序性能。

Number of threads :20
Ramp up: 2
Loop: 500

我只用 Jmeter 模拟一个简单的网站登录。

当我在上面的这些设置中开始时。前 3 分钟它开始非常快(平均响应时间 500 毫秒),但它开始迅速变慢,到 15 分钟,响应时间下降到 5 秒。完成一个请求需要几分钟。

我不确定这是否正常,或者问题是 Tomcat 还是我的 c3po 池设置不正确。

这是我对 c3po 的设置:

    <property name="testConnectionOnCheckout" value="false" />  <!-- do not test connection isValid on checkout as it has bad performance result -->
    <property name="testConnectionOnCheckin" value="true" />    <!-- test connection isValid on checkin -->
    <property name="idleConnectionTestPeriod" value="60" />     <!-- test every 60 seconds -->

    <property name="checkoutTimeout" value="5000" />            <!-- The number of milliseconds a client calling getConnection() will wait for a Connection to be checked-in or acquired when the pool is exhausted. -->
    <property name="acquireRetryAttempts" value="30" />         <!-- Defines how many times c3p0 will try to acquire a new Connection from the database before giving up. -->
    <property name="acquireRetryDelay" value="1000" />          <!-- Milliseconds, time c3p0 will wait between acquire attempts. -->
    <property name="breakAfterAcquireFailure" value="true" />   <!-- If true, a pooled DataSource will declare itself broken and be permanently closed if a Connection cannot be obtained from the database after making acquireRetryAttempts to acquire one. -->

    <property name="maxIdleTime" value="180" />                 <!-- 3 minutes, then die -->
    <property name="maxConnectionAge" value="300" />            <!-- 5 minutes, then die -->
    <property name="minPoolSize" value="1" />
    <property name="initialPoolSize" value="2" />
    <property name="maxPoolSize" value="25" />
    <property name="acquireIncrement" value="1" />              <!-- ramp up the pool with 1 connection if all others are in use -->

    <property name="unreturnedConnectionTimeout" value="360" /> <!-- in seconds (6 minutes), actually this should be necessary if connections are not closed properly and thus are leaked -->
    <property name="numHelperThreads" value="10" />
    <property name="maxStatementsPerConnection" value="5" />

我还安装了 VisualVm 来监控 Tomcat,但不知道如何分析它,我应该检查内存池还是堆还是 Perm gen..?

任何想法为什么它可能会变慢或如何检查它?

当响应时间开始变慢时,Ps Old gen Memory Pool size graph peaks 可能有任何关系吗? 我的 Cm 连接设置是

 -Xmx1024m -XX:MaxPermSize=512M

【问题讨论】:

    标签: java performance oracle tomcat jmeter


    【解决方案1】:

    您的数据库连接池可能已用完,因为它最多设置为 25。一旦达到最大值,您的服务器会将所有这些连接请求存储几分钟,然后再将它们释放回 JMeter(而 JMeter 永远不会停止发出请求)

    您可以尝试增加连接池大小,或缩短它们释放回客户端之前的时间。

    您还应该调查为什么需要这么长时间才能获得登录请求的响应。

    编辑:在下面添加示例

    我认为这里的问题不在于 Tomcat 内部(我假设 Tomcat 只是处理请求并充当客户端和数据库之间的代理),它可能在于您的测试方式本身。

    如果 JMeter 重复发出相同的登录请求,它可能会备份数据库,因为它可能会在登录处理时锁定该记录。由于这种可能性,您在负载测试时不应该使用同一个用户(无论如何这不是现实情况)。更好的测试是创建多个用户,并在负载测试期间循环访问这些用户。

    听起来你创建了许多线程来执行登录,这会导致数据库排队,这会导致 tomcat 上的连接排队,随着时间的推移,问题会变得更糟。

    【讨论】:

    • 如何调查登录请求?我的意思是使用 VisualVM 如何检查那是应用程序还是连接池问题
    【解决方案2】:

    我会遵循@Quinnlv 的声明。实现一个模拟登录,看看它是如何执行的。如果规模扩大,请检查池。

    【讨论】:

    • 如何调查登录请求?我的意思是使用 VisualVM 如何检查那是应用程序还是连接池问题,我的 jmeter 已经只模拟了登录请求
    • @Spring,我所说的模拟登录,是指在服务器端。
    • 这应该是一条评论
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 2014-08-26
    • 2017-01-06
    • 2021-09-07
    • 2013-09-10
    • 2011-02-20
    相关资源
    最近更新 更多