Slide 1

Slide 1 text

Azure Cosmos DB and Pulumi How to Build Planet Scale Applications in Minutes

Slide 2

Slide 2 text

Application v1 2 in a single geographic location (Azure region)

Slide 3

Slide 3 text

Deployed to a single location derived from the resource group Azure Cosmos DB in Pulumi 101 3

Slide 4

Slide 4 text

Deployed to a single location derived from the resource group Azure Cosmos DB in Pulumi 101 4

Slide 5

Slide 5 text

The Function code can be defined inline inside the Pulumi program. Pulumi serializes it and produces the deployment artifact. Deployed to the single location next to the Cosmos DB account Azure Functions in Pulumi 101 5

Slide 6

Slide 6 text

The Function code can be defined inline inside the Pulumi program. Pulumi serializes it and produces the deployment artifact. Deployed to the single location next to the Cosmos DB account Azure Functions in Pulumi 101 6 Cosmos DB connection parameters are passed implicitly as the variables. Alternatively, we could set them as application settings.

Slide 7

Slide 7 text

Pulumi Up result 7

Slide 8

Slide 8 text

Global Users 8

Slide 9

Slide 9 text

Latency 9 San Francisco 133 ms Frankfurt 393 ms Hong-Kong 437 ms End-to-end response time of the application Even though the database response time is < 10ms

Slide 10

Slide 10 text

Distributed Application Around the Globe

Slide 11

Slide 11 text

Deployed to multiple configurable locations Distributed Cosmos DB 11

Slide 12

Slide 12 text

Deployed to multiple configurable locations Distributed Cosmos DB 12

Slide 13

Slide 13 text

Has Latency Improved? 13 San Francisco 128 ms Frankfurt 382 ms Hong-Kong 451 ms End-to-end response time of the application Not really…

Slide 14

Slide 14 text

Global Users 14

Slide 15

Slide 15 text

Distributed Application v1 15 in multiple geographic locations (Azure regions)

Slide 16

Slide 16 text

Deployed to multiple configurable locations Distributed Code 16

Slide 17

Slide 17 text

Profile configuration defines the routing method and DNS settings. Global DNS-based routing service Traffic Manager 17 An endpoint is created to target each region. Endpoints are connected to the targets (Azure Function Apps in this case).

Slide 18

Slide 18 text

Profile configuration defines the routing method and DNS settings. Global DNS-based routing service Traffic Manager 18 An endpoint is created to target each region. Endpoints are connected to the targets (Azure Function Apps in this case).

Slide 19

Slide 19 text

Profile configuration defines the routing method and DNS settings. Global DNS-based routing service Traffic Manager 19 An endpoint is created to target each region. Endpoints are connected to the targets (Azure Function Apps in this case).

Slide 20

Slide 20 text

Latency Improved! 20 San Francisco 133 ms Frankfurt 128 ms Hong-Kong 149 ms End-to-end response time of the application The user connects to the closest HTTP endpoint which pulls data from the local replica

Slide 21

Slide 21 text

Pattern Can we make it reusable?

Slide 22

Slide 22 text

Shopping Cart Service v1 22 Docker + Azure Container Instances

Slide 23

Slide 23 text

Pricing Engine Service v1 23 Virtual Machines

Slide 24

Slide 24 text

Pattern v1 24 An abstraction that fits multiple use cases

Slide 25

Slide 25 text

A reusable GlobalApp component creates the common infrastructure including a global Cosmos DB account, Traffic Manager, etc. A custom Pulumi component Global App 25 A factory function creates the infrastructure for a specific use case: both global and regional resources.

Slide 26

Slide 26 text

A reusable GlobalApp component creates the common infrastructure including a global Cosmos DB account, Traffic Manager, etc. A custom Pulumi component Global App 26 A factory function creates the infrastructure for a specific use case: both global and regional resources.

Slide 27

Slide 27 text

A reusable GlobalApp component creates the common infrastructure including a global Cosmos DB account, Traffic Manager, etc. A custom Pulumi component Global App 27 A factory function creates the infrastructure for a specific use case: both global and regional resources.

Slide 28

Slide 28 text

Global Function App 28

Slide 29

Slide 29 text

Azure Container Registry and a Docker Image are defined in the global scope. Global Container Instances App 29 A factory function creates an Azure Container Instances Group per region

Slide 30

Slide 30 text

Azure Container Registry and a Docker Image are defined in the global scope. Global Container Instances App 30 A factory function creates an Azure Container Instances Group per region

Slide 31

Slide 31 text

The infrastructure setup may be quite involved… Global VM Scale Sets App 31 And yet, the Global App component brings structure, simplifies the implementation, and helps avoid mistakes.

Slide 32

Slide 32 text

Evolve over Time Benefits of the abstraction

Slide 33

Slide 33 text

Example #1 v1 33 Multi-master support

Slide 34

Slide 34 text

Example #2 v1 34 Replace Azure Traffic Manager with Azure Front Door

Slide 35

Slide 35 text

Wrapping Up Final Thoughts

Slide 36

Slide 36 text

Cosmos DB and Pulumi 36 Azure Cosmos DB https://azure.microsoft.com/services/cosmos-db/ Pulumi https://www.pulumi.com/ Globally Distributed close to the users Azure Cosmos DB takes care of distributing the data and low-latency access. Pulumi simplifies the deployment of the compute infrastructure to match the best practices and the target tech stack. Infrastructure as Code Typescript / Python / Go Use the power of programming languages: general-purpose functions, conditions, loops, collection manipulation, compile-time errors, automated testing, refactoring, static analysis, linting. The tools you know and love. Abstractions reusable components Codify the best practices and distribute the implementation among the teams. Both components and applications can evolve over time.

Slide 37

Slide 37 text

● Globally-distributed Serverless Application in 100 Lines of Code. Infrastructure Included! https://www.pulumi.com/blog/globally-distributed-serverless-application-in-100-lines-of-code- infrastructure-included/ ● Global App component example https://github.com/mikhailshilkov/pulumi-cosmos/ ● Getting Started with Pulumi and Azure https://www.pulumi.com/azure/ Useful Links 37