日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Apache Server和JMeter调试

發(fā)布時間:2023/12/3 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Apache Server和JMeter调试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我一直在使用JMeter為生產服務器生成負載以測試我的應用程序。 該測試計劃具有13個以上的HTTP采樣器以發(fā)出不同的請求,并具有一個正則表達式提取器以從響應中提取一些值。 此值在連續(xù)的HTTP Sampler中使用。 這個測試用例簡單而直接。 最初,我使用200個JMeter線程來模擬200個用戶。 Server能夠輕松處理許多請求,但是當線程數增加時,它就無法無限地處理和等待。 當然發(fā)生了什么事。 JMeter線程正在等待連接,因此無法無限等待它。 為了避免這種情況,我引入了“ HTTP Request default”來添加一些連接和響應超時。 解決了一個問題,現在線程沒有無限地掛在那里,但它們因以下異常而超時。

java.net.SocketTimeoutException: Read timed outat java.net.SocketInputStream.socketRead0(Native Method)at java.net.SocketInputStream.read(SocketInputStream.java:129)at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)at java.io.BufferedInputStream.read(BufferedInputStream.java:237)at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)at org.apache.jmeter.protocol.http.sampler.HTTPHC3Impl.sample(HTTPHC3Impl.java:258)at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)at java.lang.Thread.run(Thread.java:662)

肯定是服務器(Apache 2.2.14 + Apache-tomcat-7.0.11)的一部分正在崩潰,但不確定是哪一部分。 當然設置中存在一些瓶頸。 在當前設置中,Apache服務器正在將請求轉發(fā)到Tomcat引擎。 因此,可以肯定的是,它們之一都不能一次處理200多個請求。 我做了一些更改,將所有請求直接轉發(fā)到Tomcat引擎。 它能夠處理它,這意味著Apache在懈怠。 我Swift檢查了/var/log/apache2/error.log存在的Apache error.log文件,發(fā)現以下幾行。

[Wed Jun 26 16:46:19 2013] [error] server is within MinSpareThreads of MaxClients, consider raising the MaxClients setting [Wed Jun 26 16:46:20 2013] [error] server reached MaxClients setting, consider raising the MaxClients setting [Wed Jun 26 17:24:42 2013] [error] server is within MinSpareThreads of MaxClients, consider raising the MaxClients setting [Wed Jun 26 17:24:43 2013] [error] server reached MaxClients setting, consider raising the MaxClients setting

這清楚地表明MaxClients數應該增加,這反過來又會增加Apache線程數。 我通過放置以下配置快速編輯了apache2.conf文件以增加MaxClients數量,并執(zhí)行"apache2ctl -t"以確認在配置文件中所做的更改是正確的。

<IfModule mpm_worker_module>StartServers 2MinSpareThreads 25 MaxSpareThreads 100 ThreadLimit 800ThreadsPerChild 800 MaxClients 2400MaxRequestsPerChild 0 </IfModule>

我有些放松,以為現在Apache一定會處理現在的負載。 但是令我驚訝的是,它不能一次又一次地碰到JMeter。 在這一點上,我想通過啟用服務器狀態(tài)來檢查Apache的性能。 此功能可以使您清楚地了解連接狀態(tài)。 我將以/etc/apache2/mods-available/status.conf放在/etc/apache2/mods-available/status.conf

<Location /server-status>SetHandler server-statusOrder deny,allowDeny from allAllow from .your.domain.here.com localhost </Location>

我通過執(zhí)行以下命令重新啟動了Apache和服務器

/> sudo service apache2 restart; sudo service tomcat restart;

Apache重新啟動后,我點擊以下URL獲取服務器狀態(tài)。

http://your.server.name/server-status?refresh=3

在為200多個線程運行JMeter之后,我在狀態(tài)頁面上注意到了這一點。

Apache服務器狀態(tài)

狀態(tài)頁指示"W" (發(fā)送答復)狀態(tài)下有大量連接。 這可能是由其他原因引起的。 我試圖用Google搜索它,但找不到任何確定的解決方案。 但是有一件事可以肯定,Apache不會引起問題。 它必須在Apache和tomcat之間。 我意識到JMeter測試計劃適用于200個線程,甚至Tomcat默認情況下也具有200個線程。 我只是碰巧通過編輯"<APACHE_TOMCAT_HOME>/conf/server.xml"文件將線程數增加到400。

<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" maxThreads="400" minSpareThreads="20" />

現在,服務器可以輕松處理JMeter負載,即使完成測試計劃,Apache連接也處于良好狀態(tài)。
盡管問題已解決,但是當JMeter配置為直接將所有請求發(fā)送給Tomcat時,我無法理解為什么Tomcat能夠處理負載,但是當Apache將請求轉發(fā)至Tomcat時,卻無法處理負載。 如果您對此行為有任何解釋,請在評論部分中分享。

參考:來自Code4Reference博客上的JCG合作伙伴 Rakesh Cusat的Apache Server和JMeter調試 。

翻譯自: https://www.javacodegeeks.com/2013/07/apache-server-and-jmeter-debugging.html

總結

以上是生活随笔為你收集整理的Apache Server和JMeter调试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。