Skip to content

fix: [stable-9.0][OCISDEV-1724] reuse HTTP connections in the reva clients - #826

Merged
2403905 merged 1 commit into
stable-9.0from
fix/9.0/OCISDEV-1724
Nov 20, 2026
Merged

2403905 merged 1 commit into
stable-9.0from
fix/9.0/OCISDEV-1724

Conversation

@2403905

@2403905 2403905 commented Nov 20, 2026

Copy link
Copy Markdown

Backport of #824 to stable-9.0.

Problem

Under high load, the HTTP clients of reva open a new connection for most requests. The default transport of Go keeps 2 idle connections for each host. The extra connections close after each request. The host runs out of ports. This causes failed requests.

Ticket: OCISDEV-1724. The load test numbers and the analysis are in the ticket.

Change

  1. pkg/storage/utils/metadata/cs3.go: the metadata client uses its own transport. All CS3 instances share it. It keeps up to 100 idle connections for each host.
  2. pkg/rhttp/client.go: GetHTTPClient keeps up to 100 idle connections for each host. The ocdav service and the data gateway use this function.
  3. Both clients close an idle connection after 30 seconds. A load balancer or an ingress controller often closes an idle connection after 60 seconds. The client must close first.

Difference from #824

On stable-9.0, GetHTTPClient wraps the transport in autoprop.NewHttpRoundTripper. The test of #824 cannot get the *http.Transport through this wrapper. The new function newTransport in pkg/rhttp/client.go builds the base transport. The test checks the settings of this transport. The behavior of GetHTTPClient does not change.

Tests

  • I ran go test -race for ./pkg/rhttp/ and ./pkg/storage/utils/metadata/. All tests pass.
  • I set the limit back to 2. Then TestGetHTTPClientReusesConnections fails. The test checks the full client with the autoprop wrapper.

Next step

After this PR is merged, the oCIS go.mod on stable-9.0 needs a bump.

🤖 Generated with Claude Code

…ients

Under high load, the HTTP clients of reva opened a new connection for most
requests. The default transport of Go keeps 2 idle connections for each host.
The extra connections close after each request. The host runs out of ports.

1. The metadata client uses its own transport. All CS3 instances share it.
2. The function GetHTTPClient keeps up to 100 idle connections for each host.
   The ocdav service and the data gateway use this function.
3. Both clients close an idle connection after 30 seconds. A load balancer or
   an ingress controller often closes an idle connection after 60 seconds.
   The client must close first. The transport does not repeat a PUT or POST
   request on a connection that the other side closed.

On this branch, GetHTTPClient wraps the transport in an autoprop round
tripper. The new function newTransport builds the base transport, so that
the test can check its settings.

Tests send two bursts of parallel requests. The second burst reuses the idle
connections of the first burst.

Backport of #824 (cherry picked from commit af7eb0a).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@2403905
2403905 requested a review from a team as a code owner November 20, 2026 12:45
@kw-security

kw-security commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@2403905
2403905 merged commit 1cd8e7f into stable-9.0 Nov 20, 2026
14 checks passed
@2403905
2403905 deleted the fix/9.0/OCISDEV-1724 branch November 20, 2026 13:51
2403905 added a commit to owncloud/ocis that referenced this pull request Nov 20, 2026
Under high load, the proxy opened a new connection for most requests. The
host ran out of ports. This caused failed logins and failed requests.

1. The backend transport keeps up to 100 idle connections for each backend.
   Before, it kept 2. It has no global limit for idle connections.
2. The OIDC client keeps its connections alive. Before, it opened a new
   connection with a new TLS handshake for each call.
3. Both close an idle connection after 30 seconds. Before, the proxy used 90
   seconds. A load balancer or an ingress controller often closes an idle
   connection after 60 seconds. The proxy must close first.
4. Bump reva to get the same fix for the reva HTTP clients (owncloud/reva#826).

Tests send two bursts of parallel requests. The second burst reuses the idle
connections of the first burst.

Backport of #13539.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Roman Perekhod <[email protected]>
2403905 added a commit to owncloud/ocis that referenced this pull request Nov 20, 2026
…13542)

* fix: [stable-9.0][OCISDEV-1724] reuse HTTP connections in the proxy

Under high load, the proxy opened a new connection for most requests. The
host ran out of ports. This caused failed logins and failed requests.

1. The backend transport keeps up to 100 idle connections for each backend.
   Before, it kept 2. It has no global limit for idle connections.
2. The OIDC client keeps its connections alive. Before, it opened a new
   connection with a new TLS handshake for each call.
3. Both close an idle connection after 30 seconds. Before, the proxy used 90
   seconds. A load balancer or an ingress controller often closes an idle
   connection after 60 seconds. The proxy must close first.
4. Bump reva to get the same fix for the reva HTTP clients (owncloud/reva#826).

Tests send two bursts of parallel requests. The second burst reuses the idle
connections of the first burst.

Backport of #13539.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Roman Perekhod <[email protected]>

* fix: [OCISDEV-1724] bump reva to the merge commit

Reva merged the fix for the HTTP clients. Point go.mod to the merge commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Roman Perekhod <[email protected]>

---------

Signed-off-by: Roman Perekhod <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants