1 of 57

Serverless

Computing

— Exploring the Future of Cloud Computing

2 of 57

What is it?

05

02

Why use it?

Demo

AWS Lambda

04

01

Serverless Computing

03

Use Cases

3 of 57

01

What is it?

4 of 57

Serverless means…

  • Serverless computing is a cloud computing model where cloud providers manage and allocate computing resources on-demand

  • It eliminates the need for users to manage and provision servers, allowing them to focus on developing and deploying code.

  • Serverless computing is event-driven, meaning that resources are only allocated when triggered by specific events or requests.

  • It is often referred to as Function-as-a-Service (FaaS), as it enables developers to write and deploy code in the form of small, independent functions.

5 of 57

Serverless Computing Tools…

We will focus on !

6 of 57

02

Why use it?

7 of 57

Reduced operational overhead

Scalability

Faster deployment

Why Serverless Computing?

No need to manage servers, operating systems, or infrastructure.

Automatic scaling up and down based on demand, allowing for cost efficiency.

Functions can be deployed and executed quickly without needing to configure servers.

8 of 57

High availability

Greater flexibility

Improved developer productivity

Why Serverless Computing?

Built-in redundancy and automatic failover capabilities ensure applications are always available.

Developers can choose from a variety of programming languages and frameworks to write and deploy their code.

Developers can focus on writing code rather than worrying about infrastructure and server management.

9 of 57

03

Use Cases

10 of 57

Common Serverless App Use Cases

IoT Backend

Analyze sensor data

Process data from IoT devices

Chatbot

Powering chatbot logic

Web App

Static Websites

Complex Web Apps

Data Processing

Real time

Machine learning interface

Event-driven programming

Batch processing

11 of 57

Web Application Development

12 of 57

Data Processing

  • Data ingestion
  • Data transformation
  • Data analysis

13 of 57

Chatbot

  • Message processing
  • NLP
  • Integration with messaging platforms

14 of 57

04

AWS Lambda

15 of 57

What is AWS Lambda

  • AWS Lambda is one of the computing services provided by AWS, which is event-driven and serverless.

  • It is a stateless serverless system that helps us run our background tasks in the most efficient manner possible.

  • Here, being serverless doesn’t mean that servers are nowhere in the play. Instead, it means that we don’t have to worry about the provisioning or management of our servers or instances; it just helps us focus on our main goal, i.e., coding. We just have to put our code in AWS Lambda, and we’re good to go!

16 of 57

Supported Languages

  • nodeJs

  • Python

  • Go

  • Java

  • Ruby

  • .Net

  • C#

17 of 57

AWS Lambda Anatomy

  • Handler() Function: Function to be executed upon invocation and it requires two arguments “event” and “context”.
  • Event Object: The event argument contains information about the triggering event, such as an HTTP request or a message from an AWS service.
  • Context Object: The context argument provides information about the execution environment and can be used to interact with AWS services.

18 of 57

How it works…

Here is an example using AWS Lambda, AWS API Gateway, and Amazon S3 to create a serverless web application to resize images on the fly.

  • Amazon S3: Amazon S3 is a cloud storage service that lets you store and retrieve any amount of data, anywhere, anytime.

  • AWS API Gateway: AWS API Gateway lets you create, deploy, and manage APIs for your applications without worrying about infrastructure or scalability.

19 of 57

Situation

Solution

Resizing on the fly

  • As the number of devices people use to access the Internet continues to grow, developers need to provide an array of images that work well on devices with different capabilities, screen sizes, and resolutions.
  • This can be challenging and costly because it requires creating and managing images in a variety of sizes.

Instead of processing and resizing images into all necessary sizes upon upload, the approach of lazily generating images, in which a resized asset is only created if a user requests that specific size.

20 of 57

A user requests a resized asset from an S3 bucket through its static website hosting endpoint. The bucket has a routing rule configured to redirect to the resize API any request for an object that cannot be found.

21 of 57

Because the resized asset does not exist in the bucket, the request is temporarily redirected to the resize API method.

22 of 57

The user’s browser follows the redirect and requests the resize operation via API Gateway.

23 of 57

The API Gateway method is configured to trigger a Lambda function to serve the request.

24 of 57

The Lambda function downloads the original image from the S3 bucket, resizes it, and uploads the resized image back into the bucket as the originally requested key.

25 of 57

When the Lambda function completes, API Gateway permanently redirects the user to the file stored in S3.

26 of 57

The user’s browser requests the now-available resized image from the S3 bucket. Subsequent requests from this and other users will be served directly from S3 and bypass the resize operation. If the resized image is deleted in the future, the above process repeats and the resized image is re-created and replaced into the S3 bucket.

27 of 57

05

Demo

28 of 57

Design

ReactJS

AWS Amplify

Amazon API Gateway

Request

Response

AWS Lambda

Access Lambda Function

29 of 57

Set Up Project

  • We will use VSCode and set up a React Frontend

  • Now, Install the Amplify CLI

  • Next, run this command and you will be redirected to login to AWS

30 of 57

Set Up Project

  • After signing in, select an AWS region and you will be redirected to AWS to create a user

31 of 57

Create AWS User

  • Pick a name for this user

32 of 57

Create AWS User

  • Add policies for this user to be able to use AWS Resources

33 of 57

Create AWS User

  • Review Details and Create User

34 of 57

Create AWS User

  • We can now view and edit this user in the AWS Console

35 of 57

Create AWS User

  • The last step is to create and use the access keys for this user
  • Under the “Security Credentials” tab, you can create a new access key

36 of 57

Create AWS User

  • Provide CLI Access

37 of 57

Create AWS User

  • Now, we can copy these keys into the command line in VSCode

38 of 57

Set Up Project

  • Finish up the CLI prompts

39 of 57

Connect to Cloud

  • Run this command to begin Amplify hosting initialization

  • Follow the CLI prompts to finish and deploy to cloud

40 of 57

View Project in AWS Console

41 of 57

View Project in AWS Console

  • We can see our project has deployed as a backend environment in AWS

42 of 57

Add API and Lambda

  • Run this command to install amplify libraries for project

  • Run this command and complete prompts to add an API to our project

43 of 57

Create Lambda Function

44 of 57

Folder Structure

45 of 57

Push our API to AWS

  • Run this command to update our backend in the cloud

46 of 57

View and Test Lambda Function

47 of 57

AWS Front End Configuration

  • We need to import AWS configurations into index.js

48 of 57

Access Lambda From Front End

  • Import API into App.js

49 of 57

Access Lambda From Front End

  • Now we will edit the rest of App.js

50 of 57

Access Lambda From Front End

  • Add variable to store API/Lambda response

51 of 57

Access Lambda From Front End

  • Add function to call Lambda

52 of 57

Access Lambda From Front End

  • For now, call the API whenever the page loads

53 of 57

Access Lambda From Front End

  • Display the response body

54 of 57

The Result

  • We can run the app locally with “npm start”
  • The response from the Lambda function will be displayed below the React logo

55 of 57

Repository Link

56 of 57

For more information…

57 of 57

Q & A