340 likes | 360 Views
Alex Karcher. Program manager – Microsoft. 5 tips for production ready Azure Functions. Common Architecture Patterns. Serverless APIs Mobile / Web backends Event and Stream Processing IoT event and data processing Big data and machine learning pipelines
E N D
Alex Karcher • Program manager – Microsoft 5 tips for production ready Azure Functions
Common Architecture Patterns • Serverless APIs • Mobile / Web backends • Event and Stream Processing • IoT event and data processing • Big data and machine learning pipelines • Integration and Enterprise Service Bus • Connecting line-of-business systems • Pub/Sub for business events • Automation and Digital Transformation • Process automation
Sample synchronous serverless architecture CosmosDB API Management (primary) Traffic Manager API Management (secondary) CosmosDB
Azure Functions “Behind the scenes” HTTP Request HTTP Response
Functions “Behind the scenes” Azure Infrastructure Functions Instance Functions Instance Functions Instance Azure Functions Runtime HTTP Request Azure Functions (App Services) HTTP Front-end HTTP Response Azure Functions Runtime Scale Controller Azure Functions Runtime
Scalability Considerations • The “Scale Controller” determines how many instances are actively doing work • For Event Hub, Queue, Service Bus the scale controller can assess message backlog length and burndown rate to scale • For HTTP functions today looks at request queue for each instance • The “host.json” config file allows you to set instance limits for concurrency at an instance level • Other knobs are to turn off file-system logging, and not include a dashboard storage account
Your app with one pre-warmed instance Minimum Plan Size
Your app with a 3 instance min plan size Minimum Plan Size
Sample synchronous serverless architecture CosmosDB Devices and Clients Event / IoT Hubs
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients CosmosDB
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Partition 2 CosmosDB Partition 3 Partition 4
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Partition 2 CosmosDB Partition 3 Partition 4
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Device 2 Partition 2 CosmosDB Device 3 Partition 3 Device 4 Partition 4
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Device 2 Partition 2 CosmosDB Device 3 Partition 3 Device 4 Partition 4 Device 5
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Device 2 Partition 2 CosmosDB Device 3 Partition 3 Device 4 Partition 4 Device 5
Sample synchronous serverless architecture Event / IoT Hubs Function Instances Devices and Clients Device 1 Partition 1 Device 2 Partition 2 CosmosDB Device 3 Partition 3 Device 4 Partition 4 Device 5
Scalability Considerations • This is a bread-and-butter serverless scenario – elastic growth • Process messages in a batch (`EventData[]`) – “cardinality: many” • Only one active instance per partition • You can guarantee ordering with Event Hubs • You must handle exceptions yourself. No deadletter queue • Messaging choices: • Event Hubs – high scale, high throughput, ordering is preserved • Service Bus Queues / Topics – ”never lose a message”, ordering via sessions. Good for high variable workloads • Storage Queues – inexpensive, less “enterprise” and message broker features • Event Grid – send an ”event” out, any subscribers can get poked to be alerted. No ordering, no transnationality
TIP 3 - EventHub Scale Options • Add partitions • You can raise beyond 32 by contacting support 🤫 • Increase Functions instance size • Premium Plan
Inner and Outer Loop Development Outer Loop Build and Test (CI) Run (Prod) Deploy (CD) Code Run Debug Inner Loop Monitoring and Diagnostics Source Control
Inner and Outer Loop Development Outer Loop Build and Test (CI) Run (Prod) Deploy (CD) Code Run Debug Inner Loop Monitoring and Diagnostics Source Control
Dev Ops GA of Functions Build task Easily add Functions to a CI/CD pipeline New streamlined CLI command azfunctionappdevops-pipeline create Automatically configures DevOps to build with new commits to your version control Configures Github or Azure Repos automatically aka.ms/functions-azure-devops
Inner and Outer Loop Development Outer Loop Build and Test (CI) Run (Prod) Deploy (CD) Code Run Debug Inner Loop Monitoring and Diagnostics Source Control
Tip 5: Monitoring • Gain real-time observability • Analyze and debug traces and metrics • View dependencies and relationships with AppMap Application Insights
Alex Karcher • Product manager – Microsoft 5 tips for production ready Azure Functions