我的Spring Boot项目中有以下代码
import org.springframework.web.servlet.DispatcherServlet;
//some import ommited
public class LoggableDispatcherServlet extends DispatcherServlet {
private static final Logger log = ...
@Override
protected void doDispatch(final HttpServletRequest incoming, final HttpServletResponse response) throws Exception {
HttpServletRequest request = incoming;
if (!(request instanceof ContentCachingRequestWrapper)) {
request = new ContentCachingRequestWrapper(request);
}
try {
super.doDispatch(request, response);
} finally {
if (log.isTraceEnabled()) {
log.trace...;
}
}
}
}
这会触发DispatcherServlet的一些日志:
16:02:06.232 [http-nio-8080-exec-380] [trackingID] DEBUG LoggableDispatcherServlet:891 - DispatcherServlet with name 'loggableDispatcherServlet' processing GET request for route/v1]
16:02:46.453 [http-nio-8080-exec-380] [trackingID] DEBUG LoggableDispatcherServlet:979 - Last-Modified value for [route/v1] is: -1
它似乎在DispatcherServlet中花费了大约40秒钟,我不知道为什么。在此之前和之后的许多情况下,这种情况变得很平滑,并且所花费的时间约为1毫秒。 40秒的延迟发生在大约20个请求上,看起来我只是在收到请求,但是那儿有一个瓶颈。突然所有请求都在16:02:46
附近传递我使用spring boot 2.0.5,而spring web mvc是5.0.9