Hello, I've been trying to understand the behaviour of tomcat when handling internal redirects. I'm testing using tomcat 9.0.38. I'm testing using jdk8 1.8.0_265. My main test cases have been 2 forwards to the same servlet, and then a response. Or 2 redirects to the same servlet and then a response. Servlet as follows:
@WebServlet(loadOnStartup = 1, value = "/") public class ConnectorLimitServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { int number = Integer.parseInt(req.getParameter("number")); // Fake some work done at each stage of processing try { Thread.sleep(500); } catch (InterruptedException e) {} resp.setContentType("text/plain"); if (number <= 1) { resp.getWriter().write("Finished " + req.getServletPath()); return; } switch (req.getServletPath()) { case "/redirect": resp.sendRedirect(new URL(req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getRequestURI() + "?number=" + (number - 1)).toString()); return; case "/forward": final String forwardAddress = "/forward?number=" + (number - 1); getServletContext().getRequestDispatcher(forwardAddress).forward(req, resp); } } } It seems that under high load, 1000 threads in jmeter, Tomcat will refuse some of the connections for nio2 connections but not for nio, further it seems that these failures happen considerably earlier than the configuration page would suggest would be the case. The configuration suggests that if acceptCount is high enough for the number of connections then they will be queued prior to reaching the processing threads, so a small number of processing threads can exist with a queue of connection feeding them, it seems like until connectionTimeout is reached connections shouldn't be refused, but that is not what occurs. In fact acceptCount seems to have very little effect. In short, my questions are: Why is the nio2 connector type worse at this than nio type? Why are connections refused before acceptCount is reached, or connectionTimeout is reached? I'm guessing that each forward or redirect effectively counts as an extra connection, as removing the redirects and multipling the number of jmeter threads suggests that is the case, am I correct here? Also, I feel like it would help if there were better documentation around the differences between nio2 and nio, as, for example, the connector comparison part makes them sound almost the same. Apologies if this has been covered elsewhere before, I have been searching but haven't found anything particularly clear covering this. Best regards, Peter --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org