Choosing the correct backend technology for a project or business is one of the most critical decisions that every CEO or CTO needs to be able to make. It will determine time-to-market, and also the TCO (Total Cost of Ownership) and how easy it will be to add new features in the future.
At Mäd, we often find ourselves in a position to advise clients on technology and strategy decisions, and so we decided to write this White Paper on NodeJS to help our clients evaluate the pros and cons of this technology and make the right decision for their unique situation.
Introduction to NodeJS
That said, it has gained ground as a backend language as well, because of the obvious advantage in being able to write the frontends and backends with the same language means that the entire development team shares one skillset, and that allows a lot of flexibility.
NodeJS has a unique model that excels at scalable and real-time situations that are increasingly common in modern applications.
Who uses NodeJS?
A large number of well known global companies, such as Netflix, Walmart, Paypal, Trello, and Ebay, use NodeJS heavily in their backend systems, and it is also used by millions of other organisations worldwide. You can see the incredible popularity of Node below on the official Github page code repository, where it has over 50,000 stars and almost 10,000 code forks.
So, the question has to be asked, why do so many big players and other organisations choose NodeJs?
Let’s explore both the top benefits of NodeJS, as well as some of the drawbacks that are worth considering during your decision-making process.
When to Use NodeJS
The great thing about NodeJS is that it provides all the basic building blocks and functionalities for building real-time applications such as chat applications. It has a powerful event API that makes it easy to create “emitters” that periodically emit named events that can be “listened” by event handlers. This means that it is quite easy to create server-side clients and push notifications that are used in real-time applications.
NodeJS also has fantastic support for WebSockets via a library called socket.io which means that a lot of hard work is abstracted away, and just by installing a library on the server and the client, you can start to deploy efficient real-time applications with only a few lines of code.
Complex Single-Page Applications (SPA)
Single Page Applications are web applications that take a little time to load initially, but then provide a really fast and great user experience after the initial load time. Think of using a service like Gmail.
Ideally, this should result in faster development, easier maintainability, fewer resources required, and generally a better work environment for developers, which means that they can focus on shipping features required for the business, not reinventing the wheel.
For obvious reasons, modern collaboration tools also have real-time requirements, and Node’s asynchronous and event-based architecture is ideal for this.
An example of this would be users seeing real-time edits to documents, or new message appearing instantly the moment they are posted, without needing to reload the page or mobile application.
Because NodeJS is able to handle many events and I/O request, this means that the real-time components of collaboration tools do not block the server by too many requests.
Data Streaming Applications
The fact that Netflix, the undisputed king of movie streaming, uses NodeJS extensively should tell you everything you need to know about NodeJS and data streaming applications.
There are is a very informative artcle on why Netflix chooses NodeJS:
Micro Services Architecture
NodeJS enables to build your application or system with a Micro Services Arcitecture in mind, by building small blocks of code that speak to each other.
Advantages of NodeJS
Easy to Hire Developers
This means that it is significantly easier to hire and scale a development team that is using NodeJs than one that is using other backend languages.
An Active Community
As mentioned earlier, NodeJS has an extremely active community, which means that your business will benefit from a large number of third parties working to improve NodeJS, as well as one of the largest ecosystems of extensions and modules available via NPM, which is the world’s largest software registry, with over 650,000 modules available for download.
Simultaneous Request Handling
NodeJS has the awesome ability to handle threads (i.e. requests from a client) concurrently in a non-blocking manner, which means it can use a fraction of the resources traditional required to handle tens of thousands of requests per second.
When NOT to use NodeJS
At Mäd, we’re always focusing on user needs first, and then working backwards to discover the correct technology to Make It Happen.™
For this reason, we never advocate a particular technology or set of technologies for every business, because it really depends on the business model and the goals of the business.
While we love NodeJS, there are times when it would absolutely be the wrong choice for a project.
For instance, if you have an app that requires heavy-computing, then NodeJS is probably not the right language for that particular app or module, because the event-driven non-blocking I/O model uses only a single CPU core, and CPU-heavy operations will block incoming requests, essentially rendering the biggest advantage of NodeJS quite useless.
If you’re going to do heavy-computing in your app, we might recommend something like Golang.
What are the alternatives?
Go is a great choice for a backend language, however, it is quite difficult to find experienced Go developers, and the ecosystem around Go is still quite underdeveloped, so the developers may find that things like dependency management are not quite what they might expect, coming from other languages.
However, Go excels at readability, performance (it outperforms NodeJS), and simplicity.
A great choice for some types of projects, and at Mäd we're really excited to see how this language develops.
Ruby on Rails
Ruby on Rails is an opinionated web-application framework, that gives you everything you might need, mostly "out of the box". The downsides of this is that you then need to do things the "Ruby on Rails" way, and if you are creating something that is distinctly new, then this may not be the best approach for you.
PHP is a widely used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. The ubiquitous WordPress uses PHP, there are some great frameworks available such as Lavarel.
However, for modern web application projects, there are now better alternatives, but it is a great choice for corporate websites without real-time requirements, or if your team has extensive PHP knowledge.
Considerations During Decision Making
The key aspects of choosing your backend technology should be the following:
- Are you going to work in-house or work with a partner for your technology requirements?
- What are the main use cases for your application?
- Is speed of development an absolute priority?
If you are going to do a project in-house, then you need to review the skillset of your in-house team and choose the backend technology that matches their ability and experience. There is no point in choosing a “superior” technology if your entire team will be unfamiliar with the technology. You are better off using what you know.
If you are going to outsource to a third-party, then you have more flexibility in your choice because you can choose partners that are experts in the particular backend language of your choice, and they will have a vast amount of experience in production-use of the technology and can advise you accordingly.
If your application is going to have a lot of real-time components, then NodeJS should absolutely be one the choices you review, because it is ideally suited to this type of task. If you are expecting to be doing a lot of calculations in your application, then perhaps it is not the ideal choice.
If the speed of development is key, then NodeJS might not be ideal as there are frameworks such as Ruby on Rail that come with far more “out of the box” and allows you to get up and running much faster, but you may lose flexibility in the long run.
At Mäd, we have the advantage that we don’t just work on the technology side, but offer Business, Technology, and Design services, which means that we are uniquely positioned to advise our clients on the strategic use of technology, weighing up various factors to give the best advice possible.
Subscribe to Why #workwithmad
Get the latest posts delivered right to your inbox