Is Node.js a Good Choice to Create an App Based on Microservices?

Photo of Michał Hartwich

Michał Hartwich

Jun 2, 2019 • 7 min read

How can introducing microservices into your next project make it better?

There’s a number of clear, tangible benefits of using microservices for app development. But how can connecting microservices and Node.js enhance the project workflow and what business values does it bring to the project? We will explain it step by step.Before we answer the title question, let’s take a step back and answer two more basic questions: what are microservices and what’s Node.js?

Microservices, also referred to as microservice architecture, are a software design pattern which breaks up large applications into a set of small, simple applications (or services, if you will), which are highly maintainable and testable, loosely coupled, independently deployable, and organized around their business capabilities. It’s also an entire business-oriented approach to software development.

And Node? Well, it’s “an asynchronous event driven JavaScript runtime designed to build scalable network applications”. What does all that mean in practice? And how do the two concepts come together? Read on to find out!

What’s the connection between Node.js and microservices?

The connection between Node.js and microservices is very deep. Node was created precisely to make building apps based on microservices easier. Even its name was intended to make this connection clear – it’s supposed to convey the idea that Node apps should be made up of multiple small distributed nodes which communicate with each other to make the application work.

In other words, the relationship between Node.js development and microservices is like the one between peanut butter and jelly – they were made for each other.

What are the benefits of using microservices?

That’s all great, you might say, but what’s the point of all this? Building applications is not all about technology. Some might even say that the business rationale is more important than the choice of technology. So how can introducing microservices into your next project make it better? Well, there’s a number of clear, tangible benefits to using microservices for app development, and we’ll have a look at them below.

  • Better structure. A well-structured app is easier to understand, which means that new features are easier to design and implement. In more practical terms, less time (and thus less money) is spent on business analysis and ramping up developers, and more on the development itself.
  • Seamless development of very complex products. Complex applications are incredibly difficult to conceptualize, build, and later maintain. When you break them up into small bits – that is, microservices – the job becomes much more manageable.
  • Scalability. A monolithic app (i.e. one built in the legacy paradigm; more on that later) is basically a huge blob of tightly coupled code. Getting it to scale can be a nightmare since you have to spend a ton of time figuring out what’s actually going on inside. With microservices, the thing is much simpler. It becomes very clear which microservices are the bottlenecks, so getting them to handle more load is much simpler.
  • Fewer errors. Think about it this way: when you’re looking for spelling errors, is it easier to review a single sentence or an entire novel? In this analogy, microservices are sentences: bite-sized pieces of technology that can easily be kept error-free. When it comes to a monolith, looking for bugs is like reading Moby Dick: rewarding, but very time-consuming.
  • Better performance. Since every microservice only does one job, they are easy to tune and optimize to work efficiently. To use another analogy: a microservice is a chef’s knife, while a monolith is a Swiss army knife. You can use both to make a salad, but one’s obviously better suited for the purpose.
  • Resistance to vendor lock-in. Different microservices within the same larger application can be built using different programming languages depending on the problem, which means that you’re never stuck with a so-so solution forever.

The way it used to be

Before the microservices architecture came along, apps used to be built as monoliths. This means that they eventually grew to be huge in size, causing chaos and problems with maintainability. The logical solution to that was to break them up into smaller chunks: microservices.

You can think about applications in terms of corporations. Big corporations, to avoid chaos, break down their structure into specialized departments, each one with clear responsibilities. The departments also know who to contact to get something outside of their direct purview done. This is how microservices work – they’re the specialized departments in the corporate structure of your app.

In a monolithic architecture, there is no clear division of labor, so people from 10 different departments can be involved in getting you an entry badge. In this paradigm, fixing a simple login issue in your application could require the developer to understand the whole application, rather than just one straightforward process.

So why Node.js?

“I get it”, you might say, “Node.js is great and so are microservices. But what’s the business value? Isn’t this just a shiny tech toy?”. No, it’s not, we would reply to your hypothetical question. Microservice-based apps build in Node.js actually deliver a lot of very tangible benefits:

  • Performance and reliability. Your app will be snappy and stable. In addition, you can scale your app to infinity – budget is the only limit. One feature of Node that enables this is its single-threaded asynchronous architecture (explained in detail here).
  • Data replication (a feature required for microservices) is uniquely easy with Node. In addition, a number of so-called NoSQL databases (which are basically an alternative take on the traditional, tabular database model) which take advantage of Node, are available on the market, often free of charge.
  • Cost control. With a monolith app, the only way to scale is to bring up another instance. Imagine that one instance can serve up to 100,000 customers and costs 500 dollars a day to run. Need to serve 120,000? You have to get two instances and double your costs. With microservices, which are obviously Node’s main focus, you can only replicate the parts of the app that are actually required to deal with the additional traffic, saving money.
  • Easier maintenance and updates. Since there’s no intertwined mess of monolithic code, writing a new feature is not an exercise in archaeology. The same goes for updates – you can improve your system incrementally instead of investing in a huge and costly rewrite. Node actively promotes this approach by enforcing a modular, service-based structure of your application.
  • Simplified development workflows. Sounds complicated? What this means is that developers can just get down to their respective parts of the app instead of getting in each other’s way as they would with a monolith. This is a clear strength of Node.js. Since the “big” app is made up of multiple “small” ones, it’s easy for developers to divvy up the work without getting in each other’s way.

Key takeaways

In this short article, we tried to explain the philosophy behind microservices and why Node.js is a good technology to consider when implementing this architecture. Microservices offer numerous benefits: cost control, ease of development and updates, and painless scaling. Node.js and microservices work best in high-traffic, complex applications, which are a pain to build and maintain as monoliths. Do you think your business idea is a good fit for microservices? Or maybe you want to rewrite your existing application to be better suited to the modern age? Get in touch. Our team of Node.js consultants is always happy to help.
Photo of Michał Hartwich

More posts by this author

Michał Hartwich

Michal is a young, energetic man who's satisfied with his life. He wants to broaden his knowledge...

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by:

  • Vector-5
  • Babbel logo
  • Merc logo
  • Ikea logo
  • Volkswagen logo
  • UBS_Home