A few weeks ago, in our article Famous apps built with Node.js, you could see quite an impressive list of companies that have already given Node a chance. But why did they do it? If they had a functioning application, what was really the reason that made them change the technology?
Obviously, all of these companies had serious reasons to do so. Their motivations may have been different, but surely all of them wanted to see whether the benefits that Node promised would translate into a brighter reality. What benefits am I talking about? Let’s list a few.
Non-blocking I/O means better performance and scalability. Why? The application runs asynchronously and handles many tasks in one thread. If the app has to wait for data from another component, it puts the waiting line in a queue and handles a different task in the meantime, thus increasing efficiency and minimizing delays.
It does take a bit of planning not to block your application, with constructs that were not built with non-blocking I/O, but it is definitely worth it. Simply put: you process more requests with the same “size” of the virtual machine, which saves you money. At the same time, there is little to no time that developers have to put in to achieve that, so it is not offset by the higher cost of development.
Node.js has a rich library of open-source frameworks as well as an active community – no need to fear that it’ll disappear any time soon. In fact, Node is constantly growing in popularity.
In comparison to Java, for example, where major versions are released every couple of years, a new version of Node.js is released twice a year. That means the platform evolves faster to keep developers productive.
Why big companies choose Node.js
Even before Node gained its fame, it was already being implemented by some big companies. One of the first companies to give Node a try was PayPal.
Now, even though some say that Node.js is not the best solution for handling heavy data volumes – so it shouldn’t be the best fit for banking or other financial services, PayPal disproves it.
As you can see, having the same language on both sides actually does matter. Not only is it a more convenient solution (usually), but it also speeds up the development process.
When, how and why use Node.js for your backend
To start with Node.js, PayPal used it for some prototyping at first. Node proved to be extremely proficient, so they decided to try it on production. The first adopter of the new technology at PayPal was the account overview page, one of the most trafficked apps on the website. That’s a big step, isn’t it? They did, however, mitigate the risk by building an equivalent application in Java. If something went wrong with the Node.js app, they could still go back to Java.
A team of 5 Java developers started working on the app in January, while two months later a smaller team of 2 developers started working on the Node.js application. In early June both teams found themselves in the same place: both applications had the same functionalities.
What were the results?
The Node.js app was:
- built almost twice as fast with fewer people,
- written in 33% fewer lines of code,
- constructed with 40% fewer files.
That’s not all, though. The development was more efficient, sure, but there were also some improvements in the performance.
There are a couple of things worth noticing:
Compared to the Java app, the Node.js equivalent had double the requests per second. What’s more, PayPal got their initial performance results using a single core for the Node.js app and 5 cores for Java. At that time, they stated that they were expecting to increase that divide further.
The average response time for the same page was decreased by 35%. That meant pages were served 200ms faster.
Why did they choose Node.js? There are a few reasons, number one being having one common programming language. It was important for Netflix’s team to be able to write the code once and be able to run it everywhere instead of having to do everything twice. Another important factor was the performance of Node.js. Node being non-blocking and async appealed to Netflix as they were hoping to improve the performance. And it worked. From the initial 40-minute startup time they went to less than a minute.
Who can benefit from Node.js?
OK, Netflix and PayPal succeeded, but can you count on such benefits as well? The answer is: yes. Obviously, no technology choice guarantees the success of your product as there’s much more to it than its technology stack. The technology can, however, contribute to this success.
Node.js is a solution that’s lightweight, fast, and scalable. It’s performant and efficient – it handles multiple requests at the same time and, as PayPal showed, it doesn’t use as many resources. It’s more time- and cost-efficient to handle the traffic of your application. Node.js can be used for a variety of cases: web application backend (APIs), data-intensive real-time applications, serverless applications. It’s both an effective solution for startups to speed up and simplify the development, and a mature enough environment that can be used by enterprises.
Find out how to get a cross-functional tech team to work on your project