Serverless in Action TechBash November 14, 2019 Who is Chad Green - - PowerPoint PPT Presentation

serverless in action
SMART_READER_LITE
LIVE PREVIEW

Serverless in Action TechBash November 14, 2019 Who is Chad Green - - PowerPoint PPT Presentation

Chad Green Serverless in Action TechBash November 14, 2019 Who is Chad Green Director of Software Development at ScholarRx chadgreen@chadgreen.com chadgreen.com ChadGreen ChadwickEGreen Agenda What is Serverless


slide-1
SLIDE 1

Serverless in Action

TechBash November 14, 2019

Chad Green

slide-2
SLIDE 2
  • Who is Chad Green

Director of Software Development at ScholarRx

chadgreen@chadgreen.com  chadgreen.com ChadGreen ChadwickEGreen

slide-3
SLIDE 3

Serverless in Action

Agenda

3

  • What is Serverless Computing
  • Functions as a Service
  • Serverless Options
  • Azure Functions Overview
  • Azure Functions in Action
  • Pricing
  • Best Practices

@ChadGreen

slide-4
SLIDE 4

What is Serverless Computing

Serverless in Action

slide-5
SLIDE 5

Serverless in Action @ChadGreen

The evolution of application platforms

5

Which packages should be on my server? How do I deploy new code to my servers? How can I increase server utilization? How often should I patch my servers? What size of servers should I buy? Who has physical access to my servers? It takes how long to provision a new server?



On-Premises

@ChadGreen

slide-6
SLIDE 6

Serverless in Action @ChadGreen

The evolution of application platforms

6

What is the right size of servers for my business needs? How can I increase server utilization? How many servers do I need? How can I scale my application? How do I deploy new code to my server? Which Operating System should I use? Who monitors my application? How often should I patch my servers? How often should I backup my server? Which packages should be on my server?





IaaS

On-Premises

slide-7
SLIDE 7

Serverless in Action @ChadGreen

The evolution of application platforms

7

What is the right size of servers for my business needs? How can I increase server utilization? How many servers do I need? How can I scale my application?





PaaS

IaaS On-Premises

slide-8
SLIDE 8

Serverless in Action @ChadGreen

The evolution of application platforms

8

The platform for next generation applications                       

PaaS IaaS On-Premises

Serverless

slide-9
SLIDE 9

Serverless in Action @ChadGreen

What is Serverless?

9

Abstraction of Servers Event-Driven/Instant Scale Micro-Billing

slide-10
SLIDE 10

Serverless in Action @ChadGreen

Benefits of Serverless

10

Reduced DevOps Faster Time to Market Manage apps not servers

slide-11
SLIDE 11

Serverless in Action @ChadGreen

Challenges of Serverless Architecture

11

Complexity Organizational Support No Runtime Optimization

slide-12
SLIDE 12

Function as a Service

Serverless in Action

slide-13
SLIDE 13

Serverless in Action @ChadGreen

Serverless is more than just one thing

13

  • Applications that significantly or fully

depend on services (in the cloud) to manage server-side logic and state

Backend as a Service (BaaS) Functions as a Services (FaaS)

  • Application run in stateless compute

containers that are event-triggered, ephemeral, and fully managed by a 3rd party

slide-14
SLIDE 14

Serverless in Action @ChadGreen

Function Scale

14

Monolith

Microservice Microservice Microservice Microservice Function Function Function Function Function Function Function Function Function Function Function

Nano Services

slide-15
SLIDE 15

Serverless in Action

FaaS is at the center of serverless

15

Single responsibility

Functions are single-purposed, reusable pieces of code that process an input and return a result

Short lived

Functions don’t stick around when finished executing, freeing up resources for further executions

Event driven & scalable

Functions respond to predefined events, and are instantly replicated as many times as needed

Stateless

Functions don’t hold any persistent state and don’t rely on the state of any other processes

Functions-as-a-Service programming model use functions to achieve true serverless compute

@ChadGreen

slide-16
SLIDE 16

Serverless Options

Serverless in Action

slide-17
SLIDE 17

Serverless in Action @ChadGreen

Market Landscape

17

AWS Lambda

Run code without thinking about servers. Pay only for the compute time you consume.

slide-18
SLIDE 18

Serverless in Action @ChadGreen

Market Landscape

18

AWS Lambda Google Cloud Functions

Event-driven serverless compute platform

slide-19
SLIDE 19

Serverless in Action @ChadGreen

Market Landscape

19

AWS Lambda Google Cloud Functions IBM Cloud Functions

Execute code on demand in a highly scalable serverless environment

slide-20
SLIDE 20

Serverless in Action @ChadGreen

Market Landscape

20

AWS Lambda Google Cloud Functions IBM Cloud Functions Auth0 WebTask

All you need is code

slide-21
SLIDE 21

Serverless in Action @ChadGreen

Market Landscape

21

AWS Lambda Google Cloud Functions IBM Cloud Functions Auth0 WebTask Azure

Your vision. Your cloud.

slide-22
SLIDE 22

Serverless in Action @ChadGreen

