Skip to content

configure max idle connections to s3#808

Closed
chris-smith-zocdoc wants to merge 3 commits intobuchgr:masterfrom
Zocdoc:cs_idle_conns
Closed

configure max idle connections to s3#808
chris-smith-zocdoc wants to merge 3 commits intobuchgr:masterfrom
Zocdoc:cs_idle_conns

Conversation

@chris-smith-zocdoc
Copy link
Contributor

Fixes #675

This resulted in a significant cpu reduction in our environment

log.Fatalf("Failed to create default transport: %v", err)
}

tr.MaxIdleConns = MaxIdleConns
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The minio default for MaxIdleConnsPerHost is 16, which was causing excessive tls negotiation even with a modest concurrency level (~200 concurrent connections)

https://github.com/minio/minio-go/blob/1e5fd8a9ce3588100e5be814f564fd78436aa5f4/transport.go#L51-L52

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which values did you find the best?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our setup its rare for us to exceed 200 concurrent, as we tend to be very bursty, 0 -> 200 -> 0 within a very small window. I expect this to change as our baseline load increases though.

We're using Pants and there are two settings that define the max concurrency per client remote_cache_rpc_concurrency / remote_store_rpc_concurrency at 128 each. We'll occasionally have more than one client making requests concurrently, but because they're generally very fast they often don't overlap given our current workload.

}

secure := !DisableSSL
tr, err := minio.DefaultTransport(secure)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe enabling ClientSessionCache

tr.TLSClientConfig.ClientSessionCache = tls.NewLRUClientSessionCache(64)

may further improve this, but am not familiar enough with it to know if there are any drawbacks. Should I add that in this pr too? Should it be under a separate flag?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably needs some profiling before we consider changing the default. A separate PR would be best.

Copy link
Collaborator

@mostynb mostynb left a comment

Choose a reason for hiding this comment

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

Hi- thanks for the contribution.

&cli.IntFlag{
Name: "s3.max_idle_conns",
Usage: "The maximum number of idle connections to use when using the S3 proxy backend.",
DefaultText: "1024",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this correct? The link to minio code shows 256 (and 16 per host).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think I should preserve the existing defaults? In practice I think they're not good for bazel-remote, which I why I changed it here.

MaxIdleConnsPerHost: 16 This is the effective limit in place prior to my change, because we're only working with one host, eg s3.us-east-1.amazonaws.com

MaxIdleConns: 256 This would never be used, since we can't exceed MaxIdleConnsPerHost

I can see the argument for compatibility though, and preserving MaxIdleConnsPerHost: 16, but that would also mean adding a second flag for MaxIdleConns: 256 or setting that value to same as MaxIdleConnsPerHost (16)

log.Fatalf("Failed to create default transport: %v", err)
}

tr.MaxIdleConns = MaxIdleConns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which values did you find the best?

}

secure := !DisableSSL
tr, err := minio.DefaultTransport(secure)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably needs some profiling before we consider changing the default. A separate PR would be best.

chris-smith-zocdoc and others added 2 commits April 14, 2025 11:18
Co-authored-by: Mostyn Bramley-Moore <mostyn@antipode.se>
@mostynb
Copy link
Collaborator

mostynb commented Jul 18, 2025

I landed this change with the new default for MaxIdleConns at 1024 (up from effectively 16). Sorry it took so long.

@mostynb mostynb closed this Jul 18, 2025
@chris-smith-zocdoc
Copy link
Contributor Author

Thanks @mostynb !

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.

Large number of TLS handshakes to the S3 proxy

3 participants