Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

AWS Lambda Response Streaming Demo

Introduction

Response streaming is a new invocation method that enables your functions to progressively stream response payloads back to the clients. Instead of waiting for the entire data to be ready, your applications can now receive chunks of data as soon as they become available. This means faster loading times and a more responsive user experience.

Response Streaming vs. Non-Streaming (Buffering)

To quickly get an idea of how it works, we need to see it in action.

Below, we show two functions that have the simple task of displaying a message in HTML. The non-streaming function introduces a delay of 3 seconds to simulate a process. This will highlight how each approach affects the user experience.

Without Response Streaming: The Waiting Game and the Role of TTFB 

without-streaming-demo

Without a response streaming demo

In GIF above, we simulate a non-streaming operation. The function waits for three seconds to mimic a process before it returns the message. The result? The browser waits too, displaying nothing until the entire process is completed. We see no output until everything is ready. This is where the concept of TTFB, or Time To First Byte, comes into play. TTFB is the time it takes from when the client makes a request until it receives the first byte of data from the server. In this non-streaming scenario, the TTFB includes the entire three-second processing time. Only after this does the client receive its first byte of data, which can make the application seem unresponsive or slow.

With Response Streaming

Tutorials dojo strip

In contrast, response streaming can reduce the perceived TTFB by sending chunks of data as soon as they are available, which leads to an immediate and more interactive response. By allowing users to see data earlier in the process, we can enhance the user’s perception of speed and responsiveness in our applications. Let’s see how this works in the following GIF. 

with-streaming-demo

With response streaming demo

Putting it into Practice

Let’s see this feature firsthand.

Steps

  1. Save this YAML file to a location on your computer. 
  2. Create a new stack in AWS CloudFormation using the YAML that you’ve saved.
  3. Wait for your stack to be created. This may take a minute. You can monitor the progress on the CloudFormation dashboard.
  4. Once the stack creation process has been completed, go to the Outputs section of your stack details in the CloudFormation dashboard. Here, you will find the function URL of the Lambda function.

Verification

Open the function URL in your web browser to see the response streaming in action.

Cleaning up

Once you’re done testing, don’t forget to delete the stack to avoid incurring unnecessary charges and remove any potentially exposed endpoints.

 

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE AWS, Azure, GCP Practice Test Samplers

Follow Us On Linkedin

Recent Posts

Written by: Carlo Acebedo

Carlo is a cloud engineer and a content creator at Tutorials Dojo. He's also a member of the AWS Community builder and holds 5 AWS Certifications. Carlo specializes in building and automating solutions in the Amazon Web Services Cloud.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?