BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Dapr Aims to Simplify the Creation of Resilient and Portable Microservices

Dapr Aims to Simplify the Creation of Resilient and Portable Microservices

Leia em Português

Microsoft Dapr is an open-source, event-driven framework aimed to build resilient and portable microservices for Cloud and Edge applications. Dapr encapsulates the best practices for building microservices, Microsoft says, and allows developers to focus on the business logic of their application.

Dapr provides an event-driven runtime that supports the fundamental features you need to build microservices, such as service invocation, state management, and publish/subscribe messaging. Additionally, it introduces a number of more advanced features.

Virtual actors aim to simplify the management of asynchronous computation by encapsulating state and behaviour within individual objects that can be activated and deactivated, and support the use of timers to trigger code execution. Actors can also be stateless. Actors in Dapr are virtual, which means their in-memory representation is not tied to the actor identity and lifetime. In particular, an actor can be automatically collected when not used for a period of time and created when it is first requested. Actors can also migrate to a different node, for example when the node they are running on fails. To make concurrency handling easier, actors are single-threaded and subject to a turn-based access policy. Additionally, the Dapr runtime will use timeouts to detect and resolve possible deadlocks.

Dapr also offer an advanced event-driven model where external services such as databases, queues, and webhooks may be registered as source of events that will trigger code execution, or as event consumers. This is accomplished through bindings that simplify the interaction with those services, handle retry and failures, and enable porting an application from a service to another without code changes. At the moment of writing, existing bindings are still experimental.

Finally, Dapr also supports distributed tracing across services, either internal or external. Tracing does not require instrumenting the application code, since Dapr uses a HTTP/gRPC middleware that intercepts all Dapr and application traffic and automatically injects correlation IDs to trace distributed transactions. Dapr is compatible with OpenTelemetry, which enables the use of a number of backends including Azure Monitor, Datadog, Instana, Jaeger, SignalFX, Stackdriver, Zipkin and others.

Dapr architecture follows the sidecar pattern, meaning its components can be deployed either as independent processes or as containers to provide isolation and encapsulation and do not require to include a runtime in the application code. This makes it easy to integrate Dapr with other runtimes and to use it in a Kubernetes environment.

Dapr provides SDKs for a number of languages, including Go, Java, JavaScript, Python, and of course .NET. Language-specific SDKs expose Dapr API in an idiomatic way and hide the complexity of using its HTTP/gRPC API.

You can install Dapr using the install scripts available for the major OSes. For Linux, you would run the commands:

$ wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
$ dapr init

You can then run Dapr locally by executing dapr run or configure a Kubernetes cluster to exploit its auto-scaling capabilities. If you plan to use Dapr with Kubernetes, make sure you also check out the recently announced Microsoft Open Application Model (OAM) for Kubernetes and its initial implementation, Rudr. The OAM and Rudr aim to help developers define their applications clearly decoupled from the implementation and preserve separation of concerns between development and deployment.

Rate this Article

Adoption
Style

BT