Thread per connection in webserver

The webserver allocates a thread when the client starts a TCP connection, and it uses that thread for all of the requests arriving over that connection. The downside is that you end up with a mostly idle thread which is set aside for the connection but there are no active requests over the connection, If there are a lot of concurrent clients, you can exhaust the number of threads available to the system. In java especially per thread memory is high hence this model will take a lot of memory as a lot of threads are sitting idle doing nothing.

Thread per request in webserver

In the thread per request model a thread from a thread pool is allocated to handle a acitive request. Thread is not tied to connection.The whole point of “thread per request” architectures is to be able to support relatively large numbers of mostly idle connections with a smaller number of mostly busy request threads.