You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Clarify timeout hierarchy for traffic shaping ([PR #8203](https://github.com/apollographql/router/pull/8203))
2
+
3
+
The documentation reflects more clearly that subgraph timeouts should not be higher than the router timeout or the router timeout will initiate prior to the subgraph.
4
+
5
+
By [@abernix](https://github.com/abernix) in https://github.com/apollographql/router/pull/8203
Copy file name to clipboardExpand all lines: docs/source/routing/performance/traffic-shaping.mdx
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ The router applies a default timeout of 30 seconds for all requests, including t
66
66
67
67
#### Router timeouts
68
68
69
-
You can change the default timeout for client requests to the router like so:
69
+
Configure timeout values for client requests to the router:
70
70
71
71
```yaml title="router.yaml"
72
72
traffic_shaping:
@@ -77,16 +77,38 @@ traffic_shaping:
77
77
If the router-level timeout is hit, the router returns a [HTTP 504 status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/504) to indicate a gateway timeout.
78
78
79
79
#### Subgraph timeouts
80
-
You can change the default timeout for all requests between the router and subgraphs like so:
80
+
81
+
Configure timeout values for requests between the router and subgraphs:
81
82
82
83
```yaml title="router.yaml"
83
84
traffic_shaping:
84
85
all:
85
86
timeout: 50s # If subgraph requests take more than 50 seconds, cancel the request (30 seconds by default)
86
87
```
87
88
89
+
Subgraph timeouts apply to each individual subgraph fetch request. There can be multiple subgraph requests, even to the same subgraph, within a single router request.
90
+
88
91
If the subgraph-level timeout is hit, the router returns a [GraphQL-compliant HTTP 200 status code](https://graphql.github.io/graphql-over-http/). Because the router can handle multiple subgraph requests for one operation, the timeout of one subgraph doesn't immediately invalidate other requests in the query plan. Returning a 200 status code enables the router to return partial data from other requests that didn't timeout.
89
92
93
+
#### Timeout hierarchy
94
+
95
+
Set your router timeout to be greater than your subgraph timeouts. This difference provides a processing buffer, which enables the router to properly handle subgraph timeouts and return appropriate error responses to clients.
96
+
97
+
A properly configured timeout hierarchy:
98
+
99
+
```yaml title="router.yaml"
100
+
traffic_shaping:
101
+
router:
102
+
timeout: 60s # Router: 60 seconds
103
+
all:
104
+
timeout: 30s # Default for any subgraphs not explicitly named below
105
+
subgraphs:
106
+
products:
107
+
timeout: 45s # Products subgraph: 45 seconds (lower than router)
108
+
inventory:
109
+
timeout: 20s # Inventory subgraph: 20 seconds
110
+
```
111
+
90
112
<Note>
91
113
92
114
Since [deferred](/router/executing-operations/defer-support/#what-is-defer) fragments are separate requests, each fragment's request is individually subject to timeouts.
0 commit comments