Skip to content

Commit

Permalink
[smithy-rs] Establish default max idle connections on default connect…
Browse files Browse the repository at this point in the history
…ors (#2064)
  • Loading branch information
jdisanti authored and aws-sdk-rust-ci committed Dec 14, 2022
1 parent bb6e5eb commit be76de4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions sdk/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
4 changes: 2 additions & 2 deletions versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smithy_rs_revision = '6beec943ab767a791a414bbaef1acb4b363f7042'
smithy_rs_revision = '31f1d35b624bfd4f66d9edb434d9239c36ba4171'
aws_doc_sdk_examples_revision = 'f88a0edba3961f9d978bf1727054c9414e4fca2b'

[manual_interventions]
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit be76de4

Please sign in to comment.