News/Tech News

AWS Lambda Introduces Response Payload Streaming

Published on April 17, 2023

According to Amazon, AWS Lambda functions can stream response payloads progressively back to the client. This new feature improves the performance of web and mobile applications and is currently available for Node.js 14.x and newer runtimes, as well as custom ones.

The response streaming technique allows developers to stream responses from their functions to their users without having to wait for the entire response to be completed. As of now, Lambda function URLs and SDKs are supported, but it is not possible to stream response payloads via API Gateway or Application Load Balancer (ALB).

For large payloads such as images, videos, large documents, or database results, response streaming requires the use of the streamifyResponse() decorator.

Using the new responseStream object, the function can write data to the stream and send it immediately to the client. It is possible for developers to set the Content-Type header of the response in order to pass additional information about the stream. Datadog’s engineering team lead, AJ Stuyvenberg, tested and evaluated the new feature

Currently, the new feature supports a maximum response size of 20 MB (soft limit) and a maximum bandwidth throughput of 16 Mbps (2 MB/s) for streaming functions. Response streaming is currently only available in the Node.js SDK, but it is possible to implement it in a custom Lambda runtime supporting other programming languages. While some developers focus on the limitations, Jeremy Daly, CEO and co-founder of Ampt, writes in his newsletter that

AWS Serverless Hero Yan Cui wrote an article demonstrating how to return large objects using the new streaming response, bypassing the need to store results in S3.

Streaming HTTP responses in Lambda is not the first option available in the cloud space, with Vercel recently offering support for HTTP response streaming in both Node.js (Lambda) and Edge.

Amazon published examples of Lambda streaming applications in its Serverless Patterns Collection, applications that can be built and deployed using AWS SAM. While streaming responses increase the Lambda costs for network transfers, the AWS free tier now includes 100GiB of HTTP response streaming per month beyond the first 6MB per request.

Tech News

ChatGPT Is Fun, but the Future Is Fully Autonomous AI for Code at QCon London img

ChatGPT Is Fun, but the Future Is Fully Autonomous AI for Code at QCon London

A presentation on artificial intelligence (AI) for code writing was given by Mathew Lodge, CEO of DiffBlue, at the…

New Java SE Universal Subscription from Oracle img

New Java SE Universal Subscription from Oracle

Since January 2023, Oracle has announced the new Java SE Universal subscription and pricing, which will replace ..

Our Latest Blog

Mastering Full Stack Python Development with Django A Comprehensive Guide

Mastering Full Stack Python Development with Django: A Comprehensive Guide

Python is a powerful programming language that has taken the world of web development by...
Read More
Mastering Machine Learning A Beginner's Guide to Python

Mastering Machine Learning: A Beginner’s Guide to Python

Welcome to the world of machine learning! With the ever-increasing demand for artificial intelligence and...
Read More
Unlocking the Power of Data Science with Python A Beginner's Guide

Unlocking the Power of Data Science with Python: A Beginner’s Guide

Data science has become an essential part of many industries today, and Python has become...
Read More

Follow Us

Resources

Presentations
Browse LSET presentations to understand interesting…

Explore Now


eBooks
Get complete guides to empower yourself academically…

Explore Now


Infographics
Learn about information technology and business…

Explore Now