event-plane.md 4.44 KB
Newer Older
1
2
3
4
5
---
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
---

6
# Dynamo Event Plane
7

8
The event plane provides Dynamo with a pub/sub layer for near real-time event exchange between components. It delivers KV cache updates, worker load metrics, and sequence tracking events, enabling features like KV-aware routing and disaggregated serving.
9

10
## When Is the Event Plane Used?
11

12
Key use cases:
13

14
15
16
- **KV cache events** -- Workers publish cache state so the router can make cache-aware scheduling decisions.
- **Worker load metrics** -- Workers report utilization so the router can balance load.
- **Sequence tracking** -- Coordinates active sequences across router replicas for fault-tolerant routing.
17

18
![Event plane architecture showing NATS and ZMQ transport options connecting Frontend, Planner, and Worker](../../assets/img/event-plane-transport.svg)
19

20
## Choosing a Transport
21

22
The event plane supports two transports:
23

24
25
26
27
28
| | NATS (default) | ZMQ |
|---|---|---|
| **External infrastructure** | Requires a NATS server | None (peer-to-peer) |
| **Setup complexity** | Simple -- point at a NATS server | Automatic -- workers bind sockets and register via discovery |
| **Best for** | Large-scale deployments | Low operational overhead |
29

30
## Configuration
31

32
### Transport Selection
33

34
Set the `DYN_EVENT_PLANE` environment variable to choose a transport:
35
36

```bash
37
38
# Use NATS (default -- no need to set explicitly)
export DYN_EVENT_PLANE=nats
39

40
41
# Use ZMQ
export DYN_EVENT_PLANE=zmq
42
43
```

44
Python components also accept this as a CLI flag:
45

46
47
48
```bash
# vLLM backend
python3 -m dynamo.vllm --event-plane zmq --model Qwen/Qwen3-0.6B
49

50
51
# SGLang backend
python3 -m dynamo.sglang --event-plane zmq --model Qwen/Qwen3-0.6B
52
53
```

54
### Environment Variables
55
56
57

| Variable | Description | Default |
|----------|-------------|---------|
58
59
| `DYN_EVENT_PLANE` | Transport: `nats` or `zmq` | `nats` |
| `NATS_SERVER` | NATS server URL (NATS transport only) | `nats://localhost:4222` |
60

61
## NATS Transport
62

63
When using NATS (`DYN_EVENT_PLANE=nats` or unset):
64

65
66
67
- Requires a running NATS server. Set `NATS_SERVER` if it is not on `localhost:4222`.
- Events are published to NATS subjects scoped by namespace and component.
- Built-in reconnection and message buffering during brief disconnections.
68

69
Example setup:
70
71

```bash
72
73
export NATS_SERVER=nats://nats-server:4222
export DYN_EVENT_PLANE=nats
74

75
76
# Start workers -- they publish events to NATS automatically
python3 -m dynamo.vllm --model Qwen/Qwen3-0.6B
77

78
79
# Start frontend -- it subscribes to events from NATS automatically
python3 -m dynamo.frontend --router-mode kv
80
81
```

82
## ZMQ Transport
83

84
When using ZMQ (`DYN_EVENT_PLANE=zmq`):
85

86
87
88
89
90
- No external server required. Each worker binds a ZMQ PUB socket and advertises its address through the discovery system.
- Subscribers automatically discover and connect to all active publishers.
- When publishers come and go (e.g., workers scaling up/down), subscribers dynamically adjust their connections.

Example setup:
91
92

```bash
93
export DYN_EVENT_PLANE=zmq
94

95
96
# Start workers -- each binds a ZMQ socket, registers with discovery
python3 -m dynamo.vllm --model Qwen/Qwen3-0.6B
97

98
99
# Start frontend -- discovers workers and connects directly
python3 -m dynamo.frontend --router-mode kv
100
101
```

102
## Disabling the Event Plane
103

104
If you do not need KV-aware routing, you can disable the event plane entirely:
105
106

```bash
107
python3 -m dynamo.frontend --router-mode kv --no-kv-events
108
109
110
111
```

With `--no-kv-events`:

112
113
114
- The router falls back to prediction-based cache-aware routing (estimates cache state from routing decisions).
- No NATS server or ZMQ sockets are needed.
- TTL-based expiration and LRU pruning keep predicted state from growing stale.
115

116
## Deployment Modes
117

118
### Bare Metal / Local
119

120
Both transports work out of the box:
121
122

```bash
123
124
125
126
127
# NATS (requires nats-server running)
export NATS_SERVER=nats://localhost:4222

# OR ZMQ (no extra infrastructure)
export DYN_EVENT_PLANE=zmq
128
129
```

130
131
132
### Kubernetes (with Dynamo Operator)

The operator can inject `DYN_EVENT_PLANE` into pods. The same transport options apply. If using NATS, deploy a NATS server in the cluster and set `NATS_SERVER` accordingly.
133
134
135

## Related Documentation

136
137
138
139
- [Discovery Plane](discovery-plane.md) -- Service discovery and coordination (etcd, Kubernetes)
- [Distributed Runtime](distributed-runtime.md) -- Runtime architecture
- [Request Plane](request-plane.md) -- Request transport configuration
- [Fault Tolerance](../fault-tolerance/README.md) -- Failure handling