Leveraging serverless in full-stack development

Eric Johnson – Sr. Developer Advocate – Serverless, AWS @edjgeek

© 2020, Web Services, Inc. or its Affiliates. All rights reserved. Who am I?

• @edjgeek • Husband and father of 5 • Senior Developer Advocate – Serverless, AWS • Serverless tooling and automation nerd • Solutions & software architect (> 25 years) • Music lover • Pizza lover (without pineapple) • Pusher of #ServerlessForEveryone

© 2020, , Inc. or its Affiliates. All rights reserved. Application architecture journey

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The single server architecture

Proxy/Firewall: NGINX, Apache, F5, Zeus

Server: IIS, Apache, Tomcat Many application architectures Code: Node, .Net, Ruby, Java, start here. Go, Python

Database: SQL, MySQL, PostgreSQL, Mongo, Cassandra

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The tiered architecture

Proxy/Firewall

We then break applications into tiers based Server on functionality.

Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The tiered architecture

Proxy/Firewall

Even Client separating the client and backend. Backend

Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The redundant tiered architecture Proxy/Firewall

Client load balancer

As applications Client scale, we build in redundancy. Backend load balancer

Backend

Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The “more” redundant tiered architecture

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The “more” redundant tiered architecture

More redundant, more infrastructure, more management, more cost.

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The containers architecture

Proxy/Firewall

But what about containers? Client Backend Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The “more” redundant containers architecture

Proxy/Firewall

Load balancer

Client Backend

Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The “more” redundant containers architecture

Proxy/Firewall

More redundant, Load balancer more infrastructure, more management, Client more cost. Backend

Database

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to the cloud AWS Cloud

VPC Availability Zone Availability Zone

Application Load Balancer

Client Auto Scaling group Instance(s) Instance(s)

Application Load Balancer

Backend Auto Scaling group Instance(s) Instance(s)

Amazon RDS Amazon RDS

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving containers to the cloud AWS Cloud

VPC Availability Zone Availability Zone

Application Load Balancer

Application Auto Scaling group

Amazon Elastic Amazon Elastic Container Service Container Service

Amazon RDS Amazon RDS

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving containers to the cloud AWS Cloud

VPC Availability Zone Availability Zone

Application Load Balancer

Application Auto Scaling group

Moving to the cloud offers sophisticated automation and tooling Amazon Elasticto help manage scaling and redundancy.Amazon Elastic Container Service Container Service

Amazon RDS Amazon RDS

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving containers to the cloud AWS Cloud

VPC Availability Zone Availability Zone

Application Load Balancer

Application Auto Scaling group

Amazon Elastic But… Amazon Elastic Container Service Container Service

Amazon RDS Amazon RDS

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving containers to the cloud AWS Cloud

VPC Availability Zone Availability Zone

Application Load Balancer

Application Auto Scaling group

There is still infrastructure to manage and pay for. Amazon Elastic Amazon Elastic Container Service Container Service

Amazon RDS Amazon RDS

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Hello serverless!

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is serverless?

No infrastructure provisioning, Automatic scaling no management

Pay for value Highly available and secure

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless applications

Event source Function Services

Changes in Node.js data state Python Java Requests to C# endpoints Go Ruby Runtime API Changes in Resource state

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Common AWS Lambda use cases

Web Apps Backends Data Chatbots IT Automation Processing • Static • Apps & • Real time • Powering • Powering • Policy engines websites services • MapReduce chatbot logic voice- • Extending AWS enabled apps • Complex • Mobile • Batch services web apps • IoT • Alexa Skills • Infrastructure • Packages Kit management for Flask and Express

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Common AWS Lambda use cases

I will be spending Web Apps Backends Data mostChatbots of the timeAmazon in the Alexa IT Automation Processing Web Apps and • Static • Apps & • Real time • PoweringBackend area.• Powering • Policy engines websites services • MapReduce chatbot logic voice- • Extending AWS enabled apps • Complex • Mobile • Batch services web apps • IoT • Alexa Skills • Infrastructure • Packages Kit management for Flask and Express

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless in full-stack development?

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – client

Assumption: Client is separate from backend.

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – client

Assumption: Client is separate from backend.

If not, don’t worry, I’ll cover that too.

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – client

Amazon Simple Storage Service

• Hosting for http and https • Object versioning • Bucket policy, ACL, and IAM security controls. • 99.999999999% (11 9s) data durability • Custom domains • Domain redirects

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – client

Amazon S3

Lambda@edge

AWS Amplify Console

• Powered by Lambda@edge and • CI/CD • Build configurations • Feature branch deployments • Global availability (CDN) • Basic password protection

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – API

