Serverless
Hype or the Future?
Where is serverless in the Gartner hype cycle?
How much is serverless going to be adopted?
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]
Sounds promising, doesn't it?
So let's build a typical web application:
... and see if the promises come true
Compute
Lambda
API Gateway
Step Functions
User Management and Identity
Cognito
Edge
CloudFront
Systems Monitoring and Deployment
CloudWatch
X-Ray
Messaging and Streaming
SNS
Kinesis
Data Analytics
Data Firehose
Compute
Lambda
API Gateway
Step Functions
User Management and Identity
Cognito
Edge
CloudFront
Systems Monitoring and Deployment
CloudWatch
X-Ray
Messaging and Streaming
SNS
Kinesis
Data Analytics
Data Firehose
Our typical web application...
...will then look like this:
How to create these services?
Let's create the backend's services:
with the console.
Nice... but how about real-life projects?
How about Infrastructure as Code?
Are there any alternatives?
So do open source frameworks:
Let's give
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:
Create an IAM user with programmatic access to your account:
- Install the CLI
- 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
- Install the Serverless Framework:
npm install -g serverless
Let's create the backend's services:
with 
We are going to build a web application starting from this code base:
What is needed to deploy our backend as:
What is needed to deploy our frontend as:
Let's connect DynamoDB to the backend
Securing the backend with Amazon Cognito
Securing the frontend with Amazon Cognito
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
- 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
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