When a HELICS co-simulation grows beyond a single compute node, message routing between federates that are physically distant from the broker becomes a bottleneck. A single broker handling all traffic for federates spread across many machines means every message must travel to a potentially remote host and back, adding latency to every time-step. Broker hierarchies solve this problem by placing a local broker on each compute node so federates can exchange messages with low latency, while the root broker at the top of the hierarchy handles only the traffic that must cross node boundaries.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/GMLC-TDC/HELICS/llms.txt
Use this file to discover all available pages before exploring further.
Why use multiple brokers
Brokers are responsible for routing messages between federates. As the federation grows and spans multiple machines, the load on the broker and the cost of network round-trips both increase. The worst case arises when two federates on the same node must exchange values but both have a high-latency connection to a distant root broker—their communication is slowed for every single message. The solution is to place a broker on (or near) each compute node. Federates that communicate frequently are co-located and assigned to the same local broker. Messages between co-located federates stay on the local node. Messages that must cross node boundaries travel up the broker hierarchy to a parent broker, which routes them down to the correct sub-broker and on to the destination federate.For small co-simulations where all federates run on a single machine, a single broker is sufficient. Broker hierarchies are most beneficial when federates are deployed across multiple compute nodes.
Root broker and sub-broker topology
A broker hierarchy consists of:- Root broker — the broker at the top of the hierarchy. It is the broker of last resort and can route messages to any federate in the entire federation. It has no parent broker.
- Sub-brokers — brokers that connect upward to a parent broker (or the root broker) and downward to federates or further sub-brokers. They route local traffic themselves and pass unresolvable messages up the hierarchy.
Configuring a broker hierarchy
Each component in a hierarchy needs to know the address of its parent broker, and the root broker needs to know how many sub-brokers and federates to expect.Federate configuration
Federates must point to their local sub-broker. UsecoreInit in a JSON configuration file:
Sub-broker launch
A sub-broker must declare how many federates it expects (-f) and supply the --broker_address of its parent (the root broker):
Root broker launch
The root broker specifies how many direct federates (-f) and how many sub-brokers (--sub_brokers) are expected to connect. It does not supply a --broker_address because it has no parent:
Port configuration for complex networks
In environments with firewalls or strict networking policies, you may need to specify explicit port numbers. There are two ways to add a port:- Append
:<port>to the IP address inbroker_address, for exampletcp://127.0.0.1:23405. - Use the dedicated options
--broker_portand--local_port.
| Option | Purpose |
|---|---|
broker_address | IP (and optionally port) of the parent broker to connect to |
broker_port | Port number on the parent broker to connect to |
local_port | Port on which this component listens for incoming connections |
local_interface | IP address and/or socket this component listens on |
Example with explicit ports
Federate connecting to sub-broker A on port 25000, and advertising itself on port 23500:Multi-machine setup
For federates running on separate physical machines, each federate must be told where to find its broker using a routable IP address. The broker must also open an external-facing port by passing the--ipv4 flag:
Start the root broker on the broker machine
--ipv4 flag opens ports on all external IPv4 interfaces so remote machines can connect.Start sub-brokers on each compute node
Each sub-broker points to the root broker’s routable IP address:
Running simultaneous co-simulations with BrokerServer
If multiple independent co-simulations need to run on the same machine at the same time, each co-simulation needs its own broker on separate ports. Thehelics_broker_server automates this by dynamically assigning brokers and ports on demand.
Isolating co-simulations with keys
When multiple users share a machine, a broker key prevents accidental cross-talk between independent federations:Example: launching a root broker and sub-broker
The following walkthrough shows the minimal launch sequence for a two-level hierarchy with one sub-broker:
A full working example with source code is available in the HELICS Examples repository.