Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establish default max idle connections on default connectors #2064

Merged
merged 5 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,15 @@ message = "Implementation of the Debug trait for container shapes now redacts wh
references = ["smithy-rs#1983", "smithy-rs#2029"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" }
author = "ysaito1001"

[[aws-sdk-rust]]
message = "The SDK clients now default max idle connections to 70 (previously unlimited) to reduce the likelihood of hitting max file handles in AWS Lambda."
references = ["smithy-rs#2064", "aws-sdk-rust#632"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "Clients now default max idle connections to 70 (previously unlimited) to reduce the likelihood of hitting max file handles in AWS Lambda."
references = ["smithy-rs#2064", "aws-sdk-rust#632"]
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"}
author = "jdisanti"
16 changes: 16 additions & 0 deletions rust-runtime/aws-smithy-client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ use crate::http_connector::ConnectorSettings;
#[cfg(any(feature = "rustls", feature = "native-tls"))]
use crate::hyper_ext::Adapter as HyperAdapter;

/// Max idle connections is not standardized across SDKs. Java V1 and V2 use 50, and Go V2 uses 100.
/// The number below was chosen arbitrarily between those two reference points, and should allow
/// for 14 separate SDK clients in a Lambda where the max file handles is 1024.
#[cfg(any(feature = "rustls", feature = "native-tls"))]
const DEFAULT_MAX_IDLE_CONNECTIONS: usize = 70;

/// Returns default HTTP client settings for hyper.
#[cfg(any(feature = "rustls", feature = "native-tls"))]
fn default_hyper_builder() -> hyper::client::Builder {
let mut builder = hyper::client::Builder::default();
builder.pool_max_idle_per_host(DEFAULT_MAX_IDLE_CONNECTIONS);
builder
}

#[cfg(feature = "rustls")]
impl<M, R> Builder<(), M, R> {
/// Connect to the service over HTTPS using Rustls using dynamic dispatch.
Expand All @@ -96,6 +110,7 @@ impl<M, R> Builder<(), M, R> {
) -> Builder<DynConnector, M, R> {
self.connector(DynConnector::new(
HyperAdapter::builder()
.hyper_builder(default_hyper_builder())
.connector_settings(connector_settings)
.build(crate::conns::https()),
))
Expand All @@ -112,6 +127,7 @@ impl<M, R> Builder<(), M, R> {
) -> Builder<DynConnector, M, R> {
self.connector(DynConnector::new(
HyperAdapter::builder()
.hyper_builder(default_hyper_builder())
.connector_settings(connector_settings)
.build(crate::conns::native_tls()),
))
Expand Down