From be76de4b64198b5358431912741b35596f279245 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 14 Dec 2022 23:04:37 +0000 Subject: [PATCH] [smithy-rs] Establish default max idle connections on default connectors (#2064) --- sdk/aws-smithy-client/src/builder.rs | 16 ++++++++++++++++ versions.toml | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sdk/aws-smithy-client/src/builder.rs b/sdk/aws-smithy-client/src/builder.rs index 4a1b62fb8545..0ed68ec0f4cf 100644 --- a/sdk/aws-smithy-client/src/builder.rs +++ b/sdk/aws-smithy-client/src/builder.rs @@ -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 Builder<(), M, R> { /// Connect to the service over HTTPS using Rustls using dynamic dispatch. @@ -96,6 +110,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 +127,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()), )) diff --git a/versions.toml b/versions.toml index 137cbbc6df69..2cff9bd025ff 100644 --- a/versions.toml +++ b/versions.toml @@ -1,4 +1,4 @@ -smithy_rs_revision = '6beec943ab767a791a414bbaef1acb4b363f7042' +smithy_rs_revision = '31f1d35b624bfd4f66d9edb434d9239c36ba4171' aws_doc_sdk_examples_revision = 'f88a0edba3961f9d978bf1727054c9414e4fca2b' [manual_interventions] @@ -1936,7 +1936,7 @@ source_hash = 'e79e848e80107d8e7bde7ef2e33a85e95bc03a1aa5e074a016d1340ed3ee6fbb' [crates.aws-smithy-client] category = 'SmithyRuntime' version = '0.51.0' -source_hash = '012fffa414bb08b975517ab72d8ad2dceed3aaffdb96f3fa13e2663654eebf1a' +source_hash = 'ab3eb841d694f4beaca11518627e11f948b7605170f482542af897acd155f518' [crates.aws-smithy-eventstream] category = 'SmithyRuntime'