What is Multi thread model and what are the limitations ?

In a Multi thread model the server assign incoming requests to a new thread similar as a client server architecture, the user generate a request by interaction with the application and then it sent to the server.

So every time a new request comes in the server maps a new trend from the thread pool to the incoming request, then the thread is responsible for processing those requests and sending back the response.

So the number of requests is equal to the number of threads used from the thread pool.

Now the thread present in the thread pool are in limited number based on the resources.

Now suppose we have millions of request coming in per second and as the thread present in above image are in limited number so there will a situation when all the threads are exhausted from the thread pool.

In that situation a new incoming request has to wait until the thread processes the last request and return back the result.

So this is a situation of scalability which could be resolve by adding more resources and creating more threads inside the thread pool.

But this is a costly solution.

We have an easier way of doing that using a single thread model.

Second Limitation of Multi thread model. 

 

  1. If multi threaded model for every request server creates a separate thread which handle the request.
  2. If a thread acquire a lock in the shared resources and it is exclusive lock, it will block other threads, so this create a bottleneck situation in processing requests over shared resources and will affect the response time of the server.

 

Related Posts

AXIOS-in-react-js

The Power of Axios in React 18: How Axios Simplifying HTTP Requests and Data Handling

Axios is a JavaScript library that we use to send HTTP requests from browsers or Node.js. We can handle these requests more conveniently using Axios as compared…

Difference between Multithread and single thread or event driven model

Multi thread model Request with listener worker thread | lock application. Using incoming request model. Multi threaded server might block the request which might involve multiple events….

What is Single thread model used in node js and how its eliminates the limitation of multi thread model

Node Js is event driven, handing all the request asynchronously from single thread. Almost no function  in node directly performs I/O, so the process never blocks. So…

Leave a Reply

Your email address will not be published. Required fields are marked *