Implement streaming for large responses
Refactor a memory-hungry endpoint to stream data directly to the client using Node.js streams, Python generators, or Go's io.Reader. Handles backpressure correctly.
Preview
Copy prompt
Refactor the following endpoint that loads a large dataset into memory before responding: [Paste code]. Replace in-memory accumulation with HTTP streaming using [Node.js Readable streams / Python generators / Go io.Reader]. Handle backpressure so the server does not outpace the client. Set correct Content-Type and Transfer-Encoding headers. Measure peak memory before and after using a representative dataset.
More
Performance
Prompts
