Skip to content

Commit

Permalink
raise the default Redis timeout to 500ms (#5795)
Browse files Browse the repository at this point in the history
The previous default of 2ms was too low for production use cases: users keep running into issues with this low timeout with transient networking issues
Co-authored-by: Renée <[email protected]>
Co-authored-by: Edward Huang <[email protected]>
  • Loading branch information
Geal authored Aug 19, 2024
1 parent ae522fb commit 758e502
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changesets/config_geal_raise_redis_timeouts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Increase default Redis timeout ([PR #5795](https://github.com/apollographql/router/pull/5795))

The default Redis command timeout was increased from 2ms to 500ms to accommodate common production use cases.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/5795
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ serde_json_bytes = { version = "0.2.4", features = ["preserve_order"] }
sha1 = "0.10.6"
tempfile = "3.10.1"
tokio = { version = "1.36.0", features = ["full"] }
tower = { version = "0.4.13", features = ["full"] }
tower = { version = "0.4.13", features = ["full"] }
2 changes: 1 addition & 1 deletion apollo-router/src/cache/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl RedisCacheStorage {
let client = RedisClient::new(
client_config,
Some(PerformanceConfig {
default_command_timeout: config.timeout.unwrap_or(Duration::from_millis(2)),
default_command_timeout: config.timeout.unwrap_or(Duration::from_millis(500)),
..Default::default()
}),
None,
Expand Down
4 changes: 2 additions & 2 deletions docs/source/configuration/distributed-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ supergraph:
urls: ["redis://..."] #highlight-line
username: admin/123 # Optional, can be part of the urls directly, mainly useful if you have special character like '/' in your password that doesn't work in url. This field takes precedence over the username in the URL
password: admin # Optional, can be part of the urls directly, mainly useful if you have special character like '/' in your password that doesn't work in url. This field takes precedence over the password in the URL
timeout: 5ms # Optional, by default: 2ms
timeout: 2s # Optional, by default: 500ms
ttl: 24h # Optional
namespace: "prefix" # Optional
#tls:
Expand All @@ -141,7 +141,7 @@ supergraph:

#### Timeout

Connecting and sending commands to Redis are subject to a timeout, set by default to 2ms, that can be overriden.
Connecting and sending commands to Redis are subject to a timeout, set by default to 500ms, that can be overriden.


#### TTL
Expand Down
2 changes: 1 addition & 1 deletion docs/source/configuration/entity-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ preview_entity_cache:
# Configure Redis
redis:
urls: ["redis://..."]
timeout: 5ms # Optional, by default: 2ms
timeout: 2s # Optional, by default: 500ms
ttl: 24h # Optional, by default no expiration
# Configure entity caching per subgraph, overrides options from the "all" section
subgraphs:
Expand Down

0 comments on commit 758e502

Please sign in to comment.