tomcat Java NIO with concurrent slow TCP client connections

Bhuvan :

My unsertanding

Without NIO:
For every keepAlive connection server continue to block a thread.

With NIO:
This connector has a couple of poller threads used to keep the connection alive for all connected users while worker threads are called whenever data (a new HTTP request) is available

Now: If i have a simple servlet which return a 100 KB string to client(browser).

....
String HunderdKBString = "reallylongstring"
PrintWriter out = response.getWriter();
out.println(HunderdKBString);
....

If a client with 1 KB connection connects then it will take around 100 Sec to receive the string.
So is it that the java thread will be blocked for around 100 sec?

How does TCP buffer, Java OutputStream or Writer or other buffers affects the thread block time?

PS: using apache-tomcat-8.0.24 in centos 7 with oracle JDK 1.7.

EDIT: As mentioned thread does get blocked and buffer can reduce thread block time.. How to optimism tomcat/OS to reduce thread block time by using these buffer?

How one can detect in production environment if tomcat is starving of thread due to many slow connection client connected to it?

user207421 :

So is it that the java thread will be blocked for around 100 sec?

Yes.

How does TCP buffer, Java OutputStream or Writer or other buffers affect the thread block time?

If the buffer is large enough to hold the sent data, the sending thread won't block.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=453635&siteId=1