← Table of Contents · Page 453 of 868
ORCHESTRATION PATTERNS
Part 5 of 11
THE SWARM PATTERN
The Swarm pattern is a design in which many peer agents, with no central boss, pass work directly to one another, with each agent deciding for itself whether to handle a request or route it to a peer better suited to it.
The word "swarm" echoes a flock of birds or a swarm of bees, where order emerges without a single leader giving orders.
A friendly picture is a help desk where the receptionist, the technician, and the billing clerk are equals.
When a customer asks a question, whoever hears it first either answers it or says, "That is a question for Maria," and sends the customer straight to Maria.
There is no manager standing in the middle deciding.
In an agent swarm, a customer query might arrive at a general agent.
That agent determines the query is about billing and hands the conversation directly to the billing agent.
If the billing agent then realizes it is really a technical problem, it hands it to the technical agent.
Each agent decides for itself, based on its own knowledge of what its peers can do.
The strengths are flexibility and the absence of a bottleneck.
It suits highly dynamic and unpredictable workloads, because new specialist agents can be added without rewriting a central coordinator.
The weaknesses are the loss of central visibility and control.
It can be hard to see why a particular route was taken, and agents may bounce a request back and forth in endless circles, a problem related to the deadlocks we will study in Chapter 45.
Because no single place enforces rules, you must be especially careful with permissions and budgets, so each agent should carry its own limits.
The term "swarm" has also been used as a name for specific experimental software, but here we use it in the general sense of peer-to-peer routing.
Advertisement
Read Aloud:
0:00 / 0:00