From badd7060519f78cd7618733567ea40f1356eb252 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 5 Dec 2022 15:14:59 -0800 Subject: [PATCH 1/3] Establish default max idle connections on default connectors --- rust-runtime/aws-smithy-client/src/builder.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rust-runtime/aws-smithy-client/src/builder.rs b/rust-runtime/aws-smithy-client/src/builder.rs index 4a1b62fb85..674f0595e5 100644 --- a/rust-runtime/aws-smithy-client/src/builder.rs +++ b/rust-runtime/aws-smithy-client/src/builder.rs @@ -87,6 +87,18 @@ 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. +const DEFAULT_MAX_IDLE_CONNECTIONS: usize = 70; + +/// Returns default HTTP client settings for hyper. +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 Builder<(), M, R> { /// Connect to the service over HTTPS using Rustls using dynamic dispatch. @@ -96,6 +108,7 @@ impl Builder<(), M, R> { ) -> Builder { self.connector(DynConnector::new( HyperAdapter::builder() + .hyper_builder(default_hyper_builder()) .connector_settings(connector_settings) .build(crate::conns::https()), )) @@ -112,6 +125,7 @@ impl Builder<(), M, R> { ) -> Builder { self.connector(DynConnector::new( HyperAdapter::builder() + .hyper_builder(default_hyper_builder()) .connector_settings(connector_settings) .build(crate::conns::native_tls()), )) From 2a6704657864ab2b908db4f543d633faef578b68 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 5 Dec 2022 15:36:28 -0800 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.next.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index c7a74a8cde..a4eb7a9e2c 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -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" From 089daf4105d22034935743788c64039f826de37f Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 5 Dec 2022 16:17:13 -0800 Subject: [PATCH 3/3] Fix build with no default features --- rust-runtime/aws-smithy-client/src/builder.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust-runtime/aws-smithy-client/src/builder.rs b/rust-runtime/aws-smithy-client/src/builder.rs index 674f0595e5..0ed68ec0f4 100644 --- a/rust-runtime/aws-smithy-client/src/builder.rs +++ b/rust-runtime/aws-smithy-client/src/builder.rs @@ -90,9 +90,11 @@ 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);