Serverless

Hype or the Future?

Where is serverless in the Gartner hype cycle?

Gartner hype cycle

How much is serverless going to be adopted?

What is the future of serverless?

In the CIO’s Guide to Serverless Computing Gartner predicts that half of global enterprises will have deployed fPaaS by 2025, up from only 20% today.

Others take the opposite view that the serverless revolution has stalled

What is serverless, actually?

It’s a lambda, right?

... a cloud-native development model that allows developers to build and run applications without having to manage servers [Red Hat]

... a movement driven by developers and businesses who realize that software is eating the world [serverless.com]

... a desire to reduce the amount of Ops I have to do, reduce the configuration, improve the Time-To-Value, and focus on key features [thenewstack.io]

... a next-generation technology that enables agility, elasticity and cost-effectiveness when applied to appropriate use cases [Gartner]

Why serverless?

  • No servers to provision or manage

  • Scales with usage

  • Availability and fault tolerance built in

  • Pay for value

Sounds promising, doesn't it?

So let's build a typical web application:

web app

... and see if the promises come true

How to build a serverless web application on  ?

 recommends the Well-Architected Framework which describes the key concepts, design principles, and architectural best practices for designing and running workloads in the cloud.

What is more, the Well-Architected Framework offers the Serverless Applications Lens which extend the Framework specifically to serverless.

Compute
AWS Lambda Lambda
API Gateway API Gateway
Step Functions Step Functions
Data
DynamoDB DynamoDB
S3 S3
AppSync AppSync
Elasticsearch Elasticsearch
User Management and Identity
Cognito Cognito
Edge
CloudFront CloudFront
Systems Monitoring and Deployment
CloudWatch CloudWatch
X-Ray X-Ray
Messaging and Streaming
SNS SNS
Kinesis Kinesis
Kinesis Data Analytics Data Analytics
Kinesis Data Analytics Data Firehose
Compute
AWS Lambda Lambda
API Gateway API Gateway
Step Functions Step Functions
Data
DynamoDB DynamoDB
S3 S3
AppSync AppSync
Elasticsearch Elasticsearch
User Management and Identity
Cognito Cognito
Edge
CloudFront CloudFront
Systems Monitoring and Deployment
CloudWatch CloudWatch
X-Ray X-Ray
Messaging and Streaming
SNS SNS
Kinesis Kinesis
Kinesis Data Analytics Data Analytics
Kinesis Data Analytics Data Firehose

Our typical web application...

web app

...will then look like this:

web app

How to create these services?

Let's create the backend's services:

web app backend

with the console.

Nice... but how about real-life projects?

How about Infrastructure as Code?

Are there any alternatives?

offers great support:

So do open source frameworks:

  • Chalice
  • Claudiajs
  • Terraform
  • Sparta

Let's give Serverless Framework a try as it...

  • supports all languages
  • offers options for offline development
  • is provider-agnostic (AWS, Microsoft Azure, Google Cloud Platform, etc.)
  • uses CloudFormation under the hood (when deploying on AWS)
  • has great community
  • is well documented
  • offers many plugins
  • Mentioned among developer tools in AWS docs

Let's set up our environment:

  1. Create an IAM user with programmatic access to your account:
  2. Install the CLI
  3. Set up a named profile for your account using the credentials of the IAM user created in step .1:
    aws configure --profile=tech_talk
    export AWS_PROFILE=tech_talk
  4. Install the Serverless Framework:
    npm install -g serverless

Let's create the backend's services:

web app backend

with  Serverless Framework

We are going to build a web application starting from this code base:

What is needed to deploy our backend as:

web app backend

What is needed to deploy our frontend as:

web app backend

Let's connect DynamoDB to the backend

web app backend

Securing the backend with Amazon Cognito

web app backend

Securing the frontend with Amazon Cognito

web app backend

How much work does serverless take off our hands?

  • Logging / tracing
  • API Gateway (exposing to public)
  • Amplify lib simplifies client development
  • API Gateway integrates seamlesly with Amazon Cognito
Serverless Framework
  • Creates CloudFormation stacks behind the scenes
  • library to put an express app into a lambda function
  • Excluding dev dependencies when deploying
  • Website component cares about History API fallback and caching invalidation
  • Serverless Plugin to enable DynamoDB local
  • New environment -> define new stage

What is serverless good for?

  • runs infrequently
  • is tied to external events
  • has highly variable or unknown scaling requirements
  • has small and short-lived discrete functions
  • can operate in a stateless manner across invocations
Source: Gartner

Examples

  • Web applications
  • Background jobs (e.g. file processing after upload)
  • Microservices
  • Mobile backends
  • IoT events processing

What is (were) serverless not so good for?

  • exceeds Lambda's quotas, e.g.: timeout: 15 minutes, memory: 10 GB, payloads: 6 MB
  • has high, predictable and stable loads -> cost can be much more expensive than traditional VMs (e.g. EC2)
  • needs to keep state, e.g.: JDBC connections to SQL databases; can be fixed by Data API or RDS Proxy
  • cold start is an issue; can be fixed by provisioned concurrency

Cost estimation

What will serverless change?

  • Flexible software architectures allowing switching between different deployment models (VMs, containers, functions) -> hexagonal, DDD
  • Event driven architecture -> asynchronous, functional and reactive programming paradigms
  • More lightweight frameworks needed, e.g.: Middy instead of Express

Serverless enables green computing

Questions?

Slides available at: https://serverless-intro.github.io/

slides URL