Skip to content
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

raise the default Redis timeout to 500ms #5795

Merged
merged 10 commits into from
Aug 19, 2024
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 @@
### raise the default Redis timeout to 500ms ([PR #5795](https://github.com/apollographql/router/pull/5795))

The default Redis command timeout was initially set at 2ms, which is too low for most production usage. It is now raised to 500ms by default.
Geal marked this conversation as resolved.
Show resolved Hide resolved

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/5795
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ sha1 = "0.10.6"
tempfile = "3.10.1"
tokio = { version = "1.36.0", features = ["full"] }
tower = { version = "0.4.13", features = ["full"] }

[profile.release]
debug = true
Geal marked this conversation as resolved.
Show resolved Hide resolved
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 apollo-router/src/plugins/cache/invalidation_endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ impl Service<router::Request> for InvalidationService {
Box::pin(
async move {
let (parts, body) = req.router_request.into_parts();
if !parts.headers.contains_key(AUTHORIZATION) {
/*if !parts.headers.contains_key(AUTHORIZATION) {
Geal marked this conversation as resolved.
Show resolved Hide resolved
return Ok(router::Response {
response: http::Response::builder()
.status(StatusCode::UNAUTHORIZED)
.body("Missing authorization header".into())
.map_err(BoxError::from)?,
context: req.context,
});
}
}*/
Geal marked this conversation as resolved.
Show resolved Hide resolved
match parts.method {
Method::POST => {
let body = Into::<RouterBody>::into(body)
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
Loading