Thread based vs. Event based

There are 2 main approaches how to handle requests from Clients to a web server:

Thread based

On a thread based system the web server creates one thread per request and all the work for this request is handled by that thread.

This also means, that the maximum of available threads on a computer determines how many concurrent users can connect to the web server.

Event based

On an event based system every request will be put in a “queue” which then is processed by 1 web server thread.

With that you avoid the “overhead” of creating a new thread for each request.

But this also means, that e.g. a very complex and long request blocks all request since it needs to be done before all the other requests can be processed.

But due to the fact, that JavaScript can be written asynchronously no “blocking” can occur and therefore no (direct) performance problem can be felt by the end-user.

Node.js “Event Loop” visualized

Node.js Event Loop


Share this post

Leave a Reply

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Durch die weitere Nutzung der Seite stimmst du der Verwendung von Cookies zu. Weitere Informationen

Die Cookie-Einstellungen auf dieser Website sind auf "Cookies zulassen" eingestellt, um das beste Surferlebnis zu ermöglichen. Wenn du diese Website ohne Änderung der Cookie-Einstellungen verwendest oder auf "Akzeptieren" klickst, erklärst du sich damit einverstanden.