Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Serverless

1,996 views

Published on

Covers the concept behind serverless architectures, how Functions as a Service (FaaS) work and how to deploy such a serverless function.

Published in: Technology

Introduction to Serverless

  1. 1. Introduction to Serverless
  2. 2. What is Serverless? • Serverless Book • Serverless Conference • Serverless Framework • Serverless Inc. • Serverless Architectures • Serverless Application Model
  3. 3. Mike Roberts “Serverless architectures refer to applications that significantly depend on third-party services (knows as Backend as a Service or "BaaS") or on custom code that's run in ephemeral containers (Function as a Service or "FaaS"), the best known vendor host of which currently is AWS Lambda. By using these …” https://martinfowler.com/articles/serverless.html
  4. 4. Function as a unit of application logic
  5. 5. How does it work? • New instances based on invocation demand • Events trigger a function
  6. 6. Check if an instance is running Yes No Handle the Request Stop the Process
 (stop the instance if idle to long) Start an instanceActivate the Process
  7. 7. Isn’t that limiting? Yes! 🙃
  8. 8. Benefits • 📈 Auto scaling • 💵 Pay per execution • 🎪 Event Driven • 🗝 Security
  9. 9. Common Use Cases • 🕸 Web Applications • 📱 Mobile & IoT Backends • 💹 Data Processing • 🤖 Chatbots
  10. 10. Providers • AWS Lambda • Google Cloud Functions • Microsoft Functions • IBM Openwhisk • Auth0 Webtasks • IronIO IronFunctions • many more …
  11. 11. Numbers • Thomson Reuter processes 4000 req/sec • Finra processes half a trillion validations of stock trades daily • Vevo can handle spikes of 80x normal traffic
  12. 12. Challenges • Monitoring • Cold starts • Development flow • Application architecture • Service Discovery • Service Communication
  13. 13. Deployment Options • User Interface • API calls (Serverless Framework v0, Claudia, Zappa, Apex) • CloudFormation (Serverless Framework v1, SAM)
  14. 14. Deploy via the UI
  15. 15. Deploy via the API var params = { Code: {}, Description: "", FunctionName: "MyFunction", Handler: "souce_file.handler_name", MemorySize: 128, Publish: true, Role: "arn:aws:iam::123456789012:role/service-role/role-name", Runtime: "nodejs4.3", Timeout: 15, VpcConfig: {} }; lambda.createFunction(params, function(err, data) { if (err) console.log(err, err.stack); else console.log(data); });
  16. 16. Deploy via CloudFormation
  17. 17. Deploy via Serverless Framework # serverless.yml service: serverless-simple-http-endpoint frameworkVersion: ">=1.1.0 <2.0.0" provider: name: aws runtime: nodejs4.3 functions: currentTime: handler: handler.endpoint events: - http: path: ping method: get
  18. 18. // handler.js module.exports.endpoint = (event, context, callback) => { const time = new Date().toTimeString(); const response = { statusCode: 200, body: JSON.stringify({ message: `Hello, the current time is ${time}.`, }), }; callback(null, response); };
  19. 19. service: scheduled-cron-example provider: name: aws runtime: nodejs4.3 functions: cron: handler: handler.run events: # Invoke Lambda function every minute - schedule: rate(1 minute) secondCron: handler: handler.run events: # Invoke Lambda function every 2nd minute from Mon-Fri - schedule: cron(0/2 * ? * MON-FRI *)
  20. 20. service: text-analysis-via-sns-post-processing frameworkVersion: ">=1.1.0 <2.0.0" provider: name: aws runtime: nodejs4.3 functions: analyzeNote: handler: analyzeNote.analyzeNote events: - sns: analyzeNote
  21. 21. Services • Database • FilesStorage • Queues • HTTP • WebSockets • IoT Management
  22. 22. Fin 
 Thanks for listening!
 https://github.com/nikgraf
 https://twitter.com/nikgraf

×