Get an overview of what we’ll learn in this chapter.

In its early days, Node.js was just a non-blocking web server written in C++ and JavaScript and was called web.js. Its creator, Ryan Dahl, soon realized the potential of the platform and started extending it with tools to enable the creation of different types of server-side applications on top of JavaScript and the non-blocking paradigm.

The characteristics of Node.js are perfect for the implementation of distributed systems, ranging from a few nodes to thousands of nodes communicating through the network: Node.js was born to be distributed.

Unlike other web platforms, scalability is a topic that gets explored rather quickly in Node.js while developing an application. This is often because of the single-threaded nature of Node.js, which is incapable of exploiting all the resources of a multicore machine. But, in reality, there are more profound reasons for talking about scalability with Node.js.

As we’ll see in this chapter, scaling an application doesn’t only mean increasing its capacity, enabling it to handle more requests faster: it’s also a crucial path to achieving high availability and tolerance to errors.

Sometimes, we even refer to scalability when we talk about ways to split the complexity of an application into more manageable pieces. Scalability is a concept with multiple faces, six to be precise, as many as there are faces on a cube—the scale cube.

In this chapter, we’ll learn the following topics:

  • Why we should care about scalability.

  • What the scale cube is and why it’s useful to understand scalability.

  • How to scale by running multiple instances of the same application.

  • How to leverage a load balancer when scaling an application.

  • What a service registry is and how it can be used.

  • How to run and scale Node.js applications using container orchestration platforms like Kubernetes.

  • How to design a microservice architecture out of a monolithic application.

  • How to integrate a large number of services through the use of some simple architectural patterns.

Get hands-on with 1200+ tech skills courses.