I have heard a lot and read about the Javascript server side language i.e Node.js, and saw many comparisons in favor of Node.I don't understand what makes it better or faster, or how it even relates to something as mature as Java Servlets.But Servlets are built on top of a multithreaded programming language as opposed to Node.js. Then how can node.js be faster?If suppose 1000K users query for a database records, then shouldn't Node.js be slower than Servlets.Also Don't servlets have better security compared to Node.js?
Node.js Or servlets?
javascript;java ee;node.js
You're mixing apples and oranges, kind of.Servlets (or inheriting from HttpServlet) let you access HTTP request parameters and respond with something, via (or on top of) an existing HTTP server implementation.Although using Javascript as the language, Node.js is at a lower level than that. It starts from actually implementing the HTTP server. You can go on to doing more high-level stuff in it nonetheless, such as web applications.About multi-threading, it's not necessary. Node.js servers aren't faster because of multi-threading, they're faster because they don't block on IO requests, so they can keep pumping them up in the queue, while doing other things. They only work when there's work to be done - they don't wait for it - and that causes a serious performance enhancement, as it turned out.As for database queries, it's really more about constraints in the database model and API than it is about the client.As for security - it's really a different topic, and is ultimately in the hands of any developer anyway, not so much in the library.