Learn what, why, and when to use Node.js for your project and how to maximize the benefits. Examples of when Node JS is great/mediocre/bad option inside.
Technology stack selection for your project is a complex process that often determines the future success of the whole operation.
Plenty of aspects about the future web app functionality should be taken into consideration during the phase of tech stack selection.
More than half of the respondents of annual developers in a survey by Stack Overflow use Node.js technology.
Initially, Ryan Dahl, Node.js creator, worked at creating real-time sites with push capabilities. The technology he invented enables us to have web apps with the real-time connection that allows free data exchange. Before Node.js, the client always had to initiate communication.
We will talk about what Node.js is and why it is that popular in the next chapter.
Further in this blog post, we’ll describe the situations where using Node JS is a great idea. We will also speculate on when it is better to turn to other options for the backend of your web application.
You’re probably aware of what Node.js is. Please, don’t be too harsh on us for describing it to the ones who aren’t. Node.js is an open-source JS runtime environment on Chrome V8 – a platform for developing web applications.
It’s perfect for data-filled real-time apps that work across multiple distributed devices.
If you need a fast scalable network app that would pass all possible stress tests for handling big numbers of simultaneous connections with high throughput (i.e. scalable solution), Node.js should work for you.
It worked for Netflix, LinkedIn, Uber… Yeah, we threw some random names of big-time companies, but that doesn’t mean Node.js wouldn’t be the best choice for your own project. If you already have ideas about one in mind, share them with Fireart Studio here.
Among the undeniable advantages of Node.js are the comparably easy learning curve for the developers, robustness, and scalability. Node.js is an open-source project, so it has a big number of contributors. You will find plenty of reusable resources.
At the same time, you do not forget that Node.js is the platform that is perfect for fulfilling specific needs, and there are also situations when you’d rather turn to other tools.
We’ll talk about it in the following chapters.
Chats would be the most common real-time apps that several users would approach at the same time. The chat web application would show you all the benefits of using Node.js for its development and processing.
Chat development would be a perfect use case for learning for a beginner in backend web design. As simple as chats are, to develop them the programmer would use many paradigms that run in other Node.js applications.
As for why Node js? Well, essentially, modern-day chats are multi-user applications that experience heavy traffic, intensive data exchange, they run across many types of devices, and chatbots are now so popular, they’re used practically by every other web application.
Node Js allows pushing database writes off to the side to postpone dealing with them later. You will proceed as if they were successful, and that would allow dealing to shorten the queue of data input.
Databases become bottlenecks if you receive huge loads of concurrent data. Node js handles loads of connections easily, but database access oftentimes would be a blocking operation.
If you can predict your client’s actions within the web application, that would contribute to the problem solution.
The system would maintain high response abilities under a heavy load of traffic. That would come in handy if the client won’t need solid confirmation about data being written.
Operations that do not need to be reflected instantly (counter of “likes” on LinkedIn, Facebook) where final consistency is acceptable to serve as an example of this operation.
When data gets into queues in cashing infrastructure (RabbitMQ, Apache Kafka) – it is being digested by the database batch-write process. Node JS is definitely not the only option – the same could be achieved with some other languages, but throughput wouldn’t be as high as the one for Node.js.
This high throughput makes node js use cases for dealing with queued inputs that are common.
Web platforms different from Node.js often treat HTTP requests and responses as isolated events, while all of them serve as streams. Node.js sees the data that comes through a stream and processes it online. This is done to encode real-time audio and video files and proxy between data sources.
Real-time encoding was introduced back in 2010 – and the core feature is in encoding videos while they’re still uploading to the server. This serves to a 150-fold increase in encoding speed and goes even beyond that.
Node.js was the platform for Netflix, Amazon Video, Hulu, and many other leaders in streaming applications worldwide. Speed, light encoding, and uploading are the reason for that.
Nowadays, many e-commerces welcome to their websites with the videos that are encoded by Node.
LinkedIn and Medium are built on Node.js. Once again, fast routing and secure authentication alongside amazing scalability grant the much-needed combination of factors for modern-day leaders among social networks.
But it doesn’t really have to be a complex multi-million project for Node.js usage really. Node.js is a very versatile platform, so it could be used for building a dynamic website, or mail service, even if it is a single-page app.
Node.js is perfect for asynchronous data flow processing on the backend, and that makes it option number one in the development of single-page apps.
The server-side proxy should handle big numbers of simultaneous connections and not make them all clogged and blocked. Proxying services with different response times is relevant, as well as collecting data from different inputs.
When you ask yourself what Node.js is used for – all the above-mentioned will be in the list.
Instead of using dedicated proxy services, Node.js usage would allow you to find the solution for local development in non-proxying infrastructure. You could easily build a Node.js development server for proxying API requests.
We continue enumerating Node.js use cases with the systems used for tracking visitors and visualizing visitors interaction in real-time.
More and more businesses spend massive amounts of money studying customers’ behavior. For these matters, what could be better than an in-depth real-time analytics system?
Real-time stats have been introduced a long time ago, and now you could go further by building and following new communication (or simply observation) channels between you and the visitors.
Real-time two-ways sockets of our favorite platform would allow you to do all that.
Node.js event loop allows making web-based dashboards that would give you all the information about services statuses that come in an asynchronous manner. That would be beneficial to service-monitoring pages.
Statuses of Internal and public services could be reported in real-time with the help of WebSockets. That is a much more convenient option than Java Applets. Open web stack developed on Node.js is just what you need for system monitoring dashboard operations.
You incorporate Node.js into your tech stack if you need a scalable real-time web application. There are real-world examples of when Node.js replaced other platforms for big-time corporations and brought amazing benefits with it.
PayPal would be a great example.
Their tech blog contains tons of useful information, and those who read it for a long time know that Node.js wasn’t the initial platform that was used for the payment system.
Jeff Harrel, Senior Director at PayPal, admits that with Node.js arrival, engineers’ specialties were unified. The platform allows reacting to customer’s needs faster.
Some stats: Node.js vs. Java app. Twice bigger team for the latter, the former has just two-thirds of lines of the code and is constructed with 40 percent fewer number of files.
eBay, one of the biggest marketplaces in the world also was developed with Node.js.
Their major challenges were scalability and enormous amounts of traffic.
According to Senthil Padmanabhan, Chief Web Engineer at eBay, the main task was in making the app as real-time as they could. The second task that mattered was in orchestrating eBay-specific services that display on-page info.
After some debates and negotiations, Node.js was selected as a development platform.
It resulted in a quick and simple setup deployment.
Surely, we can’t omit Netflix in this list of tech giants.
Partially, it owns its success to the fact their app is tremendously lightweight and simple.It is also very customizable, and users are satisfied with the level of service that comes to them for their $11+.
At the same time, their infrastructure is really complex, and they needed tools to leverage and use all of their potentials.
All the data access layers in Netflix have been moved to Node.js back in 2017. So was the whole UI four years before that.
New web app startup time decreased by 70%, they streamlined their development processes and cut build times for their new features.
All of this is according to the words of Kim Trott, Director of UI engineering.
Long story short, if you need a scalable real-time web application, Node,js should be your go-to option.
In the next chapters, we’ll discuss the less perfect situations.
That being said, the responsiveness of Node.js will definitely be blocked by CPU-intensive computation.
A threaded platform would be a better choice. Scale out the computation if you are determined to choose the original path, but… Other environments (Rails, Django, ASP.Net MVC) will help you to perform relational operations, and you’d be wiser picking any of them instead of Node.js.
For heavy server-side computation, Node.js is probably not the best choice. Due to its event-driven model and non-blocking I/O node model. It blocks incoming requests while those threads are busy working on computing numbers.
Node.js is single-threaded and uses only a single CPU core. That means that all the CPU-intensive operation annuls all the throughput benefits Node offers, which brings us to…
Node.js minimalistic approach allows the platform to set performance records. At the same time, Node.js remains single-threaded (sorry, but have to repeat it over and over), and Heavy CPU computation will block the server responsible for the processing.
We tried to condense our thoughts on Node js is usage patterns we observe across the industry. Fireart Studio dedicated teams have used the platform across many of our internal and external projects.
We will be glad to discuss whether Node js. is good for your project. Who knows, maybe it will become Node JS use cases for both of our portfolios.
Just tell us about your project, what are your goals, and let's start.