Skip to content
Communication pattern

Communication pattern

This page describes how the different hosts of the dAIEdge-VLab cluster communicate together, and how a user request eventually reaches the right service, wherever it is currently running. It builds on top of the Host and Scheduler pages : the software stack described there (Wireguard, Nomad, Consul, Docker) is what makes the communication pattern described below possible.

Overview

The dAIEdge-VLab cluster is a set of hosts that do not know each other’s public network location in advance. To work around this, the cluster is built as three layers stacked on top of each other :

  1. Wireguard interconnects every host into a single private mesh network, regardless of where the host is physically located (behind a NAT, a firewall, on a different network, …).
  2. Nomad, together with Consul, uses this private mesh to orchestrate jobs and services across the cluster, and to keep track of which host is currently running what.
  3. Fabio runs on every host and exposes it as a public entry point. A Fabio gateway does not necessarily serve the request itself, it looks up Consul to forward the request, over the Wireguard mesh, to whichever host is actually running the requested service.

The consequence of this design is that any host of the cluster can be used as the public entry point, no matter where the requested service (API, web interface, a given benchmark, …) is actually running.

Wireguard : a private mesh network

Every host runs Wireguard and joins the same mesh network, each host is a peer of every other host. Once connected, hosts communicate using their private mesh IP address instead of their public one, which removes the need for hosts to be publicly reachable on the internet or to have a static public IP.

As described in the Host page, a VPN Service job runs on every node of the cluster. It is responsible for maintaining and updating the local Wireguard configuration so that the mesh stays up to date as hosts join or leave the cluster. The peer information needed to keep the mesh consistent (public keys, mesh IP addresses, endpoints) is kept in the Shared DB, so that any host can (re)build its Wireguard configuration from it.

    sequenceDiagram
    participant A as Host A
    participant B as Host B
    participant C as Host C
    participant D as Host D
    A-->>B: Wireguard tunnel
    A-->>C: Wireguard tunnel
    A-->>D: Wireguard tunnel
    B-->>C: Wireguard tunnel
    B-->>D: Wireguard tunnel
    C-->>D: Wireguard tunnel
    Note over A,D: Every host is a direct peer of every other host
  
No manual configuration: You do not need to configure Wireguard yourself when integrating a host. The dAIEdge-VLab SDK and the VPN Service job take care of joining and maintaining the mesh for you.

Nomad and Consul : orchestration over the mesh

Once the hosts are joined into the Wireguard mesh, they form a single Nomad cluster reachable over their private mesh addresses. A leader is elected among the hosts, and it is responsible for scheduling jobs (benchmarks, but also the dAIEdge-VLab’s own services) on the most suitable host, as detailed in the Scheduler page.

Because services can be (re)scheduled by Nomad on any host of the cluster at any time (for example after a leader change, or to rebalance the load), the cluster also runs Consul next to Nomad. Consul continuously keeps track of which host and port is currently serving each service (API, web interface, gateway, a given benchmark job, …), acting as the source of truth used to route a request to the right place.

Fabio : every host is a public entry point

Every host also runs a Fabio gateway. Fabio is a Consul-aware HTTP(S) router : instead of serving requests itself, it watches the Consul service catalog and forwards each incoming request to whichever host is currently registered as running the requested service, over the Wireguard mesh.

This has an important consequence : since every host runs the same Fabio gateway and reads from the same Consul catalog, it does not matter which host’s public address a request lands on. A request can reach the dAIEdge-VLab through the public entry point of any host, and will transparently be routed, over the private mesh, to the host actually running the target service, whether that is the same host or a different one.

    sequenceDiagram
    participant User
    participant Fabio as Fabio Gateway (Host A, public)
    participant Consul
    participant Host as Service (Host B, private mesh)

    User->>Fabio: HTTPS request (e.g. vlab.daiedge.eu)
    Fabio->>Consul: Lookup service location
    Consul-->>Fabio: Host B, port X
    Fabio->>Host: Forward request over Wireguard mesh
    Host-->>Fabio: Response
    Fabio-->>User: Response
  
Resiliency: Because any host can act as the entry point, the cluster does not depend on a single host being reachable to be usable. If the host that first receives a request is not the one running the target service, Fabio simply forwards it to the right one.

Current limitation: This resiliency only applies once a request has actually reached one of the hosts, getting there in the first place is not distributed yet. Making the domain itself point at a set of hosts instead of a fixed one runs into two compounding issues :

  • DNS failover : plain DNS can list several IPs for a name, but picking one and steering away from a dead one requires a DNS provider that actively health-checks the hosts, which is a heavier piece of infrastructure than a simple dynamic DNS updater.
  • Certificate issuance : sharing one TLS certificate across every host is not the hard part, it can be distributed to all Fabio instances. The hard part is renewing it automatically : the usual HTTP-01 challenge must be answered by the exact host that requested it, which breaks as soon as the domain can resolve to more than one, or a different, host. Avoiding this requires a DNS-01 challenge instead, which needs the DNS provider’s API to be automated too.

For now, vlab.daiedge.eu therefore resolves to a single, fixed node of the cluster, which is also the node that terminates HTTPS for the domain. If that specific node becomes unreachable, the domain becomes unreachable with it, even if the rest of the cluster and the requested service are still healthy.

Putting it all together

These three layers are complementary and each solve a different problem :

  • Wireguard solves connectivity : it gives every host a stable, private address to reach every other host, regardless of their public network setup.
  • Nomad and Consul solve placement : they decide which host runs what, and keep track of where it currently runs.
  • Fabio solves access : it turns every host into a valid public entry point, hiding the actual placement decided by Nomad from the end user.

Together, they allow the benchmark lifecycle described in the architecture overview to work transparently across a distributed and dynamic set of hosts : a user request can enter through any host, and always reaches the API, the web interface, or the benchmark job it is meant for.