Is Node.js faster than Java?



NodeJs is MUCH faster than Java if you are talking web servers. NodeJS uses an async event loop that ultimately utilizes fewer threads to handle more requests than say ...Apache. With Apache, JBoss, and other Java based implementations, one thread per request model is used..

while the one thread per request model works it certainly has it's limitations. if you have 500 threads and 501 concurrent requests then someone is going to be waiting.

also the cost of spinning up a thread isn't negligible. Especially when you multiply this effort per request, the single threaded alternative that NodeJs provides is certainly more efficient.

it's important to understand that while node is better at handling more requests really have to watch what you are doing in the main thread of execution. for example, if you have some crazy blocking i/o that is crypto related or something and you run this on the main thread you will block all requests.

this conveys the vulnerabilities with using a single threaded async model like NodeJs. If what you need to do per request is highly computationally intensive work then Node will quickly become a nightmare for you.

In conclusion, NodeJS is much better as a web server. for things that require more effort (crypto, hashing, regex) stick to java and multi threaded env.


nodejs is much faster than java as a web server.


NodeJS can do everything Java can do and then some. It can act single threaded and be multi threaded. You can fork child processes to take advantage of multiple cores. it's all about whose running the infrastructure honestly :).

NodeJS and Java are both abstractions from lower level programming they will take different approaches to doing the same things with the underlying hardware.