Skip to content

Commit 085b750

Browse files
authored
Merge pull request #5069 from JoshVanL/sa-http-streaming-1.18
[1.18] Updates resiliency of streaming HTTP Service Invocation
2 parents 84e559e + 9013f65 commit 085b750

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

daprdocs/content/en/developing-applications/building-blocks/service-invocation/service-invocation-overview.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ For more information read the [service-to-service security]({{% ref "security-co
6161

6262
In the event of call failures and transient errors, service invocation provides a resiliency feature that performs automatic retries with backoff time periods. To find out more, see the [Resiliency article here]({{% ref resiliency-overview %}}).
6363

64+
{{% alert title="Note" color="primary" %}}
65+
For HTTP service invocation, retry policies (both built-in and user-configured) are automatically bypassed for streaming requests (those using chunked transfer encoding or without a known `Content-Length`). Since the request body is consumed as it is read, it cannot be replayed on retry. Non-streaming requests with a known `Content-Length` continue to support retries as before. See [Streaming for HTTP service invocation](#streaming-for-http-service-invocation) for more details.
66+
{{% /alert %}}
67+
6468
### Tracing and metrics with observability
6569

6670
By default, all calls between applications are traced and metrics are gathered to provide insights and diagnostics for applications. This is especially important in production scenarios, providing call graphs and metrics on the calls between your services. For more information read about [observability]({{% ref observability-concept %}}).
@@ -102,7 +106,7 @@ The Consul name resolution component is particularly suited to multi-machine dep
102106

103107
You can handle data as a stream in HTTP service invocation. This can offer improvements in performance and memory utilization when using Dapr to invoke another service using HTTP with large request or response bodies.
104108

105-
The diagram below demonstrates the six steps of data flow.
109+
The diagram below demonstrates the six steps of data flow.
106110

107111
<img src="/images/service-invocation-simple.webp" width=600 alt="Diagram showing the steps of service invocation described in the table below" />
108112

@@ -113,6 +117,16 @@ The diagram below demonstrates the six steps of data flow.
113117
1. Response: "Dapr sidecar B" to "Dapr sidecar A"
114118
1. Response: "Dapr sidecar A" to "App A"
115119

120+
#### Streaming requests and resiliency
121+
122+
Dapr automatically detects streaming HTTP requests — those using chunked transfer encoding or without a known `Content-Length` header (for example, file uploads, piped bodies, or long-running data streams). For these requests:
123+
124+
- **Request bodies are not buffered in memory.** The sidecar forwards the request body directly as it is read, avoiding excessive memory usage for large payloads.
125+
- **Response bodies are not buffered in memory.** Streaming responses (such as server-sent events, file downloads, or long-running data streams) are forwarded directly to the caller.
126+
- **Retry policies are bypassed.** Both built-in retry logic and any user-configured [resiliency retry policies]({{% ref resiliency-overview %}}) are automatically skipped, since the request body is consumed as it is read and cannot be replayed.
127+
- **Other resiliency features still apply.** Circuit breakers continue to track failures normally for streaming requests.
128+
- **Non-streaming requests are unaffected.** Requests with a known `Content-Length` continue to support retries and buffered error handling as before.
129+
116130
## Example Architecture
117131

118132
Following the above call sequence, suppose you have the applications as described in the [Hello World tutorial](https://github.com/dapr/quickstarts/blob/master/tutorials/hello-world/README), where a python app invokes a node.js app. In such a scenario, the python app would be "Service A" , and a Node.js app would be "Service B".

daprdocs/content/en/operations/resiliency/policies/retries/retries-overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Dapr provides [default resiliency policies]({{% ref default-policies.md %}}), wh
2020
Each [pub/sub component]({{% ref supported-pubsub %}}) has its own built-in retry behaviors. Explicity applying a Dapr resiliency policy doesn't override these implicit retry policies. Rather, the resiliency policy augments the built-in retry, which can cause repetitive clustering of messages.
2121
{{% /alert %}}
2222

23+
{{% alert title="Note" color="primary" %}}
24+
For HTTP [service invocation]({{% ref service-invocation-overview %}}), retry policies are automatically bypassed for streaming requests (those using chunked transfer encoding or without a known `Content-Length`). Since the request body is consumed as it is read, it cannot be replayed on retry. Non-streaming requests with a known `Content-Length` continue to support retries as before. Learn more about [streaming HTTP service invocation and resiliency]({{% ref "service-invocation-overview#streaming-requests-and-resiliency" %}}).
25+
{{% /alert %}}
26+
2327
## Retry policy format
2428

2529
**Example 1**

daprdocs/content/en/operations/resiliency/targets.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Named policies are applied to targets. Dapr supports three target types that app
1717

1818
With the `apps` target, you can apply `retry`, `timeout`, and `circuitBreaker` policies to service invocation calls between Dapr apps. Under `targets/apps`, policies are applied to each target service's `app-id`. The policies are invoked when a failure occurs in communication between sidecars, as shown in the diagram below.
1919

20-
> Dapr provides [built-in service invocation retries]({{% ref "service-invocation-overview.md#retries" %}}), so any applied `retry` policies are additional.
20+
> Dapr provides [built-in service invocation retries]({{% ref "service-invocation-overview.md#resiliency-including-retries" %}}), so any applied `retry` policies are additional.
21+
22+
> For HTTP service invocation, `retry` policies are automatically bypassed for streaming requests (those without a known `Content-Length`). Circuit breakers continue to apply. See [Streaming requests and resiliency]({{% ref "service-invocation-overview#streaming-requests-and-resiliency" %}}).
2123
2224
<img src="/images/resiliency_svc_invocation.png" width=1000 alt="Diagram showing service invocation resiliency" />
2325

0 commit comments

Comments
 (0)