Skip to content

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

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

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

Conversation

@2403905

@2403905 2403905 commented Nov 20, 2026

Copy link
Copy Markdown

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. The Go transport does not repeat a PUT or POST request on a connection that the other side closed.

Tests

  • Two bursts of 20 parallel requests go to a local server. The second burst must open at most 2 new connections. With the old limit of 2, it opens 18. I checked that the rhttp test fails with the old limit.
  • Unit tests check the transport settings.
  • I ran go test -race for ./pkg/rhttp/... and ./pkg/storage/utils/metadata/.... All tests pass.
  • I did not run a load test with this version.

Next step

After this PR is merged, the oCIS go.mod needs a bump. The oCIS PR is in preparation.

🤖 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.

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

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@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.

Comment thread pkg/rhttp/client_test.go
@@ -0,0 +1,102 @@
// Copyright 2018-2021 CERN

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why CERN copyright on top?

@2403905
2403905 merged commit af7eb0a into stable-8.0 Nov 20, 2026
16 checks passed
@2403905
2403905 deleted the fix/8.0/OCISDEV-1724 branch November 20, 2026 11:29
2403905 added a commit that referenced this pull request Nov 20, 2026
…ients (#826)

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]>
2403905 added a commit that referenced this pull request Nov 20, 2026
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]>
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.

5 participants