Skip to content

Commit 31f1d35

Browse files
authored
Establish default max idle connections on default connectors (#2064)
1 parent ddf1421 commit 31f1d35

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.next.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,3 +649,15 @@ message = "Added SmithyEndpointStage which can be used to set an endpoint for sm
649649
references = ["smithy-rs#2063"]
650650
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
651651
author = "rcoh"
652+
653+
[[aws-sdk-rust]]
654+
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."
655+
references = ["smithy-rs#2064", "aws-sdk-rust#632"]
656+
meta = { "breaking" = false, "tada" = false, "bug" = false }
657+
author = "jdisanti"
658+
659+
[[smithy-rs]]
660+
message = "Clients now default max idle connections to 70 (previously unlimited) to reduce the likelihood of hitting max file handles in AWS Lambda."
661+
references = ["smithy-rs#2064", "aws-sdk-rust#632"]
662+
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"}
663+
author = "jdisanti"

rust-runtime/aws-smithy-client/src/builder.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ use crate::http_connector::ConnectorSettings;
8787
#[cfg(any(feature = "rustls", feature = "native-tls"))]
8888
use crate::hyper_ext::Adapter as HyperAdapter;
8989

90+
/// Max idle connections is not standardized across SDKs. Java V1 and V2 use 50, and Go V2 uses 100.
91+
/// The number below was chosen arbitrarily between those two reference points, and should allow
92+
/// for 14 separate SDK clients in a Lambda where the max file handles is 1024.
93+
#[cfg(any(feature = "rustls", feature = "native-tls"))]
94+
const DEFAULT_MAX_IDLE_CONNECTIONS: usize = 70;
95+
96+
/// Returns default HTTP client settings for hyper.
97+
#[cfg(any(feature = "rustls", feature = "native-tls"))]
98+
fn default_hyper_builder() -> hyper::client::Builder {
99+
let mut builder = hyper::client::Builder::default();
100+
builder.pool_max_idle_per_host(DEFAULT_MAX_IDLE_CONNECTIONS);
101+
builder
102+
}
103+
90104
#[cfg(feature = "rustls")]
91105
impl<M, R> Builder<(), M, R> {
92106
/// Connect to the service over HTTPS using Rustls using dynamic dispatch.
@@ -96,6 +110,7 @@ impl<M, R> Builder<(), M, R> {
96110
) -> Builder<DynConnector, M, R> {
97111
self.connector(DynConnector::new(
98112
HyperAdapter::builder()
113+
.hyper_builder(default_hyper_builder())
99114
.connector_settings(connector_settings)
100115
.build(crate::conns::https()),
101116
))
@@ -112,6 +127,7 @@ impl<M, R> Builder<(), M, R> {
112127
) -> Builder<DynConnector, M, R> {
113128
self.connector(DynConnector::new(
114129
HyperAdapter::builder()
130+
.hyper_builder(default_hyper_builder())
115131
.connector_settings(connector_settings)
116132
.build(crate::conns::native_tls()),
117133
))

0 commit comments

Comments
 (0)