Azure Serverless Offerings

22

Event Grid

Manage all events that can trigger code or logic

Logic Apps

Design workflows and

  • rchestrate processes

Functions

Execute your code based

  • n events you specify

Storage Security IoT Analytics Intelligence Database

slide-23
SLIDE 23

Azure Functions

Serverless in Action

Events + data Code

slide-24
SLIDE 24

Serverless in Action @ChadGreen

Features of Azure Functions

24

  • Choice of language

Batch

slide-25
SLIDE 25

Serverless in Action @ChadGreen

Features of Azure Functions

25

  • Choice of language
  • Pay-per-use pricing model

25

Batch

slide-26
SLIDE 26

Serverless in Action @ChadGreen

Features of Azure Functions

26

  • Choice of language
  • Pay-per-use pricing model
  • Bring your own dependencies
slide-27
SLIDE 27

Serverless in Action @ChadGreen

Features of Azure Functions

27

  • Choice of language
  • Pay-per-use pricing model
  • Bring your own dependencies
  • Integrated security
slide-28
SLIDE 28

Serverless in Action @ChadGreen

Features of Azure Functions

28

  • Choice of language
  • Pay-per-use pricing model
  • Bring your own dependencies
  • Integrated security
  • Simplified integration
slide-29
SLIDE 29

Serverless in Action @ChadGreen

Features of Azure Functions

29

  • Choice of language
  • Pay-per-use pricing model
  • Bring your own dependencies
  • Integrated security
  • Simplified integration
  • Flexible development
slide-30
SLIDE 30

Serverless in Action @ChadGreen

Features of Azure Functions

30

  • Choice of language
  • Pay-per-use pricing model
  • Bring your own dependencies
  • Integrated security
  • Simplified integration
  • Flexible development
  • Open-source
slide-31
SLIDE 31

Serverless in Action

Triggers and Bindings

31

Type

Blob Storage Cosmos DB Event Grid Event Hubs HTTP & Webhooks Microsoft Graph OneDrive files Microsoft Graph Outlook email Microsoft Graph Auth tokens Mobile Apps Notification Hubs Queue Storage SendGrid Service Bus SignalR Table Storage Timer Twilio

1.x

Microsoft Graph Excel tables

  • 2.x
  • Trigger
  • Microsoft Graph

events

  • Input
  • Output
  • @ChadGreen

IoT Hub

slide-32
SLIDE 32

Serverless in Action @ChadGreen

Develop How You Want

32

  • Azure Portal
  • Quickly get started without having to install anything

else

  • Visual Studio 2017
  • First class C# development experience
  • Visual Studio Code
  • First class Node.js development experience
  • Edit any function project generated via CLI
  • Azure Functions Core Tools (CLI)
  • Build any kind of function and edit in IDE of your

choice

slide-33
SLIDE 33

Serverless in Action @ChadGreen

Runtime Versions

33

  • .NET Framework 4.6

Runtime 1.x Runtime 2.x

  • .NET Core 2.0
  • Cross Platform
  • Language Extensions
  • Java
  • Binding Extensions
  • Microsoft Graph
  • Durable Functions

Runtime 3.x

  • .NET Core 3.0
slide-34
SLIDE 34

Serverless in Action @ChadGreen

Runtime Version Languages

34

Language C# JavaScript F# Java Python TypeScript PHP Batch (.cmd, .bat) Bash PowerShell 1.x GA (.NET Framework 4.7) GA (Node 6) GA(.NET Framework 4.7) N/A Experimental Experimental Experimental Experimental Experimental Experimental 2.x GA (.NET Core 2.2) GA (Node 8 & 10) GA (.NET Core 2.2) Preview (Java 8) Preview (Python 3.6.x) GA (Supported through transpiling to JavaScript) N/A N/A N/A Preview (PowerShell Core 6)

slide-35
SLIDE 35

Serverless in Action

Consumption Plan

35

  • Pay for what you use without the need to reserve compute

resources.

  • Function Apps are assigned to compute processing instances

that are scaled dynamically by the platform.

  • Functions can have multiple parallel executions minimizing the

total time needed to process requests.

  • Cost is driven by the number of executions and by accounting

for memory size used and total execution time across all functions in a Function App as measured in gigabyte-seconds. Selection guidance

  • Good option if your functions run at elastic scale with

potentially intermittent executions.

@ChadGreen

slide-36
SLIDE 36

Serverless in Action

App Service Plan

36

  • Function Apps run on dedicated VMs, just like Web Apps work

today

  • Dedicated VMs are allocated to your apps and they are always

available whether code is being actively executed or not. Selection guidance

  • Good option if you have existing, under-utilized VMs that are

already running other code

  • Good option if you expect to run functions continuously or

almost continuously

@ChadGreen

slide-37
SLIDE 37

Serverless in Action

Premium Plan

37

@ChadGreen

slide-38
SLIDE 38

Serverless in Action

Ways to Run Functions

38

App Service Plan

Free, Basic, Standard, Premium

All the advantages of Functions with the SLA and ‘always

  • n’ feature of an

