Slide 1

Slide 1 text

Spencer Schneidenbach Exploring Serverless in .NET From Azure to AWS and beyond

Slide 2

Slide 2 text

@schneidenbach [email protected]

Slide 3

Slide 3 text

Why?

Slide 4

Slide 4 text

What is “serverless”?

Slide 5

Slide 5 text

https://www.cloud fl are.com/learning/serverless/what-is-serverless/ Serverless computing is a method of providing backend services on an as-used basis. Servers are still used, but a company that gets backend services from a serverless vendor is charged based on usage, not a fi xed amount of bandwidth or number of servers.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

The three major cloud providers 0 10 20 30 40 https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/ % Marketshare ?

Slide 9

Slide 9 text

The three major cloud providers 0 10 20 30 40 https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/ % Marketshare

Slide 10

Slide 10 text

The three major cloud providers 0 10 20 30 40 https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/ % Marketshare

Slide 11

Slide 11 text

My experience • 90% of what I do is in Microsoft Azure. • I have used Azure and AWS in production. Worked on entire serverless platforms in both Azure and AWS. • My big bias: delivery > perfection.

Slide 12

Slide 12 text

What cloud providers probably think Service 1 Service 2 Service 3 Meaningful Overlap

Slide 13

Slide 13 text

Reality

Slide 14

Slide 14 text

What this talk is • Good general overview and walkthrough of my experience • De fi nitely developer-centric, with lots of architect-y opinions • Discussion on the two major serverless options: • “Turnkey” functions • Container hosting models

Slide 15

Slide 15 text

What this talk ISN’T • A so-called “expert” preaching you about “the right way” • A recommendation on any particular cloud provider for .NET • Dogmatic • You may disagree with some things I say • I also cannot know everything

Slide 16

Slide 16 text

What we will cover • In some depth • Azure Functions/AWS Lambdas/Google Cloud Functions • Azure Container Functions/AWS App Runner/AWS Fargate/Google Cloud Run • By mention only • Azure App Service/AWS Elastic Beanstalk/Google App Engine • Kubernetes stu f

Slide 17

Slide 17 text

For each thing we will discuss • Development experience • Tooling - Visual Studio, Rider, .NET CLI, AWS CLI, GCloud CLI • Deployment • Monitoring • Maturing past “basic” functions • Nuance! (Or as much as I could add in)

Slide 18

Slide 18 text

You can do great things with “the cloud”

Slide 19

Slide 19 text

https://www.troyhunt.com/serverless-to-the-max-doing-big-things-for-small-dollars-with-cloud fl are-workers-and-azure-functions/

Slide 20

Slide 20 text

All cloud providers have similar offerings. What do you value?

Slide 21

Slide 21 text

@PHP_CEO

Slide 22

Slide 22 text

“Friction Man”

Slide 23

Slide 23 text

Testing methodology • Started with a brand new cloud account for each provider • Used the following tools • Visual Studio • Rider • dotnet CLI • AWS CLI • Google Cloud CLI

Slide 24

Slide 24 text

Really basic things • Deploy a function with a contrived error condition • Run it 100 times • See what happens!

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Lessons learned • More nuance than I expected • Clouds have strengths and weaknesses • There’s friction everywhere - the question is, what friction is tolerable to you and your team?

Slide 29

Slide 29 text

Azure

Slide 30

Slide 30 text

Azure Serverless • Azure Functions (regular and premium) • Azure Container Apps • Azure App Service

Slide 31

Slide 31 text

Azure Functions • Simple requests (HTTP, Event Grid, etc) • Great for event-based architectures and small bits of code

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

@schneidenbach

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Azure Monitor/Application Insights • Comprehensive goodness out of the box • Comparatively expensive • …honestly I prefer third party vendors like DataDog

Slide 47

Slide 47 text

Two execution paths for Azure Functions • In process - Azure Functions that execute inside of the Functions host process • Isolated - runs inside a worker process https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-di ff erences

Slide 48

Slide 48 text

In process vs isolated Feature/behavior In-process Isolated worker process Supported .NET versions Long Term Support (LTS) versions All supported versions + .NET Framework Core packages Microsoft.NET.Sdk.Functions Microsoft.Azure.Functions.Worker Microsoft.Azure.Functions.Worker.Sdk Durable Functions Supported Supported (public preview) HTTP trigger model types HttpRequest / ObjectResult HttpRequestData / HttpResponseData Dependency injection Supported Supported Middleware Not supported Supported Logging ILogger passed to the function ILogger via dependency injection ILogger/ILogger obtained from FunctionContext or via dependency injection Cancellation tokens Supported Supported Cold start times (Baseline) Additionally includes process launch https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-di ff erences

Slide 49

Slide 49 text

In process vs isolated

Slide 50

Slide 50 text

Isolated woes

Slide 51

Slide 51 text

Azure Functions (premium) • Can have pre-warmed instances, preventing cold starts • Minimum spend required, though https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal

Slide 52

Slide 52 text

Premium elastic plan pricing https://learn.microsoft.com/en-us/azure/azure-functions/functions-premium-plan?tabs=portal

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Azure Container Apps • Best of all possible worlds as you scale - more fl exible hosting option with less spend required during idle periods

Slide 55

Slide 55 text

https://endjin.com/blog/2022/09/bye-bye-azure-functions-hello-azure-container-apps-part-1-introduction Like Azure Functions, ACA pricing is consumption-based and you have the option for your containers to scale down to zero if needed. Obviously this wouldn't help with the cold start issues we've covered above, but it's also possible to set a minimum number of replicas for your container, which would have much the same effect as the Premium Functions plan mentioned above. However, there's a potential advantage over the Premium Functions Plan; the notion of containers becoming inactive - meaning they are still provisioned but idle - in which state the cost is significantly lower. Azure Container Apps

