Serverless Architecture
A Love Story!

Linda Nichols
@lynnaloo

Norfolk.js
norfolkjs.org
















@lynnaloo
Today you're going to fall in love with Serverless Architecture...
But first, you have to break-up with your servers.


@lynnaloo

@lynnaloo
This story has all of the pieces of a typical romance:
-
Break-ups and decoupling
-
Commitment (and no-commitment)
-
Highly cohesive relationships
-
High availability and dedication
-
Support and growth
But first, what is "serverless"* architecture?


@lynnaloo
* "Serverless" is just a catchy, made-up, marketing term.
(Kind of like, "Cloud")


@lynnaloo
Serverless Architecture?
It isn't about a platform or compute product...


@lynnaloo
Serverless Architecture?
It's about the events!



@lynnaloo
Serverless Architecture?
Serverless Architecture is an event-driven system that uses remote functions (likely via a a FaaS product) without concern for the operations of the containers that execute the code.

@lynnaloo

@lynnaloo
Functions-as-a-Service (FaaS)

Stateless functions running in execution environments managed by a service provider (not you!).
Functions-as-a-Service (FaaS)
-
Building block of Serverless Architecture
-
Stateless and ephemeral
-
Functions run in managed execution environments
-
Removes the complexity of building your own infrastructure
-
You only pay for functions when you use them

@lynnaloo

@lynnaloo

Your code could be completely free...





@lynnaloo
Functions-as-a-Service (FaaS)


@lynnaloo
AWS Lambda
Most popular kid in school


@lynnaloo
Azure Functions
The Developer's Favorite


@lynnaloo
IBM Cloud Functions
They do really mean open


@lynnaloo
Google Cloud Functions
Finally in GA!
Serverless Architecture
-
Storage
-
IoT
-
Database Actions
-
API Gateway
-
Queues and Topics
-
Logging


@lynnaloo
Functions can be triggered by other cloud services
Functions are Microservices
-
Responsible for one specific task
-
Lightweight and fast
-
Reusable
-
Deployed independently
-
Not dependent on other services
-
Work together to power applications

@lynnaloo

@lynnaloo
Did someone say decoupling?


@lynnaloo
Serverless Architecture


@lynnaloo
Your perfect match!
Serverless Architecture
-
Dedicated
-
Flexible
-
Supportive
-
Resilient
-
Growth potential
-
Speaks many languages!
What if I'm scared of commitment?


@lynnaloo


@lynnaloo
The cloud platforms do have analogous services...
Relationship Counseling



@lynnaloo
Embrace frameworks!
Serverless Framework:
-
Open-source
-
Abstracts provider-specific tasks
-
Multi-provider plugin system
-
Scaffold and deploy using CLI

@lynnaloo
Get started.
# Install serverless cli
$ npm install serverless -g
# Create AWS Service
$ serverless create --template aws-nodejs --path cat-name-service
# Change into the service directory
$ cd cat-name-service
# Deploy to cloud provider
$ serverless deploy -v
cat-name-service/
package.json
serverless.yml
handler.js
dog-name-service/
package.json
serverless.yml
handler.js

@lynnaloo
Configure Service and Events.
#serverless.yml
service: cat-name-service
provider:
name: aws
runtime: nodejs6.10
functions:
catName:
handler: handler.getCatName
events:
- http:
path: cats/name
method: get

@lynnaloo
Create Handler.
'use strict';
const catNames = require('cat-names');
function getCatName(event, context, callback) {
callback(null, { payload: `Your cat name is ${catNames.random()}.` });
}
module.exports = getCatName;
(then package and/or deploy it!)

@lynnaloo
'use strict';
const catNames = require('cat-names');
const AmazonDb = require('amazon-db-module');
function getCatName(event, context, callback) {
const amazonDb = new AmazonDb();
const catName = catNames.random();
amazonDb.update(catName);
callback(null, { payload: `Your cat name is ${catName}.` });
}
module.exports = getCatName;
'use strict';
const catNames = require('cat-names');
const GoogleDb = require('google-db-module');
function getCatName(request, response) {
const googleDb = new GoogleDb();
const catName = catNames.random();
googleDb.update(catName);
return response.status(200).send(`Your cat name is ${catName}.`);
}
module.exports = getCatName;



@lynnaloo

@lynnaloo

But what about the events?

@lynnaloo


@lynnaloo
Cloud Events
a specification for describing event data in a common way
-
Azure Event Grid natively supports events in the CloudEvents JSON schema
-
Serverless Framework's Event Gateway
Audience Participation!


@lynnaloo
Mention @thesecatstweet in a tweet with the hashtag #valentinebot
Demo Time!


@lynnaloo
Thank You!

@lynnaloo
Serverless Architecture: A Love Story
By Linda Nichols
Serverless Architecture: A Love Story
A love story about Serverless Architecture.
- 1,363