You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/ipc/design.md
+25-19Lines changed: 25 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,32 +30,14 @@ flowchart TD
30
30
31
31
```
32
32
33
-
## Choosing a multiplexer
34
-
The multiplexer adds a custom layer on top of the socket that allows running servers on both ends of the socket.
35
-
36
-
### nri/net/multiplex - a minimal multiplexer
37
-
The plugin system in [containerd/nr](https://github.com/containerd/nri) implements its own simple frame-based multiplexer [nri/net/multiplex](https://github.com/containerd/nri/tree/main/pkg/net/multiplex).
38
-
It provides two streams on each side that need to be re-used for all communication.
39
-
This works well for [ttrpc](https://github.com/containerd/ttrpc) which uses its own length-prefixed framing.
40
-
However, the standard Go HTTP server inside `Server(net.Listener)` does one `Accept()`, gets one `net.Conn`, and then loops inside serveConn to decode requests.
41
-
But because that sub-connection isn’t a real socket—and because the mux delivers no further “new connections” and any pipelined data after the first request can get lost or stuck in the mux’s framing, and the server never sees it.
42
33
43
-
Alternatively, HTTP/2 without TLS could be used as it gives control over the framing.
44
-
Unfortunately, Go's `net/http` package does not easily support HTTP/2 without TLS and getting it to work comes with its own set of challenges, such as requiring a custom `net.Listener` implementation that handles the HTTP/2 framing.
45
-
46
-
TLDR: [nri/net/multiplex](https://github.com/containerd/nri/tree/main/pkg/net/multiplex) is not ideal for general HTTP servers.
47
-
48
-
### Yamux
49
-
50
-
Yamux is a full-featured, multiplexing protocol that allows multiple streams to be sent over a single TCP connection. It is actively maintained by Hashicorp and is used by Hashicorp's Nomad.
51
-
Using Yamux we get Go's `net/http` out-of-the-box.
52
34
53
35
54
36
## Decisions
55
37
56
38
---
57
39
58
-
2025-07-02 IPC stack
40
+
### 2025-07-02 settling on yamux + connect rpc for the IPC stack
59
41
60
42
The IPC stack consists of multiple parts that need to play well together:
61
43
- socket multiplexing
@@ -80,3 +62,27 @@ In addition, the main performance bottleneck will be within the actual plugins d
80
62
81
63
---
82
64
65
+
### 2025-06-27 dropping nri/net/multiplex in favor of yamux
66
+
67
+
The multiplexer adds a custom layer on top of the socket that allows running servers on both ends of the socket.
68
+
69
+
#### nri/net/multiplex - a minimal multiplexer
70
+
71
+
The plugin system in [containerd/nri](https://github.com/containerd/nri) implements its own simple frame-based multiplexer [nri/net/multiplex](https://github.com/containerd/nri/tree/main/pkg/net/multiplex).
72
+
It provides two streams on each side that need to be re-used for all communication.
73
+
This works well for [ttrpc](https://github.com/containerd/ttrpc) which uses its own length-prefixed framing.
74
+
However, the standard Go HTTP server inside `Server(net.Listener)` does one `Accept()`, gets one `net.Conn`, and then loops inside serveConn to decode requests.
75
+
I.e. it tries to create (and on completion closes) a new stream per request but using nri/net/multiplex gets stuck as nri/net/multiplex is only design to return one stream per lifetime.
76
+
77
+
Alternatively, HTTP/2 without TLS could be used as it gives control over the framing.
78
+
Unfortunately, Go's `net/http` package does not easily support HTTP/2 without TLS and getting it to work comes with its own set of challenges, such as requiring a custom `net.Listener` implementation that handles the HTTP/2 framing.
79
+
80
+
TLDR: [nri/net/multiplex](https://github.com/containerd/nri/tree/main/pkg/net/multiplex) is not ideal for general HTTP servers.
81
+
82
+
#### Yamux
83
+
84
+
Yamux is a full-featured, multiplexing protocol that allows multiple streams to be sent over a single TCP connection. It is actively maintained by Hashicorp and is used by Hashicorp's Nomad.
85
+
Using Yamux we get Go's `net/http` out-of-the-box.
0 commit comments