Unverified Commit 31f1d35b authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Establish default max idle connections on default connectors (#2064)

parent ddf1421b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -649,3 +649,15 @@ message = "Added SmithyEndpointStage which can be used to set an endpoint for sm
references = ["smithy-rs#2063"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "rcoh"

[[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"
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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()),
        ))
@@ -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()),
        ))