mirror of https://github.com/smithy-lang/smithy-rs
Establish default max idle connections on default connectors (#2064)
This commit is contained in:
parent
ddf1421be2
commit
31f1d35b62
|
@ -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"
|
|
@ -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()),
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue