liveBook · Manning

Horizontal scaling

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

Horizontal scaling is the technique of increasing capacity by running multiple instances of a component and distributing its workload among them.

Horizontal scaling increases capacity by running more instances of a component and distributing workload across them. In a microservices application, it can target the whole cluster or an overloaded service, avoiding the need to enlarge every component. section 12.3 section 12.3.3

Apply the technique at several levels:

  • Scale the cluster by adding more virtual machines while keeping each machine’s size unchanged. Six smaller VMs can provide more computing power than three. section 12.3.2
  • Scale an individual microservice by increasing its replica count. This directs more compute, memory, and storage toward the specific bottleneck. section 12.3.3
  • Use elastic scaling when demand varies: Kubernetes can grow the cluster near its limits and deallocate unneeded resources during quieter periods. section 12.3.4
  • Keep microservice databases separate so independent services remain horizontally scalable; a shared database can become a tightly coupled bottleneck. section 12.3.6

Replicate a gateway service

Set replicas to 3 in the Kubernetes Deployment for the gateway service. Multiple instances improve performance by sharing workload and also provide temporary redundancy when one instance fails or restarts. section 12.3.3

Scale a cluster with Terraform

Change the node pool’s node_count from 1 to 6 while retaining the smaller Standard_B2ms VM size. This illustrates fixed-size horizontal expansion. section 12.3.2

Figure 12.10 Viewing CPU and memory usage for microservices in the Kubernetes dashboard

Inspect CPU and memory usage in the Kubernetes dashboard to identify overloaded or poorly performing microservices before scaling them. section 12.3

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Explains cluster, service, elastic, and database implications with Terraform and Kubernetes examples, but defers advanced autoscaler customization.
Examples
Demonstrates six smaller VMs, three gateway replicas, Kubernetes monitoring, and Terraform autoscaling bounds.
What it assumes
Assumes a Kubernetes microservices cluster, Terraform configuration, and basic awareness of virtual machines and service deployments.
What you can do after
Operate/configure cluster and service capacity through Terraform node counts, Kubernetes replicas, and autoscaling limits.
How it connects
Connects microservices with vertical scaling, elastic scaling, redundancy, Kubernetes, Terraform, and database sharding.

Also explained in

Compare how 13 books explain horizontal scaling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.