Is Node.js a single-threaded language or multi-threaded language ?
When I faced an interview, the panel of judgers asked me the question “Is Node.js a single-threaded or multi-threaded ? reason ?” at that time I struggled to answer this question, so that after finish my interview I searched on google and I get some ideas on that, these are some points I got.
Answer is Node.js is single-threaded language.
Node.js event model mainly inspired by Java script event based model, and with the js callback mechanism, because of that Node.js can easily handle concurrent client request. So that it follows the single-threaded with Event Loop model. This Event Loop Model is considered as the heart of the Node.js processing model.
So which technologies follow the multi-threaded request/responses ?
- JSP, Spring MVC, ASP.NET, HTML, Ajax, jQuery and some other technologies that follows the multi-threaded request/response methods, they handle the multiple concurrent clients.
Why Node.js uses the single-threaded Event Loop Model Architecture ?
- Node.js created by an experiment of asynchronous processing and its theory was doing asynchronous in single-threaded , it provide more scalability and performance under typical web loads.