2011-11-10 43 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