Skip to content

Commit e78a764

Browse files
committed
feat(sdk): disable http keepalive
1 parent c24d69c commit e78a764

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

internal/ipc/design.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,30 @@ Yamux is a full-featured, multiplexing protocol that allows multiple streams to
5151
Using Yamux we get Go's `net/http` out-of-the-box.
5252

5353

54+
## Decisions
5455

56+
---
57+
58+
2025-07-02 IPC stack
59+
60+
The IPC stack consists of multiple parts that need to play well together:
61+
- socket multiplexing
62+
- API format (includes networking protocol + serialization format)
63+
64+
At this point in time we have decided to go with yamux + connect rpc.
65+
Connect rpc in itself uses protobuf for data serialization combined with gRPC over http for networking.
66+
A main advantage is that we can keep using Go's standard library's `net/http` stack for server and client.
67+
See [Connect: A better gRPC](https://buf.build/blog/connect-a-better-grpc) for a detailed comparison against e.g.`grpc-go`.
68+
Also connect rpc is part of CNCF ([source](https://www.cncf.io/projects/connect-rpc/)).
69+
70+
Potential drawbacks: Performance
71+
72+
Using [nri/net/multiplex](https://github.com/containerd/nri/tree/main/pkg/net/multiplex) with [ttrpc](https://github.com/containerd/ttrpc) probably would be the most performance optimised solution.
73+
It re-uses one stream over the multiplexed socket per direction and has overhead of the http protocol as protobuf gets streamed directly over the multiplexer.
74+
However, it has stopped evolving and e.g. has not caught up on latest improvements on protobuf.
75+
Another major downside is that it's mainly Go only, i.e., supporting alternative languages for plugins would come at a high cost.
76+
We argue that in our use case, as the networking only happens locally so the overhead of grpc over http and the cost of opening a new yamux stream are negligible.
77+
In addition, the main performance bottleneck will be within the actual plugins, e.g., because authentication needs to happen, disk access or because (slow) external networking access is required.
78+
79+
---
5580

internal/ipc/ipc.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ func waitForClientToDisconnect(s *yamux.Session, t time.Duration) {
132132
return
133133
}
134134
streams := s.NumStreams()
135-
// 1 stream is the control stream (todo: verify)
136-
// TODO: https://github.com/docker/secrets-engine/issues/71
137-
if streams <= 1 {
135+
if streams <= 0 {
138136
return
139137
}
140138
}
@@ -149,6 +147,7 @@ func createYamuxedClient(session *yamux.Session) *http.Client {
149147
DialContext: func(context.Context, string, string) (net.Conn, error) {
150148
return session.Open()
151149
},
150+
DisableKeepAlives: true,
152151
}
153152
return &http.Client{Transport: transport}
154153
}

0 commit comments

Comments
 (0)