Top

EdgeNetworksExpert Speak Part 3 | Why we should use nodeJS

Part 3 | Why we should use nodeJS

Hello tech-peers. We are back and today close our blog series by knowing more on why to use nodeJS and what could be some of its best applications. Enjoy the piece!

Non-blocking code

 This is the strongest reason to select node as your server. nodeJS is completely event driven and majority of the code runs basing on callbacks. This approach helps the application not to pause or sleep, but to become available for other requests. Let’s explain this with an example.

Suppose the program will read a .txt file and print the content as output.

 

nodeJS

If you notice the code, you will find in php, in line no#3, it will start reading the file and before finishing up reading the file it can’t do anything else. That means php blocks the execution there. Whereas in case of nodeJS, in line no#3 it starts reading the file and assigns a callback to it, and proceeds to the next line. It continues executing the other parts of the program and whenever the “fs” finished reading the myFile.txt, the callback will be called to process necessary statements.

Fast processing

 nodeJS uses V8 JavaScript Runtime engine, the one that Google Chrome uses. nodeJS has a wrapper over this JavaScript engine providing some extra facilities to build network applications. Both the nodeJS wrapper and the V8 JavaScript engine are written using C language; which makes it really fast. It is much faster than Ruby, Python, or Perl.

Concurrent request handling

 nodeJS is architected to handle concurrent requests.

One environment

 Same code can be shared between server and client, etc.

Easy to learn

Java Script is the most popular language according to the StackOverflow (http://stackoverflow.com/insights/survey/2016 ) This is because it is easy to learn and get started with.

Popularity and community

JavaScript has a huge community. According to GitHub, 2016 saw the highest number of active repositories related to JavaScript. http://githut.inf

Where nodeJS can be the best solution

 Web Socket Server

 The non-blocking architecture of node makes it the best-suited solution for socket server applications or broadcasting like applications. Chat servers can become more efficient and real time using nodeJS as their base.

Fast file upload client

 With node you can upload multiple files at a time. That means it is possible that a part of file1 and another part of file2 is in the server at a given point of time. This approach makes file uploading dramatically fast.

Data streaming

 As node deals with callback concept, it can easily be used for streaming data flow. It can be really useful when data is coming from different sources

Ad server

 Well, I personally think Ad servers should be the fastest servers. Because, from an advertiser’s point of view, if I can load the ads before all the contents of the page is loaded, I may catch the visitor. Another is if my ads load slower, the visitor might navigate to somewhere else. So ad servers really need to be fast and thus nodeJS should be used.

Stock exchange software

 Things have to be very much real time in case of stock updates. Node helps us to develop real time web applications.

nodeJS clustered server

 What is a cluster in general? A cluster is a set of loosely or tightly connected compute machines or resources (called “nodes”) that communicate with each other and share work to solve a single purpose. It can be viewed as a single system.

1

Akhilesh Kumar is a developer with AI-driven HR Tech firm EdGE Networks. As a developer, Akhilesh is driving the company’s vision with great application to work without limits. He is an expert on working with JavaScript and all its families. Akhilesh is proficient in different tech-set as well e.g. Java, Web Security, Platform independent App development etc. Previously, he worked in many reputed companies. Akhilesh is fun-loving and adventurous person and holds a B.Tech from GGSIPU in Information Technology.

Hope you’ve enjoyed and benefited from our three-part blog series on nodeJS. Its been a pleasure sharing it with you – and we’d love to hear your thoughts on it. Drop us a comment below! Bye

No Comments

Leave a Reply