App Service Plan

Consumption

Serverless

Pay only for what you use! Metering is per execution and per Gb second.

App Service Environment

Network Isolation

Your own dedicated cloud environment with network isolation for apps, higher scale, and the ability to connect securely to local vNets.

Azure Stack

On Premises

Leverage cloud innovations in on- premises infrastructure. Azure Stack brings the power

  • f Azure to your

data centers.

Azure Functions Runtime

Functions on your Server

Run your Azure Functions on our local server (without the rest

  • f Azure)

Azure IoT Edge

On Devices

Run on IoT Devices by deploying custom modules.

@ChadGreen

slide-39
SLIDE 39

Pricing

Serverless in Action

slide-40
SLIDE 40

Serverless in Action @ChadGreen

Pricing – General Information

40

  • No upfront cost
  • No termination fees
  • Pay only for what you use
slide-41
SLIDE 41

Serverless in Action @ChadGreen

Consumption Plan Pricing

41

  • Gigabyte-second (GB-s) – Combination of memory size and execution time
  • Executions – Each time a function is executed

Meter Price Free Grant Execution Time $0.000016 per Gb-s 400,000 GB-s Executions $0.20 per million executions 1 million executions

Pricing Example

  • Execution Time
  • 3 million executions x 1 second per execution = 3 million seconds
  • Resource consumption of 512-Mb  1.5 million GB-s
  • 1.5 million GB-s minus grant of 400,000 Gb-s = 1.1 million Gb-s
  • Execution Total = $17.60
  • Executions
  • 3 million executions minus grant of 1 million executions = 2 million executions
  • 2 million transactions at 20 cents per million = $0.40
  • Grand Total: $18.00
slide-42
SLIDE 42

Azure Functions in Action

Serverless in Action

slide-43
SLIDE 43

Demo: Create an Azure Function from the Portal

slide-44
SLIDE 44

Demo: Create an Azure Function from Visual Studio

slide-45
SLIDE 45
slide-46
SLIDE 46
slide-47
SLIDE 47

Demo: Monitoring a Rapidly Scaling Function

slide-48
SLIDE 48

Serverless in Action @ChadGreen

Most Powerful Sith Lord

48

slide-49
SLIDE 49

Serverless in Action @ChadGreen

Most Powerful Sith Lord

49

slide-50
SLIDE 50

Serverless in Action @ChadGreen

Most Powerful Sith Lord

50

Vote VoteMonitor

slide-51
SLIDE 51

Best Practices

Serverless in Action

slide-52
SLIDE 52

Serverless in Action @ChadGreen

Function Timeouts

52

  • Default timeout of 5 minutes
  • Maximum timeout of 10 minutes
  • For longer running functions use the App Service

Plan and/or Durable Functions

slide-53
SLIDE 53

Serverless in Action @ChadGreen

The absolute minimum best practices

53

  • Functions should do one thing
  • Functions should be idempotent
  • Functions should finish as quickly as possible
slide-54
SLIDE 54

Serverless in Action @ChadGreen

General Best Practices

54

  • Avoid long running functions
slide-55
SLIDE 55

Serverless in Action @ChadGreen

General Best Practices

55

  • Avoid long running functions
  • Cross function communication
slide-56
SLIDE 56

Serverless in Action @ChadGreen

General Best Practices

56

  • Avoid long running functions
  • Cross function communication
  • Write functions to be stateless
slide-57
SLIDE 57

Serverless in Action @ChadGreen

General Best Practices

57

  • Avoid long running functions
  • Cross function communication
  • Write functions to be stateless
  • Write defensive functions
slide-58
SLIDE 58

Serverless in Action

Testing Your Functions

58

  • Recommended Way
  • Abstract logic away from the Function and test that abstraction
  • But I really need (want) to test the actual Function
  • Within test project, you will need to create a class that implements the

ILogger which will be passed into the Functions

@ChadGreen

slide-59
SLIDE 59

Serverless in Action @ChadGreen

Scalability Best Practices

59

  • Do not mix test and production code in the same

function app

slide-60
SLIDE 60

Serverless in Action @ChadGreen

Scalability Best Practices

60

  • Do not mix test and production code in the same

function app

  • Use async code but avoid blocking calls
slide-61
SLIDE 61

Serverless in Action @ChadGreen

Scalability Best Practices

61

  • Do not mix test and production code in the same

function app

  • Use async code but avoid blocking calls
  • Receive messages in batch whenever possible
slide-62
SLIDE 62

Serverless in Action @ChadGreen

Scalability Best Practices

62

  • Do not mix test and production code in the same

function app

  • Use async code but avoid blocking calls
  • Receive messages in batch whenever possible
  • Configure host behaviors to better handle

concurrency

slide-63
SLIDE 63

Serverless in Action @ChadGreen

How to get started

63

  • Start small, replace 1 API or background processing

item

  • Integration is a great place, often it’s a new layer on

top of old layers

slide-64
SLIDE 64
  • Questions

chadgreen@chadgreen.com  chadgreen.com ChadGreen ChadwickEGreen