Scaling 

Once the server is in production, it's a good idea to monitor its resource consumption and business metrics associated with the application. If we identify any anomalies or high traffic, we should consider scaling the server to offer a better user experience.

Since a client can be any device that is able to connect to the server, including separate computers, we might suddenly have millions of clients accessing the server. When the application ran on one machine, the balance of resource consumption between the client and server parts of the application was fixed. However, as soon as clients and servers could be scaled independently, it became easy for clients to scale way out of proportion to the server's capacity. Today, clients only need to interact with one user. Because of this, it is easy for them to have adequate resources. However, servers may be asked to support numbers of clients across a wide, dynamic range. It’s in this situation that scaling becomes an important technical requirement.  

We have two options for scaling a server, as follows:

  • Vertical
  • Horizontal

We can think about vertical scaling for services that cannot be deployed on more than one node, because of its own nature. A node can be represented by a computer or process running the service.

In this scaling option, we can only scale a service by adding more resources, such as RAM, CPU, hard-disk, and so on, as shown in the following diagram:

Vertical scaling

An explicit limitation that we have is that we can only increase the power of the unique process that is running the service.

On the other hand, if you have a stateless service, like a REST API, it can be deployed on more than one node, making it possible to scale the service horizontally. This approach allows us to scale applications in a better way, but a load balancer should be in front of them, in order to route the request appropriately, using an algorithm for it. A typical algorithm to use is round-robin, which distributes the requests equally among all of the available nodes.

The following diagram shows servers arranged behind a load balancer, using a horizontal scaling approach:

Horizontal scaling
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.151.44