Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Planet Scale Applications with Cosmos DB and Pulumi

Planet Scale Applications with Cosmos DB and Pulumi

An example of how Pulumi and Infrastructure as code help create globally-distributed applications in Azure

Mikhail Shilkov

September 11, 2019
Tweet

More Decks by Mikhail Shilkov

Other Decks in Programming

Transcript

  1. 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
  2. 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.
  3. 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
  4. 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…
  5. 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).
  6. 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).
  7. 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).
  8. 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
  9. 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.
  10. 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.
  11. 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.
  12. 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
  13. 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
  14. 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.
  15. 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.
  16. • 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