Skip to content

Add timeouts and connection health checks to Redis connections #7526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 27, 2025
Merged
6 changes: 6 additions & 0 deletions .changesets/maint_caroline_redis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Add timeouts and connection health checks to Redis connections ([Issue #6855](https://github.com/apollographql/router/issues/6855))

This PR updates the internal Redis configuration to improve client resiliency under various failure modes (TCP failures
and timeouts, unresponsive sockets, Redis server failures, etc.). It also adds heartbeats (a PING every 10 seconds) to the Redis clients.

By [@aembke](https://github.com/aembke), [@carodewig](https://github.com/carodewig) in https://github.com/apollographql/router/pull/7526
89 changes: 25 additions & 64 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ dependencies = [
"rstest",
"rust-embed",
"rustls",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pemfile",
"ryu",
"schemars",
Expand Down Expand Up @@ -972,7 +972,7 @@ dependencies = [
"hyper-util",
"pin-project-lite",
"rustls",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pki-types",
"tokio",
"tower 0.5.2",
Expand Down Expand Up @@ -1731,16 +1731,6 @@ dependencies = [
"tower 0.5.2",
]

[[package]]
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]

[[package]]
name = "core-foundation"
version = "0.10.0"
Expand Down Expand Up @@ -1856,15 +1846,6 @@ dependencies = [
"crossbeam-utils",
]

[[package]]
name = "crossbeam-queue"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35"
dependencies = [
"crossbeam-utils",
]

[[package]]
name = "crossbeam-utils"
version = "0.8.20"
Expand Down Expand Up @@ -2409,9 +2390,9 @@ dependencies = [

[[package]]
name = "float-cmp"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
dependencies = [
"num-traits",
]
Expand Down Expand Up @@ -2508,24 +2489,24 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa"

[[package]]
name = "fred"
version = "9.4.0"
version = "10.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cdd5378252ea124b712e0ac55147d26ae3af575883b34b8423091a4c719606b"
checksum = "3a7b2fd0f08b23315c13b6156f971aeedb6f75fb16a29ac1872d2eabccc1490e"
dependencies = [
"arc-swap",
"async-trait",
"bytes",
"bytes-utils",
"crossbeam-queue",
"float-cmp",
"fred-macros",
"futures",
"glob-match",
"log",
"parking_lot",
"rand 0.8.5",
"redis-protocol",
"rustls",
"rustls-native-certs 0.7.3",
"rustls-native-certs",
"semver",
"socket2",
"tokio",
Expand Down Expand Up @@ -2763,6 +2744,12 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"

[[package]]
name = "glob-match"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9985c9503b412198aa4197559e9a318524ebc4519c229bfa05a535828c950b9d"

[[package]]
name = "globset"
version = "0.4.15"
Expand Down Expand Up @@ -3202,7 +3189,7 @@ dependencies = [
"hyper",
"hyper-util",
"rustls",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pki-types",
"tokio",
"tokio-rustls",
Expand Down Expand Up @@ -4891,8 +4878,8 @@ version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b"
dependencies = [
"heck 0.4.1",
"itertools 0.11.0",
"heck 0.5.0",
"itertools 0.13.0",
"log",
"multimap 0.10.1",
"once_cell",
Expand Down Expand Up @@ -5096,9 +5083,9 @@ dependencies = [

[[package]]
name = "redis-protocol"
version = "5.0.1"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65deb7c9501fbb2b6f812a30d59c0253779480853545153a51d8e9e444ddc99f"
checksum = "9cdba59219406899220fc4cdfd17a95191ba9c9afb719b5fa5a083d63109a9f1"
dependencies = [
"bytes",
"bytes-utils",
Expand Down Expand Up @@ -5212,7 +5199,7 @@ dependencies = [
"pin-project-lite",
"quinn",
"rustls",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pemfile",
"rustls-pki-types",
"serde",
Expand Down Expand Up @@ -5563,19 +5550,6 @@ dependencies = [
"zeroize",
]

[[package]]
name = "rustls-native-certs"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5"
dependencies = [
"openssl-probe",
"rustls-pemfile",
"rustls-pki-types",
"schannel",
"security-framework 2.11.1",
]

[[package]]
name = "rustls-native-certs"
version = "0.8.1"
Expand All @@ -5585,7 +5559,7 @@ dependencies = [
"openssl-probe",
"rustls-pki-types",
"schannel",
"security-framework 3.0.1",
"security-framework",
]

[[package]]
Expand Down Expand Up @@ -5698,27 +5672,14 @@ dependencies = [
"zeroize",
]

[[package]]
name = "security-framework"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
"bitflags 2.6.0",
"core-foundation 0.9.4",
"core-foundation-sys",
"libc",
"security-framework-sys",
]

[[package]]
name = "security-framework"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8"
dependencies = [
"bitflags 2.6.0",
"core-foundation 0.10.0",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
Expand Down Expand Up @@ -6477,7 +6438,7 @@ dependencies = [
"futures-util",
"log",
"rustls",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pki-types",
"tokio",
"tokio-rustls",
Expand Down Expand Up @@ -6538,7 +6499,7 @@ dependencies = [
"percent-encoding",
"pin-project",
"prost",
"rustls-native-certs 0.8.1",
"rustls-native-certs",
"rustls-pemfile",
"socket2",
"tokio",
Expand Down Expand Up @@ -7227,7 +7188,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]

[[package]]
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dhat = { version = "0.3.3", optional = true }
diff = "0.1.13"
displaydoc = "0.2"
flate2 = "1.0.30"
fred = { version = "9.4.0", features = ["enable-rustls-ring", "i-cluster"] }
fred = { version = "10.1.0", features = ["enable-rustls-ring", "i-cluster", "tcp-user-timeouts"] }
futures = { version = "0.3.30", features = ["thread-pool"] }
graphql_client = "0.14.0"
hex.workspace = true
Expand Down Expand Up @@ -280,7 +280,7 @@ tikv-jemallocator = "0.6.0"
axum = { version = "0.8.1", features = ["http2", "ws"] }
axum-server = "0.7.1"
ecdsa = { version = "0.16.9", features = ["signing", "pem", "pkcs8"] }
fred = { version = "9.4.0", features = ["enable-rustls-ring", "mocks", "i-cluster"] }
fred = { version = "10.1.0", features = ["enable-rustls-ring", "mocks", "i-cluster", "tcp-user-timeouts"] }
futures-test = "0.3.30"
insta.workspace = true
maplit = "1.0.2"
Expand Down
Loading