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.

Getting Started with Serverless Architectures using Azure Functions

749 views

Published on

Presentation I gave at Techdays 2017 in Amsterdam.
First the concepts of a serverless architecture are explained. Then Azure Functions is introduced. The corresponding demo code can be found at https://github.com/marcduiker/demos-serverless-architectures-functions.

Published in: Technology
  • Be the first to comment

Getting Started with Serverless Architectures using Azure Functions

  1. 1. Getting Started with Serverless Architectures using Azure Functions MARC DUIKER
  2. 2. Marc Duiker Lead Consultant Xpirit Netherlands @marcduiker – mduiker@xpirit.com
  3. 3. Current situation Client PlaceOrder Search ValidateOrder CalculatePrice Orders Products Prices
  4. 4. Current situation - Problems Client PlaceOrder Search ValidateOrder CalculatePrice Orders Products Prices Expensive infrastructure Performance issues Teams require synced delivery
  5. 5. POC to redesign – Conditions & Requirements Client PlaceOrder Search ValidateOrder CalculatePrice Orders Products Prices Uneven & spikey workload 2 weeks Limited budget Fault tolerant Independent delivery
  6. 6. What are serverless architectures?
  7. 7. 1. Application that fully depends on a 3rd party service in the cloud to manage logic and state. Multiple interpretations for Serverless
  8. 8. 2. Application where some code is written by the developer but is run in stateless compute containers that are event-triggered, short lived and fully managed by a 3rd party. Multiple interpretations for Serverless
  9. 9. • Serverless is a misleading term • Functions as a Service (FaaS) is better “Serverless”
  10. 10. Traditional n-tier architecture Client PlaceOrder Search ValidateOrder CalculatePrice Orders Products Prices
  11. 11. Serverless architecture with FaaS Client PlaceOrder Gateway Search Validate Order Calculate Price Temp Storage Perm Storage Products Prices
  12. 12. Why a serverless architecture?
  13. 13. What we all want • A responsive application • Regardless of workload • Regardless of failures
  14. 14. Solution: Reactive Systems Responsive Message driven ResilientElastic https://www.reactivemanifesto.org/FaaS enables Reactive Systems
  15. 15. Serverless architecture with FaaS Client Temp Storage Gateway Search Products PlaceOrder Perm Storage Calculate Price Prices Validate Order
  16. 16. Serverless architecture with FaaS Client Temp Storage Gateway Search Products PlaceOrder Perm Storage Calculate Price Prices Validate Order
  17. 17. Benefits of FaaS • Focus on code instead of servers & runtime • Node.js , Python, C#, Java … • Reduced operational costs • Allows easier experimentation • Shorter time to market
  18. 18. Benefits of FaaS • Consumption based pricing • Resource consumption & number of executions # Executions / month 2m Time / execution 0.5 sec Time consumption 2m * 0.5 = 1m sec Avg memory consumption 1.5 GB Resource consumption 1.5 * 1m = 1.5m GB-s Resource price* 0.000014 Eur / GB-s Resource costs 1.5m * 0.000014 = 21 EUR Execution price* 0.169 EUR/1m executions Execution costs 2m * 0.169 = 0.34 EUR *Based on Azure Functions consumption plan dd 11 Oct 2017 2 1
  19. 19. Benefits of FaaS • Automatic scaling • Can reduce compute costs for spikey workloads constantspikey
  20. 20. Disadvantages of FaaS • Learning curve • Limited execution duration • Startup latency • Development tooling
  21. 21. FaaS offerings AWS Lambda (2014) Google Cloud Functions (2016) Azure Functions (2016)
  22. 22. How do Azure Functions fit in?
  23. 23. What is Azure Functions? “Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure.” https://docs.microsoft.com/en-us/azure/azure-functions/
  24. 24. What is Azure Functions?
  25. 25. Function Anatomy: Triggers & Bindings Input Output Trigger Code 1 0-n 0-n Function
  26. 26. Function Anatomy: Function App Input Output Trigger Code Function Function App Settings
  27. 27. The rise of the Functions WebJobs Functions
  28. 28. Differences with WebJobs • Seamless integration with Azure services • Azure Storage (Queues, Blobs) • Service Bus (Queues, Topics) • CosmosDB • Event Hubs • Webhooks • Timer • Consumption based pricing • Improved automatic scaling
  29. 29. Automatic scaling
  30. 30. Azure Functions Limitations • Max execution duration: 10 min (default 5 min) • Available memory: 1.5 GB
  31. 31. Developing Azure Functions
  32. 32. • Function scripts - Directly in the portal - Visual Studio Code • Compiled Functions - Visual Studio 2017 with Azure Function Tools Developing Functions
  33. 33. Demo: Developing Function Scripts
  34. 34. Benefits of Compiled Functions: • Enjoy the VS IDE features • Local debugging • Easier package management • Configure CI/CD pipelines • Reduce cold start time Developing in Visual Studio
  35. 35. Demo: Developing Compiled Functions
  36. 36. User uploads image Image requires validation Image needs to be analyzed Analysis result need to be stored Use case
  37. 37. Solution using Azure Functions & Queues images input images to analyze images too large analysis results to store validate analyze store blob DB
  38. 38. Solution using Azure Functions & Queues Upload images images input images to analyze images too large analysis results to store validate analyze store blob DB
  39. 39. Solution using Azure Functions & Queues Validate images images input images to analyze images too large analysis results to store validate analyze store blob DB
  40. 40. Solution using Azure Functions & Queues Analyze images images input images to analyze images too large analysis results to store validate analyze store blob DB
  41. 41. Solution using Azure Functions & Queues Store analysis data images input images to analyze images too large analysis results to store validate analyze store blob DB
  42. 42. Solution using Azure Functions & Queues Scope of the demo images input images to analyze images too large analysis results to store validate analyze store blob DB
  43. 43. Demo: Multiple Functions in one App
  44. 44. Demo data
  45. 45. Solution using Azure Functions & Queues Start situation images input images to analyze images too large analysis results to store validate analyze store blob DB 3 3
  46. 46. Solution using Azure Functions & Queues End situation images input images to analyze images too large analysis results to store validate analyze store blob DB 3 1 2
  47. 47. Demo: Doing the magic
  48. 48. ✓ Develop function using the Azure portal ✓ Develop function using Visual Studio ✓ Multiple functions in one Function App ✓ Microsoft Azure Storage Explorer ✓ Function App Logs Developing Functions Demos
  49. 49. Deploying Azure Functions
  50. 50. Edit & save scripts in Portal Publish from Visual Studio Deploy straight from source control Deploy from VSTS Deploying Functions
  51. 51. Demo: Deploying Functions
  52. 52. ✓ Configure deployment using Azure Portal ✓ Configure deployment using VSTS Deploying Functions Demos
  53. 53. Other scenarios
  54. 54. Currently you need to provide a message queue to chain functions. Function Chaining & Durable Functions
  55. 55. Function Chaining & Durable Functions https://azure.github.io/azure-functions-durable-extension/ Durable Functions will use Orchestrator and Action functions making it easier for developers to chain functions.
  56. 56. Use Functions as Actions Functions & Logic Apps
  57. 57. Use an API gateway to manage your Functions API Gateway Client PlaceOrder Search ValidateCalculate Temp Storage Perm Storage Products Gateway
  58. 58. Marc Duiker Lead Consultant Xpirit Netherlands @marcduiker – mduiker@xpirit.com Go and discover endless possibilities with Azure Functions! https://github.com/marcduiker/ demos-serverless-architectures-functions/

×