The Good and the Bad of Node.js Web App Development
The Rise of Node.js
As an open-source project, Node.js was sponsored by Joyent, a cloud computing and hosting solutions provider. The company invested in a number of other technologies, such as Ruby on Rails framework, and provided hosting services to Twitter and LinkedIn. The latter also became one of the first companies to use Node.js for its mobile application backend. The technology was later adopted by a number technology leaders, such as Uber, eBay, Walmart, and Netflix, to name a few.
However, it wasn’t until recently that a wide adoption of Node.js started. The interest in this technology peaked in 2014, as per Google Trends, and remains high.
The Benefits of Node.js
⊕ Robust technology stack
- better efficiency and overall developer productivity
- code sharing and reuse
- speed and performance
- easy knowledge sharing within a team
- huge number of free tools
Consequently, your team is a lot more flexible, the development is less time-consuming and as a result you get fast and reliable software.
⊕ Unlimited scalability and speed
A lightweight technology tool, Node.js is perfect for microservices architecture. This architectural style is best described by Martin Fowler and James Lewis as “an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.”
Accordingly, breaking the application logic into smaller modules, microservices, instead of creating a single, large monolithic core, you enable better flexibility and lay the groundwork for further growth. As a result, it is much easier to add more microservices on top of the existing ones than to integrate additional features with the basic app functionality.
Node.js is the technology of choice when building and deploying microservices solutions, according to the recent Node.js User Survey Report. About a half of the respondents are already using microservice-related technologies (namely, Docker, the leading software containerization platform) with Node.js:
With each microservice communicating with the database directly through streams, such architecture allows for better performance and speed of application. Namely, Walmart’s shift to microservices architecture with Node.js resulted in the following immediate benefits:
- Overnight 20 percent conversion growth in general and 98 percent mobile conversion growth
- One hundred percent uptime on Black Friday (handling over 500 million pageviews)
- Saving up to 40 percent on hardware and 20-50 percent on overall operations
Another bright example of how Node.js can outperform the competition in terms of performance is the case of GoDaddy. Running the SuperBowl ad campaign, the company was able to handle 10.000 requests per second without downtime, using only 10% of the hardware thanks to Node.js.
⊕ Rich ecosystem
With such a vast variety of free tools accessible in a few clicks, there is a huge potential for the use of Node.js. At the same time, open source software enjoys a growing popularity as it allows you to build new solutions reducing the overall costs of development and time to market. The Future of Open Source Survey finds that 65 percent of respondents leverage such solutions to speed up the application development.
⊕ Strong corporate support
As mentioned above, the development of Node.js was supported by Joyent. In 2015, the Node.js Foundation was created to “enable widespread adoption and help accelerate development of Node.js.” IBM, Microsoft, PayPal, Fidelity and SAP became the founding members of the organization.
The list of organizations using Node.js in production is constantly growing. It currently includes almost three hundred well-known companies, such as PayPal, Medium, Trello, Uber and Zendesk.
Very few open source projects have ever enjoyed such strong support from the world’s leading companies. And that foretells Node.js has outstanding potential.
The Drawbacks of Node.js
Θ Performance bottlenecks and design issues
Two of the most argued about aspects of Node.js programming are its insufficiency with heavy computations and the so-called “callback hell”. Before we get into too many details, let’s figure out what’s what.
At the same time, Node.js is a single-threaded environment, which is often considered a serious drawback of the technology. Indeed, in some cases, a CPU-bound task (number crunching, various calculations) can block the event loop resulting in seconds of delay for all website users.
This represents a serious issue. That is why, to avoid it, it is recommended not to use Node.js with computation-heavy systems.
Due to its asynchronous nature, Node.js relies heavily on callbacks, the functions that run after each task in the queue is finished. Keeping a number of queued tasks in the background, each with its callback, might result in the so-called callback hell, which directly impacts the quality of code. Simply put, it’s a “situation where callbacks are nested within other callbacks several levels deep, potentially making it difficult to understand and maintain the code.”
Example of code with nested callbacks. Image source – http://callbackhell.com/
Θ Immaturity of tooling
Although, the core Node.js modules are quite stable and can be considered mature, there are many tools in the npm registry which are either of poor quality or not properly documented/tested. Moreover, the registry itself isn’t structured well enough to offer the tools based on their rating or quality. Hence it might be difficult to find the best solution for your purposes without knowing what to look for.
The fact that the Node.js ecosystem is mostly open source, has its impact as well. While the quality of the core Node.js technology is supervised by Joyent and other major contributors, the rest of the tools might lack the quality and high coding standards set by global organizations.
Θ Growing demand for experienced professionals
As the hype over Node.js continues to grow, the demand for experienced professionals in this field increases.
Image source – www.indeed.com/jobtrends
However, a relatively new technology niche cannot meet this demand. The number of Node.js job postings is 3-4 times bigger than the number of job seekers with the relevant skillset.
Image source – www.indeed.com/jobtrends
Make Node.js Shine
Obviously, with all the listed pros and cons, Node.js is no silver bullet. But neither is Java, .Net framework or PHP. Yet, there are specific cases where each one of the listed technologies perform best. For Node.js, these are real-time applications with intense I/O, requiring speed and scalability.
This might be social networks, gaming apps, live chats or forums as well as stock exchange software or ad servers, where speed is everything. Fast and scalable, Node.js is the technology of choice for data-intensive, real-time IoT devices and applications.
Due to its non-blocking architecture, Node.js works well for encoding and broadcasting video and audio, uploading multiple files, and data streaming. The latter might be exceedingly useful for Travel industry software where you need to source data from different APIs of different suppliers.
Recently, Node.js has been actively used in enterprise-level software. While there is still much argument about this, many large companies and global organizations, such as Capital One and NASA, have already adopted Node.js. And the enterprise Node.js ecosystem continues to mature with such tools as IBM API Connect, Triton by Joyent, N|Solid by NodeSource, Red Hat OpenShift, Trace by RisingStack and others.
Yet, you can’t choose a language or tool just because another super-successful company did. It makes no sense to look at the others when your product and your business is at stake. You need to get your priorities straight and clearly identify the benefits the technology will give you, without forgetting about the hidden drawbacks. Hopefully, our “The good and the bad…” series will help you make the right choice.