Serverless
JaxNode Oct 2016
Node News
- Node 7 coming soon
- Node 6 now moved into LTS with 4
- Yarn released
November
Redux
Yarn
- JS Package Manager
- From Google, Facebook and others
- Security
- Performance
- Offline Cache
NPM
npm install
npm install lodash --save
npm uninstall lodash --save
npm install babel -g
npm update --save
Yarn
yarn
yarn add lodash
yarn remove lodash
yarn global add babel
yarn upgrade
Cool features
- yarn licenses ls
- yarn licenses generate
- yarn why lodash
Yarn Demo
Servers
Hosting Applications
- Run locally
- Deploy to Server (in a data center hopefully)
- On Premise
- Co-Location in rack space
- Cloud Hosting (Rackspace, CenturyLink)
- PAAS (AWS EC2, Azure, Bluemix)
- Container hosting
- Serverless (Lambda, Azure Functions)
Tenets of Serverless
- Composed of many services
- Sometimes called micro-services
- May have less than 200 lines of code
- One function per service
- Logging important!!!
AWS Lambda
- Written in JS, Java or Python
- Bound to events or HTTP requests
- 128 MB RAM Default per function
- Monitor logging with CloudWatch
Azure Functions
- Azure version of AWS Lambda
- Similar model
- NPM install modules through console
Advantages of Serverless
- Lowest Cost hosting
- Simple development model
- Simple deployment
- Don't have to worry about load scheduling
- Scales automagically
$0.20 per 1 million requests
Disadvantage of Serverless
- Local development a challenge
- No NPM Support (Azure has NPM)
- Debugging threw logging
Ocean Disc example
- Mobile app had to store reports
- Upload to S3 storage
- Process files based on upload event
- Call REST based service
- Accomplished threw AWS Lambda
Serverless Framework
- Formerly Called Jaws
- Currently AWS only
- Build entire apps from Lambda
- Organize Lambda functions
- Local development and testing
- resource management (APIs and Databases)
- Multi-region development
method signature
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Hello World!',
input: event,
}),
};
callback(null, response);
};
Serverless CLI
- $ sls create --template aws-nodejs
- $ sls deploy
- $ sls deploy --function functionName
- $ sls invoke --function functionName
- $ sls logs -f hello
- $ sls info
Demo
Questions?
Resources
Serverless
By David Fekke
Serverless
These are the slides for the October 2016 Serverless presentation at the JaxNode User Group
- 2,099