Break-up with your Server
But don't commit to a cloud platform.
Linda Nichols
@lynnaloo
Norfolk.js
norfolkjs.org
RevolutionConf
Virginia Beach, VA
Today, we're going to break-up with our servers.
@lynnaloo
But we're not going to commit to a cloud platform.
@lynnaloo
Because developers have commitment issues.
@lynnaloo
Even when they have a great partner.
@lynnaloo
Amazon Web Services
@lynnaloo
IBM Bluemix
@lynnaloo
Microsoft Azure
@lynnaloo
Google Web Toolkit
@lynnaloo
When someone says, "serverless"* ...
@lynnaloo
* "Serverless" is just a catchy, made-up, marketing term.
Kind of like, "Cloud."
@lynnaloo
They don't mean ...
@lynnaloo
They probably mean ...
AWS Lambda
@lynnaloo
Or generally, Serverless Functions (FaaS).
@lynnaloo
Functions-as-a-Service (FaaS)
Stateless functions running in containers managed by a service provider (not you!).
@lynnaloo
Serverless Architecture?
But "Serverless" isn't really about a platform or compute product...
@lynnaloo
Serverless Architecture?
It's about the events!
@lynnaloo
Serverless Architecture
-
Storage
-
IoT
-
Database Actions
-
API Gateway
-
Queues and Topics
-
Logging
@lynnaloo
How do you go "serverless" without vendor lock-in?
@lynnaloo
Option #1:
Roll your own containers
-
OpenFaaS
-
Kubeless
-
Iron.io
-
OpenWhisk
@lynnaloo
Option #2:
Commit to multi-provider framework
@lynnaloo
Serverless Framework:
-
Open-source
-
Abstracts and automates 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
What about the platform-specific services?
@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
Demo Time!
@lynnaloo
github.com/lynnaloo/beatlemania
Demo Time!
@lynnaloo
Thank You!
@lynnaloo
Break-up with Your Server
By Linda Nichols
Break-up with Your Server
Break-up with your Server, but Don't Commit to a Cloud Platform. ServerlessConf 2017
- 2,278