Skip to content

Commit 25cfa94

Browse files
authored
Default the protocol detection timeout to 10s (#782)
The proxy fails connections that do not complete protocol detection within a given timeout. This timeout has been derived from the request-level dispatch timeout; but in practice, many applications may create idle connections, i.e. in a connection pool, and distribute requests over them as requests or events come into the application. In order to better-support these applications, we want to extend the detection timeout to permit idle connections to be established without failing them eagerly; though we do not want to increase the request-level dispatch timeout, as that can lead to undesirable memory pressure and request-level latency. This change creates a dedicated pair of configurations for the detection timeout, decoupled from the dispatch timeout, and sets its default to 10s.
1 parent a2ef4a7 commit 25cfa94

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

linkerd/app/src/env.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const ENV_INGRESS_MODE: &str = "LINKERD2_PROXY_INGRESS_MODE";
6767
const ENV_INBOUND_DISPATCH_TIMEOUT: &str = "LINKERD2_PROXY_INBOUND_DISPATCH_TIMEOUT";
6868
const ENV_OUTBOUND_DISPATCH_TIMEOUT: &str = "LINKERD2_PROXY_OUTBOUND_DISPATCH_TIMEOUT";
6969

70+
const ENV_INBOUND_DETECT_TIMEOUT: &str = "LINKERD2_PROXY_INBOUND_DETECT_TIMEOUT";
71+
const ENV_OUTBOUND_DETECT_TIMEOUT: &str = "LINKERD2_PROXY_OUTBOUND_DETECT_TIMEOUT";
72+
7073
const ENV_INBOUND_CONNECT_TIMEOUT: &str = "LINKERD2_PROXY_INBOUND_CONNECT_TIMEOUT";
7174
const ENV_OUTBOUND_CONNECT_TIMEOUT: &str = "LINKERD2_PROXY_OUTBOUND_CONNECT_TIMEOUT";
7275

@@ -170,14 +173,16 @@ pub const DEFAULT_INBOUND_LISTEN_ADDR: &str = "0.0.0.0:4143";
170173
pub const DEFAULT_CONTROL_LISTEN_ADDR: &str = "0.0.0.0:4190";
171174
const DEFAULT_ADMIN_LISTEN_ADDR: &str = "127.0.0.1:4191";
172175
const DEFAULT_METRICS_RETAIN_IDLE: Duration = Duration::from_secs(10 * 60);
173-
const DEFAULT_INBOUND_DISPATCH_TIMEOUT: Duration = Duration::from_secs(5);
176+
const DEFAULT_INBOUND_DISPATCH_TIMEOUT: Duration = Duration::from_secs(1);
177+
const DEFAULT_INBOUND_DETECT_TIMEOUT: Duration = Duration::from_secs(10);
174178
const DEFAULT_INBOUND_CONNECT_TIMEOUT: Duration = Duration::from_millis(100);
175179
const DEFAULT_INBOUND_CONNECT_BACKOFF: ExponentialBackoff = ExponentialBackoff {
176180
min: Duration::from_millis(100),
177181
max: Duration::from_millis(500),
178182
jitter: 0.1,
179183
};
180-
const DEFAULT_OUTBOUND_DISPATCH_TIMEOUT: Duration = Duration::from_secs(5);
184+
const DEFAULT_OUTBOUND_DISPATCH_TIMEOUT: Duration = Duration::from_secs(3);
185+
const DEFAULT_OUTBOUND_DETECT_TIMEOUT: Duration = Duration::from_secs(10);
181186
const DEFAULT_OUTBOUND_CONNECT_TIMEOUT: Duration = Duration::from_secs(1);
182187
const DEFAULT_OUTBOUND_CONNECT_BACKOFF: ExponentialBackoff = ExponentialBackoff {
183188
min: Duration::from_millis(100),
@@ -243,9 +248,11 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
243248
let inbound_listener_addr = parse(strings, ENV_INBOUND_LISTEN_ADDR, parse_socket_addr);
244249
let admin_listener_addr = parse(strings, ENV_ADMIN_LISTEN_ADDR, parse_socket_addr);
245250

251+
let inbound_detect_timeout = parse(strings, ENV_INBOUND_DETECT_TIMEOUT, parse_duration);
246252
let inbound_dispatch_timeout = parse(strings, ENV_INBOUND_DISPATCH_TIMEOUT, parse_duration);
247253
let inbound_connect_timeout = parse(strings, ENV_INBOUND_CONNECT_TIMEOUT, parse_duration);
248254

255+
let outbound_detect_timeout = parse(strings, ENV_OUTBOUND_DETECT_TIMEOUT, parse_duration);
249256
let outbound_dispatch_timeout = parse(strings, ENV_OUTBOUND_DISPATCH_TIMEOUT, parse_duration);
250257
let outbound_connect_timeout = parse(strings, ENV_OUTBOUND_CONNECT_TIMEOUT, parse_duration);
251258

@@ -416,6 +423,8 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
416423
},
417424
};
418425

426+
let detect_protocol_timeout =
427+
outbound_detect_timeout?.unwrap_or(DEFAULT_OUTBOUND_DETECT_TIMEOUT);
419428
let dispatch_timeout =
420429
outbound_dispatch_timeout?.unwrap_or(DEFAULT_OUTBOUND_DISPATCH_TIMEOUT);
421430

@@ -429,7 +438,7 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
429438
dispatch_timeout,
430439
max_in_flight_requests: outbound_max_in_flight?
431440
.unwrap_or(DEFAULT_OUTBOUND_MAX_IN_FLIGHT),
432-
detect_protocol_timeout: dispatch_timeout,
441+
detect_protocol_timeout,
433442
},
434443
}
435444
};
@@ -475,6 +484,8 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
475484
},
476485
};
477486

487+
let detect_protocol_timeout =
488+
inbound_detect_timeout?.unwrap_or(DEFAULT_INBOUND_DETECT_TIMEOUT);
478489
let dispatch_timeout =
479490
inbound_dispatch_timeout?.unwrap_or(DEFAULT_INBOUND_DISPATCH_TIMEOUT);
480491

@@ -499,7 +510,7 @@ pub fn parse_config<S: Strings>(strings: &S) -> Result<super::Config, EnvError>
499510
dispatch_timeout,
500511
max_in_flight_requests: inbound_max_in_flight?
501512
.unwrap_or(DEFAULT_INBOUND_MAX_IN_FLIGHT),
502-
detect_protocol_timeout: dispatch_timeout,
513+
detect_protocol_timeout,
503514
},
504515
require_identity_for_inbound_ports: require_identity_for_inbound_ports.into(),
505516
profile_idle_timeout: dst_profile_idle_timeout?

0 commit comments

Comments
 (0)