In Apigee, the default behavior is that HTTP request and response payloads are stored in an
in-memory buffer before they are processed by the policies in the API Proxy.
If streaming is enabled, then request and response payloads are streamed without modification to
the client app (for responses) and the target endpoint (for requests). Streaming is useful
especially if an application accepts or returns large payloads, or if there's an application that
returns data in chunks over time.
Antipattern
Accessing the request/response payload with streaming enabled causes Apigee to go back to the
default buffering mode.
Figure 1: Accessing request/response payload with streaming enabled
The illustration above shows that we are trying to extract variables from the request payload and
converting the JSON response payload to XML using JSONToXML policy. This will disable the streaming
in Apigee.
Impact
Streaming will be disabled which can lead to increased latencies in processing the data
Increase in the heap memory usage or OutOfMemory errors can be observed on Message Processors
due to use of in-memory buffers especially if we have large request/response payloads
Best practice
Don't access the request/response payload when streaming is enabled.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-07 UTC."],[[["Apigee's default behavior involves buffering HTTP request and response payloads in memory, but streaming can be enabled to send payloads directly to clients or target endpoints."],["Accessing request or response payloads when streaming is enabled in Apigee will revert the system to the default buffering mode."],["Disabling streaming by accessing the request/response payload can result in increased latency and higher memory consumption, potentially leading to `OutOfMemory` errors."],["The recommended practice is to avoid accessing the request/response payload when streaming is active to maintain the benefits of streaming."],["Streaming is beneficial for applications that handle large payloads or data delivered in chunks over time."]]],[]]