The proxy/firewall now points directly at the backend.

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – API

Amazon API Gateway

• Load balancing and redundancy built in • REST, WebSocket • 10k+ requests per second (soft limit) • Private, regional or global options • Application authentication and authorization • SSL offloading • Custom domains • API user keys and throttling • Data validation • Resource Policy, IAM security

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – compute

AWS Lambda

• Supports Node, Python, Go, Ruby, Java, and .NetCore natively • Custom runtime for all other languages • Triggered by many internal and external events • 1k concurrent invocations (soft limit) • Triggered synchronously and asynchronously

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – database

Amazon Amazon DocumentDB (with DynamoDB MongoDB compatibility)

Amazon Amazon RDS Amazon Quantum Redshift Ledger Database

Amazon Timestream

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – database

Amazon Amazon Amazon Aurora DocumentDB (with DynamoDB MongoDB compatibility) In a web stack, these are the most common database options Amazon Amazon RDS Amazon Quantum Redshift Ledger Database

Amazon Amazon Neptune Timestream

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Moving to serverless – database

Relational Databases NoSQL Databases

Amazon Aurora Amazon RDS Amazon Amazon Serverless DynamoDB DocumentDB • Serverless • Simple scaling • Serverless • Highly redundant • Highly redundant • Engine native • Highly redundant • Highly available • Highly available replication • Highly available • MongoDB • Auto scaling • Microsoft SQL • Global tables Compatible • PostgreSQL • MySQL • High input and • MySQL • PostgreSQL output • MariaDB • Oracle

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Putting it all together

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic website AWS Cloud

Users Amazon API Lambda Amazon Gateway function DynamoDB Table

Amazon Amazon RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic website AWS Cloud HTML can be rendered by the Lambda function and returned to the user.

Users Amazon API Lambda Amazon Gateway function DynamoDB Table

Amazon Amazon RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic website AWS Cloud

Users Amazon API Lambda Amazon Gateway function DynamoDB Table

Pools and shares connections established with the relational database Amazon Amazon RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic website AWS Cloud

Users Amazon API Lambda Amazon Gateway function DynamoDB Table All serverless services scale automatically as needed to handle client requests. Amazon Amazon RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic client/backend website AWS Cloud

Users Amazon API Lambda Amazon Gateway Client function DynamoDB application Table hosted

AWS Amplify serverlessly Console and scales to Amazon Amazon meet load RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A basic secure client/backend website AWS Cloud User management and authentication. Amazon Cognito

Users Amazon API Lambda Amazon Gateway function DynamoDB Table

AWS Amplify (console) Amazon Amazon RDS Proxy Aurora

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A microservice website AWS Cloud

/orders

Lambda Amazon function Cognito

/users/{userId} Each Lambda function has a single Users Amazon API Lambda responsibility Amazon Gateway function DynamoDB Table

/reports

AWS Amplify (console) Lambda function

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A microservice website AWS Cloud

/orders More actions on data

Lambda Amazon function Cognito

/users/{userId}

Users Amazon API Lambda Amazon Lambda Amazon Gateway function DynamoDB function EventBridge Table

/reports Asynchronous post AWS Amplify processing via (console) Lambda function streams and event buses.

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Getting started

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A START WITH A FRAMEWORK START WITH A FRAMEWORKFRAMEWORK START WITH A FRAMEWORK STARTSTART WITHSTART WITHA FRAMEWORKSTART WITHA FRAMEWORK WITHA FRAMEWORK A STARTFRAMEWORK WITH A

FRAMEWORK! FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START FRAMEWORK A WITH START START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A FRAME START WITH A FRAMEWORK A WITH START WORK START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A FRAMEWORK START WITH A FR © 2020,! Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frameworks: AWS SAM Serverless Application Model

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM comes in two parts

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM comes in 2 parts

SAM templates SAM CLI Using shorthand Provides tooling for syntax to express local development, resources and event debugging, build, source mappings, it packaging, and provides infrastructure deployment for as code (IaC) for serverless applications serverless applications.

https://aws.amazon.com/serverless/sam/

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frameworks: AWS Amplify

• Designed for front-end developers • Allows creation of full-stack serverless infrastructure • Uses SAM for backend management • Helps manage front end code and backend connectivity for: • Analytics • APIs • AR/VR • Auth • DataStore • PubSub • And more

https://aws-amplify.github.io/docs/

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frameworks: Third Party

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Final resources

AWS Serverless

slip.link/aws-serverless

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Final resources

AWS Serverless YouTube Channel

slip.link/serverless

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Eric Johnson @edjgeek

© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Image Source: https://pixabay.com/illustrations/thank-you-polaroid-letters-2490552/