liveBook · Manning

Horizontal scaling

As explained in Microservices Patterns, Second Edition

A scaling technique that increases capacity by adding concurrent instances of a service or processing component.

Horizontal scaling adds concurrent service instances or processing nodes to increase throughput or capacity. For message receivers, concurrency can disrupt message order; partitioning work helps preserve it. section 8.3.6 section 13.3.1

Two approaches illustrate how horizontal scaling works:

  • For message consumers, route messages by shard key to partitioned channels and assign each shard to one receiver; reassign shards as receivers start or stop. section 8.3.6
  • For databases, partition data across nodes so adding nodes adds capacity; replication can help maintain availability when a node fails. section 13.3.1

Ordered order events

Three service instances process Order Created, Order Updated, and Order Cancelled messages. Delivering them to different receivers concurrently can produce out-of-order processing; assigning messages to shards by key preserves ordering within the partition. section 8.3.6

Figure 8.15 Scaling consumers while preserving message ordering by using a sharded (partitioned) message channel. The sender includes the shard key in the message. The message broker writes the message to a shard determined by the shard key. The message broker assigns each partition to an instance of the replicated receiver.
ShardedChannel

Shows how a sender’s shard key determines the message partition and how the broker assigns partitions to receiver instances. section 8.3.6

How Microservices Patterns, Second Edition covers it

How deep it goes
Details shard-key routing and receiver assignment, then contrasts partitioned NoSQL growth with vertical relational database scaling.
Examples
Uses ordered order-lifecycle events across three receivers and contrasts NoSQL and relational database scaling.
What you can do after
Evaluate database scalability against view load and availability requirements, and understand how partitioned receivers preserve message order.
How it connects
Connects message brokers, sharded channels, consumer groups, CQRS, NoSQL databases, and vertical scaling.

Also explained in

Compare how 19 books explain horizontal scaling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.