2011-11-10 94 views
0

我嘗試使用JMeter測試對產生朝向RabbitMQ隊列的消息的API運行壓力測試。資源調用一個服務,該服務打開與RabbitMQ的連接,通過綁定的交換機在隊列上發佈消息,然後關閉連接。在多線程壓力測試中使用JMeter和RabbitMQ的NoRouteToHostException

當我使用調用API的單個線程運行測試以產生45000條消息時,它完美地工作。 當我嘗試使用五個產生9000消息的線程運行測試時出現問題:拋出了java.net.NoRouteToHostException(請參閱下面的跟蹤)。

運行這個測試我檢查了我的服務器上的連接數,我發現了超過30000個TIME_WAIT連接,我決定在我的sysctl.conf的減少TIME_WAIT超時20秒,而不是120秒。

但沒有任何改變。 TIME_WAIT狀態下的連接較少(大約5000個),但異常仍然被拋出。 我試圖增加RabbitMQ中的文件描述符限制以獲得相同的結果。

SEVERE: Mapped exception to response: 500 (Internal Server Error) 
fr.company.rest.InternalServerError: java.net.NoRouteToHostException: Cannot assign requested address 
at fr.company.webResources.EmailResource.create(EmailResource.java:66) 
at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:616) 
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) 
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) 
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469) 
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400) 
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349) 
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339) 
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) 
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537) 
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263) 
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178) 
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91) 
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62) 
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118) 
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301) 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162) 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:140) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:636) 

Caused by: java.net.NoRouteToHostException: Cannot assign requested address 
at java.net.PlainSocketImpl.socketConnect(Native Method) 
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327) 
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193) 
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180) 
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384) 
at java.net.Socket.connect(Socket.java:546) 
at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:362) 
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:400) 
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:423) 
at fr.company.services.MessageService.init(MessageService.java:41) 
at fr.company.webResources.EmailResource.create(EmailResource.java:62) 
... 41 more 

回答

0

如果我理解你,我看到兩種方式。首先 - 當不需要時,你必須關閉連接。 connect(); some_action(); disconnect(); 第二 - 在設置連接;在runTest中發送查詢,解析響應和其他內容;在tearDown中斷開連接。

如果你加載MQ,我認爲第二種方式是你的。

+0

我的API資源是調用業務服務的REST服務。業務服務打開與RabbitMQ的連接,發佈HTTP請求中給出的消息並最終關閉連接。所以我的壓力測試呼叫X次我的REST服務。我現在不會改變我的實施,如果可能的話找到另一種解決方案。 – Pascal

+0

什麼是您的負載測試的受害者? REST服務? – Zernike

+0

不是,我嘗試對發送消息的整個過程進行測試,並檢查整個鏈可以處理負載。 – Pascal