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.

Building Event-Driven Serverless Applications

1,079 views

Published on

We built event-driven user interfaces for decades. What about bringing the same approach to mobile, web, and IoT backend applications? You have to understand how data flows and what is the propagation of changes, using reactive programming techniques. You can focus on the core functionalities to build and the relationships among the resources you use. Your application behaves similarly to a “spreadsheet”, where depending resources are updated automatically when something “happens”, and is decomposed into scalable microservices without having to manage the infrastructure. The resulting architecture is efficient and cost effective to run on AWS and managing availability, scalability and security becomes part of the implementation itself.

Published in: Software

Building Event-Driven Serverless Applications

  1. 1. Building Event-Driven Serverless Applications Danilo Poccia Technical Evangelist @danilop danilop
  2. 2. Virtual Machines
  3. 3. Virtual Machines Containers
  4. 4. Virtual Machines Containers Functions
  5. 5. Event-Driven in the Front End
  6. 6. Name Email Create New User Submit Check the “Name” syntax is right (only letters and spaces) Check the “Email” syntax is right (something@some.domain) Create the new user using provided Name and Email User Interface Actions
  7. 7. Name Email Create New User Submit Check the “Name” syntax is right (only letters and spaces) Check the “Email” syntax is right (something@some.domain) Create the new user using provided Name and Email User Interface ActionsObservers Target Action
  8. 8. What about the Back End ?
  9. 9. Users
  10. 10. Internet Users
  11. 11. Back End Logic Internet Users
  12. 12. Back End Data Back End Logic Internet Users
  13. 13. Back End Data Application Back End Back End Logic Internet Users
  14. 14. Application Back End Web Browsers Back End Data Back End Logic
  15. 15. Application Back End Web Browsers Mobile Apps Back End Data Back End Logic
  16. 16. Application Back End Web Browsers Mobile Apps IoT Devices Back End Data Back End Logic
  17. 17. Application Back End Web Browsers Mobile Apps IoT Devices Other Services Back End Data Back End Logic
  18. 18. Application Back End Files Databases Web Browsers Mobile Apps IoT Devices Other Services Back End Logic
  19. 19. HTML, CSS, JavaScript & Multimedia Content API Calls Application Back End Web Browsers Mobile Apps IoT Devices Other Services Files Databases Back End Logic
  20. 20. API Calls Application Back End HTML, CSS, JavaScript & Multimedia Content Web Browsers (JavaScript) Mobile Apps IoT Devices Other Services By using JavaScript, Web Browsers can behave like the other clients, such as Mobile Apps or IoT Devices Files Databases Back End Logic
  21. 21. API Calls Application Back End HTML, CSS, JavaScript & Multimedia Content Web Browsers (JavaScript) Mobile Apps IoT Devices Other Services Files Databases Back End Logic
  22. 22. Client Application API Calls Application Back End HTML, CSS, JavaScript & Multimedia Content The Client Application can be a Web Browser, a Mobile App, an IoT Device, or another Service We can now decouple the back end implementation from the device used by our users Files Databases Back End Logic
  23. 23. Client Application API Calls Application Back End HTML, CSS, JavaScript & Multimedia Content The Client Application can be a Web Browser, a Mobile App, an IoT Device, or another Service Files Databases Back End Logic
  24. 24. Functions as your API
  25. 25. Context Function Event AWS Lambda Result RequestResponse Function Invocation Lambda API Call AWS Lambda Functions Synchronous Invocations
  26. 26. Context Function Event AWS Lambda Event Function Invocation Lambda API Call AWS Lambda Functions Asynchronous Invocations
  27. 27. ContextContextResource ContextContextResource Context Function Event AWS Lambda Managed by AWS Not managed by AWS Result (Optional) Function Invocation Resources can be files, records in a DB, etc. Lambda API Call Functions can Modify Resources
  28. 28. Events (Context) Events (Context) Generated by AWS Not generated by AWS ContextContextResource ContextContextResource Context Function Event AWS Lambda Managed by AWS Not managed by AWS Result (Optional) Function Invocation Lambda API Call Resources can Generate more Events
  29. 29. Events (Context) Events (Context) Generated by AWS Not generated by AWS ContextContextResource ContextContextResource AWS Lambda Managed by AWS Not managed by AWS Direct Use of Resource For example, a file is uploaded or something is written in a database AWS Lambda Function 2 Function 3 Function 1 Events can Trigger more Functions
  30. 30. Sample Event-Driven Serverless Media-Sharing Application
  31. 31. Client Application Event-driven Backend User
  32. 32. Client Application Get Content Index Get Content Upload Content with Metadata Update Content Metadata Get Content Metadata User
  33. 33. Client Application Get Content Index Get Content Upload Content with Metadata Update Content Metadata Get Content Metadata AWS Lambda User
  34. 34. Client Application Get Content Index Get Content Upload Content with Metadata Update Content Metadata Get Content Metadata Files (Multimedia) Database AWS Lambda User Resources
  35. 35. Client Application Get Content Index Get Content and Thumbnails Upload Content with Metadata Update Content Metadata Get Content Metadata Files (Multimedia) Database Build Thumbnails Update Content Index Extract and Update Metadata Event: new or updated file Event: new or updated content metadata AWS Lambda User Resources
  36. 36. Get Content Index Get Content and Thumbnails Upload Content with Metadata Update Content Metadata Get Content Metadata Files (Multimedia) Database Build Thumbnails Update Content Index Extract and Update Metadata User Mobile App
  37. 37. Get Content Index Get Content and Thumbnails Upload Content with Metadata Update Content Metadata Get Content Metadata Files (Multimedia) Database Build Thumbnails Update Content Index Extract and Update Metadata User Web Browsers (JavaScript)
  38. 38. Calling Functions from the Client
  39. 39. Client Application AWS Lambda Function AWS Lambda Invoke API User Calling Lambda Functions Directly
  40. 40. Client Application AWS Lambda Function AWS Lambda Invoke API Get Temporary AWS Credentials Amazon Cognito User Getting AWS Credentials from Amazon Cognito
  41. 41. Client Application AWS Lambda Function Amazon Cognito Amazon
 API Gateway Get Temporary AWS Credentials Web API Modeling, Caching, Throttling, Logging, CDN, etc. User Exposing Functions as Web API
  42. 42. Client Application AWS Lambda Function Amazon
 API Gateway Web API Modeling, Caching, Throttling, Logging, CDN, etc. User Exposing Functions as Public Web API
  43. 43. https://some.domain/stage/resource1/resource2/…/resourceN GET POST PUT DELETE HEAD PATCH OPTIONS Unique domain that you can customize API stage, for example
 prod, test, dev, or v0, v1, … Resources as part of the URL HTTP verb
 used when accessing the URL function1 function2 function3 function1 function2 function3 function1 Function to execute Web API to Lambda Functions Integration
  44. 44. Web API to Lambda Functions Mapping Resource + HTTP Verb ➔ Method
  45. 45. Web API to Lambda Functions Mapping Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks
  46. 46. Web API to Lambda Functions Mapping Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks /books + POST ➔ CreateNewBook
  47. 47. Web API to Lambda Functions Mapping Resource + HTTP Verb ➔ Method /books + GET ➔ GetAllBooks /books + POST ➔ CreateNewBook /books/{id} + GET ➔ GetBookById /books/{id} + PUT ➔ CreateOrUpdateBookById /books/{id} + DELETE ➔ DeleteBookById
  48. 48. Best Practices
  49. 49. Distributed Systems
  50. 50. Distribute the Logic React to Changes
  51. 51. Preserve Independent Deployment Of Functions
  52. 52. <demo> ... </demo>
  53. 53. Building Event-Driven Serverless Applications Danilo Poccia Technical Evangelist @danilop danilop

×