When, How And Why Use Node.js as Your Backend

Node.js is a platform build on Chromes java script run time for easily building fast and scale network applications.It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Node.js is lightweight, efficient, and its ability to use JavaScript on both frond end and back end opens new avenues for development. In this blog, I want to discuss when it is worth using Node.js, and in what cases it might not be the best idea.

How is Node.js different from web JavaScript?

Web JavaScript and Node.js falls under same umbrella .There is no difference between them in terms of the language used. JavaScript is used in browsers. And in it is almost exactly the same. What makes it special is the different set of APIs. In browsers, you have a variety of DOM/Web APIs exposed that help you interact with UI. And it allow you to access the hardware to a limited extent. To compare, Node.js, it comes with with many APIs suitable for back end development. E.g. the support for file systems, http requests, streams, child processes, etc. Browsers do offer some basic support for file systems or http requests, but those are usually limited due to security concerns.

Good use cases

Node.js is suitable for real time applications. Like that application which has to process a high volume of short messages requiring low latency. These real time application can can be easily developed with Node.js.  One of the most popular ones are live-chat and instant-messaging apps.

Ruby on Rails might not be sufficient in terms of speed, if you have a ton of requests. It will prove useful in situations when something faster and more scale than Rails is needed. It is very popular choice among “single-page application” sites. Where all the rendering is done on the client’s side, and the backend only provides a JSON API.

When might Node.js not be the best idea?

There are still some bad use cases when you shouldn’t consider using it.The first thing that comes to my mind are heavy-computing apps. It is based on an event-driven, non-blocking I/O model, and uses only a single CPU core. CPU-heavy operations will just block incoming requests, rendering the biggest advantage of it useless. It would be superfluous for simple HTML or CRUD applications in which you don’t need a separate API, and all data comes directly from the server. Your application might be marginally more scale, but don’t expect more traffic coming to your app just because you used it.

Author: Meliora Stroganova
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments