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

7
# Dynamo Event Plane
8

9
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.
10

11
## When Is the Event Plane Used?
12

13
Key use cases:
14

15
16
17
- **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.
18

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

21
## Choosing a Transport
22

23
The event plane supports two transports:
24

25
26
27
28
29
| | 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 |
30

31
## Configuration
32

33
### Transport Selection
34

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

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

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

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

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

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

55
### Environment Variables
56
57
58

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

62
## NATS Transport
63

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

66
67
68
- 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.
69

70
Example setup:
71
72

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

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

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

83
## ZMQ Transport
84

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

87
88
89
90
91
- 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:
92
93

```bash
94
export DYN_EVENT_PLANE=zmq
95

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

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

103
## Disabling the Event Plane
104

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

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

With `--no-kv-events`:

113
114
115
- 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.
116

117
## Deployment Modes
118

119
### Bare Metal / Local
120

121
Both transports work out of the box:
122
123

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

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

131
132
133
### 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.
134
135
136

## Related Documentation

137
138
139
140
- [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