Should you use Node.js as your backend?

Kamil Karczmarczyk
Should you use Node.js as your backend?

As it has celebrated its 10th birthday only recently, Node.js can still be treated as a fairly new technology. Yet, it has already been recognised as a top-notch solution for many projects. Mostly because, thanks to this open-source and cross-platform JavaScript runtime environment, you can now do a lot more with JavaScript than just making your websites interactive. In fact, it makes it possible to develop applications with a single programming language, rather than use different languages for server- and client-side scripts.

Here’s whether you should use Node.js for your next project, along with the best Node.js examples to draw inspiration from.

What is Node.js, exactly?

Before Node.js web apps were written in a client/server model, in which the client would demand certain resources from the server, and get those resources in response. The server only reacted when the client made a request, and then closed the connection right after each response. In 2009, Ryan Dahl introduced a new approach to server-side runtime written in JavaScript. It enables requesting in and out of the web server (I/O) to be processed concurrently and asynchronously using a concept called non-blocking, or asynchronous I/O. That’s how Node.js has started.

The original idea behind the use of Node.js was to build websites with real-time push capability. Therefore, unlike the previous client/server model, it became possible to develop two-way connection websites with free data exchange. It’s mostly due to WebSockets, which allow opening an interactive communications session between a user’s browser and a server. Requests to a server are then processed as a loop (event loop, to be more precise), which makes Node.js a JavaScript runtime environment that takes a “non-blocking” approach to serving requests and thus, achieves low latency and high throughput along the way.

Basically, a Node.js app is run in a single process, without creating a new thread for every request. It makes such apps very efficient, mostly thanks to the V8 JavaScript engine which powers Node.js (and also happens to be the core of Google Chrome). The engine takes the JavaScript code and converts it into lower level or machine code - which don’t need to be interpreted first in order to be run. Then, running code on the server this way actually increases the processing speed.

Why use Node.js as your backend, then?

It’s worth to keep in mind that JavaScript is supported by all modern web browsers and employed by the majority of websites. As a matter of fact, it’s been the most commonly used programming language for a few years in a row, being valued especially for its simplicity and versatility. With Node.js, however, JavaScript is not limited to the front-end but works outside of the browser as well. As a result, it’s possible to build fast and scalable applications with the same code for both server- and client-side. What is more, with frameworks such as Electron or NW.js, it’s possible to develop native desktop applications for Linux, Windows and MacOS, using web technologies like HTML, CSS and JavaScript.

In fact, Node.js is a perfect choice for data-intensive, real-time apps that run across distributed devices. Take chats, as an example. With Node.js, you can easily serve multiple users and devices, and handle both big traffic and intensive data exchange. Speaking of data - it is also possible to leverage the fact that HTTP requests & responses are essentially data streams, and stream large files or even process them while they’re being uploaded (to encode audio & video, for example). It’s also a powerful solution for collecting and visualising real-time data in the form of advanced dashboards. GraphQL is an interesting example. Although this query language for APIs can work together with other programming languages, such as Python or Java, it’s Node.js that helped GraphQL to become a new standard to ask for data. This is also the case of Prisma - a brand new solution that replaces traditional ORMs (Object-Relational Mapping) and simplifies database workflows.

No matter the common uses of Node.js, it’s also worth to keep in mind that there’s a robust and helpful community behind it. It makes it much easier to solve any problem at hand - not to mention that Node package manager (npm), which is included in Node.js by default, is said to be the fastest growing and one of the largest ecosystem of open source libraries in the world. Node.js also comes with fine documentation and instrumentation, as well as the set of best practices to ease app development.

On the other hand, Node.js is not the best choice for handling CPU-intensive apps. Take editing graphics as an example - it requires an efficiency that an event-based and a single-threaded environment can’t really provide. It’s also being criticised for not being mature enough - at least not just yet. Even though the main Node.js modules are stable, there are many entries in the npm registry which are low-quality or just haven’t been tested and/or documented properly.

The examples of Node.js applications

Despite a few drawbacks, the words that best describe Node.js by its users happen to be: fast, simple, and easy - but also powerful and flexible. It might be the reason why Node.js is widely used by both emerging startups and some well-known companies.  

Rumour has it that Netflix and PayPal have already implemented Node.js, and saw significant results afterwards - both economically and in performance.  Actually, Node.js is said to boost business productivity by the majority of companies that decided to take advantage of it. It also powers the two biggest online marketplaces - eBay and AliExpress (and Amazon on top of that).

While there’s still some debate about the maturity of Node.js, its popularity is still growing. In fact, it was downloaded more than 360 million times in 2018 - and all versions of Node.js show a 40% year-by-year growth of downloads. Given these numbers, it’s likely that there will be more great Node.js examples in the future as well. Especially since Node.js is scalable and relatively easy to learn and use, which often matters for startups.

If you’re considering it for your own venture, the above-mentioned stats should’ve given you more confidence that you’re on the right track. Now it’s time to discuss developing your Node.js application with us.  



Kamil Karczmarczyk

blog comments powered by Disqus
5 min. read

More to discover


Design in the Age of the Machine Revolution

What does chess have to do with design? When and how will machines replace designers? And what is Elon Musk's role in all of this? Get a cup of coffee and read on if you find any of these questions intriguing.
12 min. read

A Tough Year Lies Ahead of the Retail Industry

A tough year lies ahead of the retail industry. Companies struggle against the economic crisis, rising inflation, and increasing fuel costs, which all translate into an overall increase in commodity prices.
8 min. read

Is there anything we can do for you?

We use cookies to enhance your experience. Read more about cookies in our privacy policy. Agree