Node.JS Use Case: When & How Node.JS Should be Used
So you are starting your next project, and you have decided to use Node.js. Well, what this means for you is to first thoroughly read the documentation and then to ask around in the community that uses Node.js.
But here’s the catch –– thanks to its countless use cases, researching Node.js inevitably proves to be tedious and time consuming. And you realise, a little too late, that you’ve signed-up for a never-ending research loop.
The way out of this loop lies in understanding the Node.js use case like ––
- Leverage data streaming with Node.js
- Implementing web-scraping with Node.js
- Building a proxy-server using Node.js
So, why use Node.js, you ask?
Key points addressed in this article
Node.JS – What is it used for?
The usage of Node.js is not only limited to building web applications, but also for implementing various kinds of services.
- Backends and servers
- Developing API
- Scripting and automation
Now that we know about what is Node.js and its use case, let’s understand how these uses are categorized.
Node.js Usage: How the best use case of Node.js are categorized
We analyzed 10 industries that use Node.js in their tech stack and classified them into different categories. The loyalty matrix attached below is the result of our analysis as to how often Node.js gets used category wise and what’s the retention percentage of these categories.
Quadrant I includes categories that are most frequently used and to which Industries are leveraging them over time. Not surprisingly, Data streaming, Chatbots, and real-time data fall within this quadrant. Industries use Node.js for these categories every day, many times a day.
Quadrant II consists of categories that are used intensely, but for finite periods of time. Web scraping falls within quadrant II, along with server-side proxy and a system monitoring dashboard. Although these categories are used by Industries in an intensive manner, the retention over a period of time is less than those falling in Quadrant I.
Quadrant III is made up of categories that have low retention and infrequent use. However, the use of Node.js in these categories is expected to increase in the upcoming years. Needless to say, Big-data and IoT technology fall in this quadrant.
Quadrant IV comprises of categories that have a low frequency of use, but a loyal Industry base. The categories like REST API, Queued I/O Inputs, and command-line apps fall in the category.
Let’s cover these categories one-by-one.
1. Data Streaming
Streaming data in web require heavy processing
Data streaming is a complex process because it requires a continuous stream of data to be generated by an array of different sources and devices, delivered in a wide myriad of formats.
Node.js streams make data-streaming easier than ever
2. Server-side proxy
Third-party proxies can cause troubles in building complex web-apps
Third-party proxy services such as Nginx and HAProxy are sometimes not feasible and scalable in handling multiple requests from various sources at a time.
Node.js makes it easier to build a proxy server
While third-party proxy services such as Nginx or HAProxy are affordable, they can add to severe complexity when used for building large scale websites. Node.js can be easily employed as a server-side proxy for collecting data from various third-party resources. Whether you are building a news websites such as BBC, a media website such as Forbes, and entertainment websites such as IMDb, you would want to load content from various third-party domains. Node.js is beneficial for proxying different services with different response times. When used as a server-side proxy, it is capable of handling a large number of simultaneous connections in a non-blocking manner.
For instance: consider a website such as BBC news communicating with various third-party resources, gathering data from different sources, or storing assets like images and videos to third-party cloud services.
3. Big Data and Analytics
Dealing with large data in a browser is troublesome
If you are trying to deal with larger data in the browser, then it might wait for your users for a long time. Any user does not like to wait for more than 5 minutes with a frozen browser, no matter how cool the analysis might be.
Node.js back pressuring makes data processing easier
Node.js streams allow to effectively have a pipeline from which data starts at one point and flows through until the end. To overcome the problem of dealing with larger data, it is important to have a mechanism for breaking the large data into multiple chunks. Using back pressuring, which comes from implementing Node.js, you can use a computer’s resources while processing very large sets of data.
4. Wireless Connectivity
Bandwidth consumption and bi-directional signaling
Bandwidth consumption is a major challenge for IoT connectivity. For collecting and routing data between devices, reliable bidirectional signaling is essential. This is a challenge as it requires a reliable server to collect the data and send it to a particular destination.
Node.js server ensures data connectivity without any request blockage
Node.js is the best solution to create a proxy server for data connectivity and routing as it supports I/O connectivity without blocking.
5. System Monitoring Dashboard
Pushing real-time data at scale can be inconvenient
Dashboards are meant to convey a large amount of information quickly, however, finding the relevant information and displaying it in real-time is difficult. While using a dashboard to respond to errors, there are high chances for you to encounter several problems like:
- You won’t be automatically notified of unusual behavior.
- You’ll need to monitor the dashboard to detect potential errors continuously.
Pushing data in real-time with Node.JS is easy
Using the advance capability of event loop in Node.js, you can build a powerful web-based dashboard that validates the status of all services in an asynchronous manner. The data can be pushed in real-time to clients using WebSockets. By using Node.js, both internal (intra-company) and public services’ statuses can be reported live. For instance, you can build a dashboard to monitor real-time data which runs on frameworks backed by Node.js and Websocket instead of Java or Java Applets.
6. Real-time Data
Scalability bottlenecks in real-time data is very common
The common real-time data streaming issues are sizing and scaling. If your web app is running live 24 x 7, there is a need to plan out extra resources to execute all the operations without failing to meet any service-level agreements.
Node.JS makes real-time data a boon for web apps
Node.js is a good fit for building real-time web apps by using push technology over web sockets (a two-way communication between the servers and clients). What’s more revolutionary about Node.js is that it is the best choice for creating server-side web apps. Let’s walk you through a few reasons as to why it is pivotal to choose Node.js for building real-time web apps:
- Sharing & Reusing: It lets developers share the package of library code.
- I/O Bound: Node.js handles I/O bound tasks effectively.
- Fast & Scalable: In real-time web apps, it is possible to handle the multi-users requests due to the single-threaded model of Node.js.
The collaborative web apps (Trello, Google Docs), live chat, instant messaging, and online gaming are examples of real-time apps that benefit from Node.js architecture. These apps do function within a time frame that the users recognize as immediate and current.
7. Queued I/ O Inputs
An app database can be crashed with huge data load
Receiving a high amount of concurrent data can make database congested and resulting in the crash of the application. Also, it becomes expensive to queue data and maintain concurrency because of huge data load.
The asynchronous nature of Node.js makes it capable of handling huge data load
Due to the asynchronous capability and event-driven architecture, Node.js excels in handling huge data load. What’s more, the data can be queued through caching or messaging queuing infrastructure such as RabbitMQ or ZeroMQ and stored in different database batch-write process.
For businesses, investment in customer service calls is costly
A typical business spends $1.3 trillion on 265 billion customer service calls each year. Moreover, 265 billion customer support requests are made every year, which costs businesses a whopping $1.3 trillion to service them. That’s a huge cost considering the revenue made by these businesses is not constant.
Chatbots can offer better customer service experience at a lower cost
Building chatbots with Node.js is a perfect solution because you can build a simple API quickly with hapi.js, Express, etc as it supports real-time messages (RTM) or Slack RTM bots. Facebook has built a sample chatbot with Node.js, which is available on Github.
Drift (conversion-driven marketing and sales platform) is another example of chatbot that connects businesses with the best leads. Drift lets users to directly message them within the browser or provide them an automated chat experience.
9. Web Scraping & Automation
Manual data extraction is a cumbersome process
Extracting millions of data from different website sources is not possible manually. Furthermore, data analytics often gets challenging to implement in this case, considering the amount of data required to push through the stream.
Data scraping with Node.js is a cheaper alternative
An automated way of collecting information or extracted data from websites called as data scraping. Node.js embraces a vast library of packages that simplify tasks such as web scraping. For web scraping, there are mainly two packages used i.e., request and cheerio in Node.js.
The request package is used for downloading web pages. On the other hand, cheerio generates a DOM (Document Object Model) tree and provides a subset of jQuery function set to manipulate it.
10. REST API
SOAP makes API Integration a complex process
Although SOAP (Simple Object Access Protocol) has a high capacity of data transfer, API integration with it becomes very complex.
Building REST API with Node.js speeds up the API Integration process
The trendiest usage of Node.js also covers building RESTful APIs for API Integration. REST APIs, which can be developed using Express.js in Node, is commonly used in enterprise software development project. Moreover, the current trend of microservices design patterns has made the use of RESTful APIs even more common.
Another area where Node.js excels is developing command-line apps. You must be wondering why should we choose Node.js to build command-line apps? The main reason is the strong Node.js ecosystem means that the hundreds of thousands of packages are available for all purposes. They are specifically designed to help build powerful command-line tools.
Node.js use case Infographic
We have articulated all the use case of Node.js in an Infographic so that you can have a sneek-peak of where can you use it.
Feel free to use the Infographic on Your Site (with due attribution to simform.com)
10 Industries that can leverage their business with these Node.JS use case
Now that you’ve gone through use case of Node.js by category, let’s understand what are some industries that leverage these categories.
1. Media and Entertainment
The Media and Entertainment industry handles more than 500k requests per second and stores TBs of data on a daily basis. To build such kind of scalable web application, it is required to use cutting edge technologies such as Node.js.
In the media and entertainment industry, data streaming is used to make the videos work. This means that instead of sending all the data in a single packet to the frontend, you should send it in little chunks at a time. The data streaming would ensure that the initial request to the server will execute the first few seconds of the video and the rest will get downloaded while playing. Node.js helps in implementing this in a good way because it can queue the data or send it in an asynchronous manner so that the requests won’t get block and you get to see the video without interruption.
2. Social Network and Communities
Whether you want to build a news feed like Twitter, Instagram, Spotify or Facebook, Node.js can be of great help. Node.js stream API enables you to build, scale and personalize the news feeds or activity streams of your social media app. The world’s biggest business and employment-oriented social networking service, LinkedIn also trusted Node.js. The company decided to move its backed from ROR to Node.js and it proved to be a smart move for them. Linkedin dumped ROR from their Tech stack and adopted Node.js because they faced huge performance issues due to the synchronous nature of ROR. By adopting Node.js, Linkedin experienced 20 times faster speed and improved performance with lower memory consumption.
Almost all the data handled by highly scaled travel search engines involve any kind of natural language processing. This works like this: the visitor searches for any place and receives 100s of related results as a response. While python is a language of choice to implement Natural language processing, you can still rely on Node.js to implement the same with ease. The developers that have used Python for implementing Natural language processing (NLP) can use Node to achieve the same results. Node.js can be your go-to-language to implement such kind of processing because it consists of a variety of language processing packages like Node-nlp.
Apart from implementing NLP, Node.js can be used in travel websites to implement a server-side rendering (SSR). The developer team at Airbnb built an entirely new service using Node.js to render their most of HTML server-side. Since SSR is compute intensive, they ran into limits when they first introduce Node.js. But they sorted out that problem using reverse proxying and load balancing.
Node.js works with the NoSQL database, and it helps in the quick processing of results. It also makes it faster for patients to retrieve nearby doctors and consult them.
The most popular on-demand healthcare web app, Doctor on Demand that plays an important role in transforming the telemedicine industry. To put it in perspective, you need to check out the following top features of on-demand doctor app that you can consider during telemedicine app development:
- Real-time Video Consultation: To build an on-demand telemedicine web app, then be considerate over real-time video consultation feature. It allows remote app users to consult in real-time via video.
- Online Scheduling: Through the online scheduling feature, users can schedule the time as per their convenience.
- Payment Gateway Integration: No matter what kind of web app is, it is pivotal to accept electronic payments for users’ convenience.
The use of Node.js in the eCommerce industry is well known! It can be used as frontend in websites or as a backend to support the heavy traffic spikes during the holiday sales.
For instance: Groupon, a deal-of-the-day website, migrated its ROR app to Node.js stack and the results were substantial!
In his interview, Adam Geitgey – Director of Software Engineering – reported that they run about 70 node apps in production right now, and with these apps, they support traffic in 30 countries and 4 data centers.
The Node.js stack itself is perfectly fine for use in FinTech, although we are not sure whether it has the necessary horsepower for high-frequency trading. Perhaps, it’s a good idea to leverage another tech stack for a use case like that.
Capital One, however, is a fine example of companies in the U.S that leverages Node.js in their tech stack. With thousands of developers working with Node.js in production, they have contributed a lot to the node and its ecosystem.
If you are still unsure if Node.js is the correct choice for FinTech, we would suggest you check out the official Node.js Foundation Case Study with Capital One. Furthermore, we would like you to take a look at this fantastic talk by Azat Mardan that showcase how Capital One uses Node.js.
Moreover, there is an abundance of Fintech companies in New York that uses Node.js somewhere in their tech stack.
8. Transportation and Logistics
Just like the Travel industry, Node.js can be used to implement a website search engine in Transportation and Logistic indutry. The web app can be built either with any front-end library like React or Angular and Node.js can be used as a custom backend or a web server. Moreover, frameworks like Express, Koa, or Sails can help you to create API endpoints to handle requests from your web app, perform some business logic and store data in any database.
Uber used Node.js in production for its transportation web app as it responds quickly to all requests made and helps in a convenient deployment.
9. Education and eLearning
The education industry has been disrupted by eLearning web apps, thanks to the Internet. An eLearning web app taps advanced capabilities such as course creation, database management, forums & webinars, reporting & analytics, and video conferencing.
10. Project Management
A project management web app makes collaboration well organized. It helps users to manage the whole projects, at work or at home. For example, Trello, a project management web app, allows users to create boards to organize anything on an individual or group of team members. The server-side of Trello is built in node.js. The requirement of the Trello was an instant propagation of updates. That means they need to hold a lot of open connections, so an event-driven, non-blocking server, Node.js seemed like a good choice for Trello. Node.js also turned out to be an amazing tool for a single-page app.
If you are planning to build a web app like Trello, and still confused about choosing Node.js, then you can go through the official Trello Engineering blog.
When Should Not Use Node.JS?
Heavy Server-side Computation/Processing
Node.js is not the best platform when it comes to heavy computation. However, it is still possible to implement such kinds of things with some workaround.
For instance: while building a computation-heavy operation like the Fibonacci computing algorithm, node.js might make things worse because any request will get rejected by node.js event-driven & non-blocking architecture as the thread is busy in number-crunching.
Here’s how you can make things work for you in such case:
- Offloading heavy computation to background processes: Since node.js is single-threaded and uses a single CPU core, developers should take care when adding concurrency on a multicore server. It is advisable to do some more work in the form of a cluster module or maybe run several Node.js server instances behind a reverse proxy via Nginx.
- With clustering, you can still offload all heavy computation to background processes written in a more appropriate environment for that and can communicate via message queue server like RabbitMQ.
Furthermore, if your background processing might be running on the same server initially, this approach has the potential for high scalability. It is highly recommended to use the same approach on other platforms too, but with node.js you get that high reqs/sec throughput, as each request is a small task handled efficiently.
Server-side Web Application backed with a Relational Database
If we compare Node.js or Express.js against Ruby on Rails (ROR), then there is a clear decision in favor of the ROR when it comes to relational data access. For this, Node.js is not a good choice because Relational DB tools for Node.js are still underdeveloped as compared to ROR.
Rails automatically provide data access setup together with DB schema migration support tools. Furthermore, its a more mature framework as compared to Node.js.
Still unsure whether to use or not use Node.js in your web application? Please shoot us an email at firstname.lastname@example.org.