Spring引导线程正在等待org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter:invokeHandlerMethod:827

时间:2017-09-24 06:54:02

标签: spring spring-mvc spring-boot

我们使用spring boot开发了一组API。当性能测试运行并达到超过5000个呼叫/分钟时,平均响应时间开始增加。当我们在AppDynamics的帮助下进行调查时,超过2%的交易响应时间较慢(超过1.5秒)。但CPU使用率仍低于20%。

他们所有人都在同一个地方等我。 e org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter:invokeHandlerMethod:827.

以下是完整的调用图。

HTTPServlet:service:742 (method time = 0 ms, total time = 1800 ms)
HTTPServlet:service:661 (method time = 0 ms, total time = 1800 ms)
Servlet - dispatcherServlet:doService:897 (method time = 0 ms, total time = 1800 ms)
Servlet - dispatcherServlet:doDispatch:963 (method time = 0 ms, total time = 1800 ms)
Web Service - org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter:handleInternal:738 (method time = 0 ms, total time = 1800 ms)
Web Service - org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter:invokeHandlerMethod:827 (method time = 0 ms, total time = 1800 ms)
java.util.concurrent.locks.LockSupport:parkNanos:215 (method time = 1800 ms, total time = 1800 ms)

线程在此位置处理的根本原因是什么?是否有任何SpringBooot属性需要更新以消除此问题?

以下是RequestMappingHandlerAdapter的源代码:invokeHandlerMethod,它挂起在invocableMethod.invokeAndHandle(webRequest,mavContainer);

protected ModelAndView invokeHandlerMethod(HttpServletRequest请求,             HttpServletResponse响应,HandlerMethod handlerMethod)抛出异常{

    ServletWebRequest webRequest = new ServletWebRequest(request, response);
    try {
        WebDataBinderFactory binderFactory = getDataBinderFactory(handlerMethod);
        ModelFactory modelFactory = getModelFactory(handlerMethod, binderFactory);

        ServletInvocableHandlerMethod invocableMethod = createInvocableHandlerMethod(handlerMethod);
        invocableMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
        invocableMethod.setHandlerMethodReturnValueHandlers(this.returnValueHandlers);
        invocableMethod.setDataBinderFactory(binderFactory);
        invocableMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);

        ModelAndViewContainer mavContainer = new ModelAndViewContainer();
        mavContainer.addAllAttributes(RequestContextUtils.getInputFlashMap(request));
        modelFactory.initModel(webRequest, mavContainer, invocableMethod);
        mavContainer.setIgnoreDefaultModelOnRedirect(this.ignoreDefaultModelOnRedirect);

        AsyncWebRequest asyncWebRequest = WebAsyncUtils.createAsyncWebRequest(request, response);
        asyncWebRequest.setTimeout(this.asyncRequestTimeout);

        WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);
        asyncManager.setTaskExecutor(this.taskExecutor);
        asyncManager.setAsyncWebRequest(asyncWebRequest);
        asyncManager.registerCallableInterceptors(this.callableInterceptors);
        asyncManager.registerDeferredResultInterceptors(this.deferredResultInterceptors);

        if (asyncManager.hasConcurrentResult()) {
            Object result = asyncManager.getConcurrentResult();
            mavContainer = (ModelAndViewContainer) asyncManager.getConcurrentResultContext()[0];
            asyncManager.clearConcurrentResult();
            if (logger.isDebugEnabled()) {
                logger.debug("Found concurrent result value [" + result + "]");
            }
            invocableMethod = invocableMethod.wrapConcurrentResult(result);
        }

        invocableMethod.invokeAndHandle(webRequest, mavContainer);
        if (asyncManager.isConcurrentHandlingStarted()) {
            return null;
        }

        return getModelAndView(mavContainer, modelFactory, webRequest);
    }
    finally {
        webRequest.requestCompleted();
    }
}

0 个答案:

没有答案