Say you use a (blocking) BIO connector like this:
<Connector port="8080" protocol="org.apache.coyote.http11.Http11Protocol" connectionTimeout="20000" redirectPort="8443" maxConnections="1000" maxThreads="200" />
and you make 201 concurrent connections, what happens to the last connection?
If you make 1001 concurrent connections then what happens to the last connection?
Next let's use a (non-blocking) NIO connector protocol="org.apache.coyote.http11.Http11NioProtocol"
Will there be any differences if we make 201 and 1001 concurrent connections?
As far as I understand there is no behavioural differences between NIO and NIO2, only the implementation differs, is this true?
What connector Tomcat 8 uses with default protocol settings protocol="HTTP/1.1"
when no APR/native connector is available?
------------- edit ---------------
I made a small servlet like this:
Thread.sleep(2000);
response.getWriter().write("ok");
Set these settings connectionTimeout="20000"
maxConnections="10"
maxThreads="2"
and made 50 concurrent requests. All would be accepted and then executed 2 at a time (as executing threads finished). Non of the requests timed out or got errors even though connectionTimeout="20000"
and maxConnections="10"
.
Exactly the same for both protocol="org.apache.coyote.http11.Http11NioProtocol"
and protocol="org.apache.coyote.http11.Http11Protocol"
. I guess the difference shows when you have Keep-Alive
connections. BIO would block a thread for entire duration of connection, NIO would free up the thread after every request.
When I tested the same scenario but with added parameter acceptCount="15"
as Dennis R pointed out, only then most requests returned org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8080 refused
.
---------- edit2 -----------
Note that if I set this maxConnections="100"
acceptCount="15"
then all 50 connections were accepted.
Here are configuration parameters: Apache Tomcat 8 Configuration Reference There is basically Executor and the queue default length in standard implementation is: acceptCount=100
Max connections is how many connections are accepted in total(in queue and being processed ). Connections are rejected, I assume based on whatever reached first.
NIO is not limited by request-processor threads.
Here is good summary/comparison