Slide 56

Slide 56 text

Premium Cloud “growth”

Slide 57

Slide 57 text

Azure Summary • Azure Functions - great for small bits of code to respond to events and/or starting out. HTTP APIs as well… if you don’t mind the cold start. • Azure Functions Premium - great “next level” destination for Azure Functions if you need to help eliminate cold starts, but more expensive (obv) • This article describes spinning this up temporarily when anticipating tra ffi c spikes, then spinning it back down to normal Consumption after the work is done. (Example: https:// www.davepaquette.com/archive/2020/05/23/scaling-azure-functions-from-consumption- plan-to-premium-hosting-plan.aspx) • Azure Container Apps - gives more fl exibility for building scalable apps • Azure App Service - I use these for more general purpose web app hosting, especially if I need predictable pricing and easy, fl exible scale up, easy web con fi guration, etc. https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale

Slide 58

Slide 58 text

AWS

Slide 59

Slide 59 text

Serverless options in AWS • AWS Lambda/AWS Serverless Lambdas • AWS App Runner/Fargate • AWS Elastic Beanstalk

Slide 60

Slide 60 text

dotnet new -i Amazon.Lambda.Templates

Slide 61

Slide 61 text

dotnet tool install -g Amazon.Lambda.Tools https://aws.amazon.com/cli/

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

IAS

Slide 68

Slide 68 text

IAS

Slide 69

Slide 69 text

https://github.com/ysugimoto/aws-lambda-image/issues/153

Slide 70

Slide 70 text

https://github.com/ysugimoto/aws-lambda-image/issues/153#issuecomment-910356865

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

IAS

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

Other hosted services • AWS Elastic Beanstalk • Like Azure App Service, but I have not heard anyone say a positive thing about it • AWS Fargate/App Runner/Elastic Kubernetes Service

Slide 88

Slide 88 text

AWS Summary • Lambdas - similar to Azure Functions in pretty much every way • AWS Serverless Application using Lambdas - almost certainly the direction I would go • AWS App Runner - akin to Container Apps • AWS Fargate - lower level than App Runner • Great article about nuanced di ff erences btwn Fargate and App Runner: https://cloudonaut.io/fargate-vs-apprunner/ • AWS Elastic Beanstalk… kind of like App Service but apparently it’s way worse?

Slide 89

Slide 89 text

“Honorable” mentions? • Provisioned concurrency • Do The “Jeremy” • Jeremy sez: he uses Serverless framework (https://www.serverless.com/) and aws-vault for dev work.

Slide 90

Slide 90 text

Google Cloud

Slide 91

Slide 91 text

Serverless options in Google Cloud • Cloud Functions • Cloud Run • App Engine

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

Nitpicky at best • Does not support .NET Framework • Not as widely adopted as the other cloud providers, duh

Slide 112

Slide 112 text

Something really cool • https://shell.cloud.google.com/

Slide 113

Slide 113 text

@schneidenbach

Slide 114

Slide 114 text

@schneidenbach

Slide 115

Slide 115 text

Something really cool • https://shell.cloud.google.com/

Slide 116

Slide 116 text

GCS Summary • Cloud Functions - similar to Azure Functions and Lambdas in pretty much every way • Cloud Run - managed container system akin to Azure Container Apps/AWS App Runner • App Engine - generalized app hosting akin to App Service • Detailed cost comparison of Functions vs Run • https://medium.com/google-cloud/cloud-run-vs-cloud-functions-whats- the-lowest-cost-728d59345a2e

Slide 117

Slide 117 text

The Conclusions Slide

Slide 118

Slide 118 text

Initial Thoughts • Most of your cloud providers are going to have been chosen already • Your architecture should only be as complicated as it needs to be • Bias getting stu ff done > overthinking what scale you think you MIGHT need • Cloud costs are easy to lose control of - ensure you’re monitoring well. • https://www.troyhunt.com/how-i-got-pwned-by-my-cloud-costs/

Slide 119

Slide 119 text

General suggestions • Azure Functions/AWS Lambdas/Google Functions for simple slices of functionality, especially when cold starts aren’t super critical. • LOVE it for event-driven stu ff . • All cloud providers have a way of “promoting” functions, mainly to eliminate cold starts and manage costs/resources better. You will probably know when you feel you need to do this. • Spencer’s case study

Slide 120

Slide 120 text

No content

Slide 121

Slide 121 text

@schneidenbach Azure AWS Google Basic Functions Azure Functions AWS Lambda/AWS Lambda Serverless Cloud Functions "Premium" Functions Azure Functions Premium Provisioned Concurrency* Cloud Run Minimum instances* Container abstractions Azure Container Apps AWS AppRunner Cloud Run Lower-level container abstractions Azure Container Instances AWS Fargate Cloud Run I guess? K8S aka The Big Time Azure Kubernetes Service Amazon EKS (Elastic K8S Service) Google Kubernetes Engine General App Host App Service Elastic Beanstalk App Engine * mainly good for eliminating cold starts and is pricey for what it is

Slide 122

Slide 122 text

More resources • Serverless cost comparison • https://acloudguru.com/blog/engineering/serverless-showdown-aws- lambda-vs-azure-functions-vs-google-cloud-functions • Lots of links throughout the slide deck!

Slide 123

Slide 123 text

Thank you! schneids.net @schneidenbach [email protected]