Microsoft’s Distributed Application Runtime (Dapr) has now graduated to the production-ready version, 16 months after it was released as an alpha project.
Dapr is an open-source, Microsoft-incubated project for developers to build event-driven and distributed cloud-native applications.
Why Dapr
Dapr was launched in October 2019 and has released 14 major updates since. It can integrate with all major cloud providers such as Azure, AWS, and Google Cloud.
Credit: Dapr
The last few years have witnessed a steady increase in the number of organisations moving from on-premises to cloud and microservices-based software architectures. Applications built on function-based components which are smaller and connect through APIs are easier to develop and maintain. In such cases, a single developer takes responsibility for one service, also called microservice.
This is where platforms like Dapr come into play. Dapr acts as a self-hosted environment on a local machine. It is a portable and event-driven runtime environment that helps developers build microservices-based applications on the cloud.
Building Block
Dapr consists of a set of building blocks accessible by standard HTTP or gRPC APIs, which can be called using any programming language. “These building blocks empower all developers with proven, industry best practices, and each building block is independent; you can use one, some, or all of them in your applications,” as per a Microsoft blog post.
Dapr contains language-specific SDKs for Go, Java, .NET, Python, Javascript and enables developers to write both stateful and stateless functions in their chosen language. Since the SDKs share the Dapr runtime, developers can also get a cross-language actor and function support.
Dapr allows developers to build applications for both cloud and edge, without any code changes. With Dapr, applications can be run locally — on Kubernetes or any other hosting environment.
Dapr’s building blocks include:
Service-to-service invocation: It enables the communication between applications through endpoints in the form of HTTP or gRPC messages. These endpoints act as a combination of reverse proxy with built-in service discovery and leverage built-in distributed tracing and error handling.
State management: Dapr provides a key/value-based state API with pluggable state stores using which an application can preserve a state beyond a single session.
Publish and subscribe: A loosely coupled messaging service between senders and subscribers. Dapr supports the publishing and subscribing pattern between applications.
Resource binding: Binding facilitates a bi-directional connection to cloud or on-premise service. With Dapr, users can invoke the external service using binding API. It allows the application to be triggered by events sent by the cloud or on-premise service.
Actors: The actor is an independent entity of computing and state which has single-threaded execution. Based on the Virtual Actor pattern, Dapr provides actor implementation on a single-threaded programming model. Actors are collected as garbage when not in use.
Observability: Dapr system components monitor services, components, and user applications.
Secrets: Dapr offers a secrets building block API and integrates it with Azure Key Vault, Kubernetes and other secret stores. Secrets API can be called using the service code to retrieve these ‘secrets’ from the stores.
Wrapping Up
With v1.0, Microsoft is focused on Kubernetes for running production-ready applications. The scope of Dapr will further increase and diversify into virtual machines, platform-as-a-service (PaaS), and edge environments in the future.
Traditionally, a developer is expected to do client, server, and database-type applications, containerise them and create scalable microservices . Additionally, these apps are also expected to be portable across environments, adding an extra layer of complexity.
“The goal with Dapr was: let’s take care of all of the mundane work of writing one of these cloud-native distributed, highly available, scalable, secure cloud services, away from the developers so they can focus on their code,” Microsoft Azure CTO Mark Russinovich said in an interview.