简体   繁体   中英

Restful web application with Node.js?

I came from java and I played around with node.js. Seems to be very fast and short to develop some apps. But is it good enough for a real cloud application? I used spring with spring mvc, security, data and so on.. But are the some modules like spring in Node.js? What would you suggest?

You've really got two questions here:

  1. Is node good enough for a real cloud application?
  2. Are there modules like spring in node.js

For the first one, Node is being used in production by some very large companies (Walmart, for example), and the general consensus in 2014 is that using an event driven webserver (primarily node and nginx, though there are others) is the best way to serve the highest of high demand applications. Yes, node is good enough, once you've learned how to use it.

For the second one, I don't know spring , but there are frameworks out there. Most of my work thus far has been primarily console based, not web based, so I haven't searched anything out, but look around.

I'm a current java/spring developer and I've been playing a couple of weeks with nodejs and expressjs. Nodejs is a really good framework for a web application, but is it the best for your project? In my opinion you should analyse your project before chose the environment.

If you expects to have too many concurrent requests, Nodejs is a really good choice because uses a non-blocking I/O model. At the same we can be in troubles because of the non-blocking feature; imagine that we want to retrieve some data from our database, manipulate this data and send the result as response. It should be easy but sometimes, because of asynchronous nature of Nodejs, is not and you must find a solution to make synchronous something that by default is asynchronous, making the code a bit tricky. I recommend Async.js to solve this "problem".

The code in the server side is quite simply and both requests and responses send just JSONs, loading all the content in the html through AngularJS, that improves even more the performance. This advantage has also an objection. Part of the application can be easily replicated, using SpringMVC and JSTL is much more complicate, because almost all the content is injected in server side. And In my opinion with Spring is easier to make a tidy project and that is really important for big projects.

You can find a comparation between SpringMVC and NodeJS in this article: "Discovering Nodejs & Express by a Spring guy"

ps: if finally you chose Nodejs, I recommend you to take a look to MeteorJS , is quite amazing :)

Here are a couple of the more well known existing WEB Framework modules within node:

If Walmart is happy with NodeJS to use it during Black Friday, I would think most folks might be able to live with results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM