🖥️

Introduction to Dapper at DapperCon 2021

Jul 10, 2024

Introduction to Dapper at DapperCon 2021

Overview

  • Presenter: Cecil Phillip, Senior Cloud Advocate at Microsoft
  • Event: DapperCon 2021
  • Topic: Introduction to Dapper for microservice development

Key Points

Introduction

  • Dapper simplifies microservice development.
  • Offers flexibility in solving infrastructure concerns.
  • Focus on getting started with Dapper.
  • Demonstrations on installing Dapper tools and CLI, dapperizing an application, and using Docker Compose and Visual Studio Code.

Challenges in Distributed Systems

  • Numerous options for tools: Service discovery, Key-value stores, Pub/Sub, Secrets Management, Configuration, Observability.
  • Complexity in choosing and integrating these tools.
  • Dapper provides a consistent and flexible runtime to simplify this process.

Benefits of Dapper

  • Portable, lightweight, event-driven runtime.
  • Focus on business value over infrastructure concerns.
  • Language-agnostic and open-source, with extensibility for community contributions.

Dapper Building Blocks

  • Service to Service Invocation: Service discovery, invocation APIs.
  • State Management: Manage state across services.
  • Pub/Sub: Publish and subscribe to events.
  • Triggers and Bindings: Reactive programming model.
  • Actors: Manage state and behavior of individual entities.
  • Observability: Metrics and tracing.
  • Secrets Management: Securely manage application secrets.
  • Exposed via HTTP and gRPC allowing broad compatibility.

Flexibility in Usage

  • Selective usage of building blocks based on application needs.
  • Useful for both modern microservices and legacy applications.

Getting Started with Dapper

Demo: Initial Setup

  • Example Application: Python and FastAPI web API.
  • Initial Setup: Command Line Execution and Requests.
  • Installing Dapper CLI: Using Homebrew on macOS.
  • Initialization: Command dapper init downloads and configures default components (e.g., Redis, Zipkin).

Dapperizing an Application

  • Command: dapper run --app-id api --app-port 8000 --dapper-http-port 3500 <app_command>.
  • Outcome: Automatic discovery of the app, enabling metrics, tracing, loading components.

Dapper Dashboard

  • Tool: Accessible on localhost:8080.
  • Features: View running Dapper applications, configured components, component details and configurations.

Understanding Dapper Architecture

  • Sidecar Model: Each app instance has an associated Dapper sidecar process.
  • Communication: Over gRPC or HTTP APIs between app and sidecar.
  • Service Invocation, State Management, Pub/Sub: Examples of HTTP requests to these endpoints.

Components and Configuration

  • Component Implementations: Variety of databases, message brokers, etc.
  • Open Source Contributions: Community can add new components.
  • Components Repository: GitHub - Dapper components-contrib.

Real World Application Example: Contoso Crafts

  • Application Composition: Web UI (ASP.NET Core Blazor), Products API, Checkout Service.
  • Docker Compose: Orchestrates services, databases (MongoDB), message brokers (RabbitMQ).

Configuration Examples

  • For Each Service: Separate Dapper sidecar configurations.

Example Code

  • Setting Up HTTP Client: For invoking services and storing state.
  • Service Invocation, State Management, Pub/Sub: Python code examples based on service methods.
  • Checkout Processor: Listening to pub/sub topics, handling messages using cloud events.

Configuration in YAML

  • Local Secrets Store: Example configuration for development purposes.
  • Component Configs: RabbitMQ, Redis for state storage; referencing secrets for sensitive information.

Debugging and Tracing

  • Debugging with VS Code: Attach to running containers for live debugging.
  • Tracing with Zipkin: View service dependencies, trace execution paths.

Closing Remarks

  • Learning Resources:
    • Website: dapper.io
    • Getting Started Guide.
    • Community Platforms: Discord, GitHub, YouTube.
    • Dapper for .NET eBook.
  • Encouragement to Explore Dapper: Access documentation, participate in community, contribute to open source.

Enjoy the rest of DapperCon 2021!