@@ -87,6 +87,20 @@ use crate::http_connector::ConnectorSettings;
87
87
#[ cfg( any( feature = "rustls" , feature = "native-tls" ) ) ]
88
88
use crate :: hyper_ext:: Adapter as HyperAdapter ;
89
89
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
+
90
104
#[ cfg( feature = "rustls" ) ]
91
105
impl < M , R > Builder < ( ) , M , R > {
92
106
/// Connect to the service over HTTPS using Rustls using dynamic dispatch.
@@ -96,6 +110,7 @@ impl<M, R> Builder<(), M, R> {
96
110
) -> Builder < DynConnector , M , R > {
97
111
self . connector ( DynConnector :: new (
98
112
HyperAdapter :: builder ( )
113
+ . hyper_builder ( default_hyper_builder ( ) )
99
114
. connector_settings ( connector_settings)
100
115
. build ( crate :: conns:: https ( ) ) ,
101
116
) )
@@ -112,6 +127,7 @@ impl<M, R> Builder<(), M, R> {
112
127
) -> Builder < DynConnector , M , R > {
113
128
self . connector ( DynConnector :: new (
114
129
HyperAdapter :: builder ( )
130
+ . hyper_builder ( default_hyper_builder ( ) )
115
131
. connector_settings ( connector_settings)
116
132
. build ( crate :: conns:: native_tls ( ) ) ,
117
133
) )
0 commit comments