DAPR Distributed Application Runtime

Seenivasa Ramadurai - Aug 28 - - Dev Community

DAPR is open source project funded by Microsoft and its written in GOlang. Dapr is portable , Event driven it helps easy to build cloud native applications with Resiliency , Stateless and Stateful that run on any cloud and edge environments. Dapr supports all major programming languages C# , JAVA , NODE , GO , PYTHON , PHP etc.. DAPR helps you to tackle the challenges that come with building Microservices.

DAPR Architecture

Dapr runtime deployed as Sidecar app when we deploying our apps into K8s . Dapr supports both HTTP and gRPC APIs that can be called from you code . DPAR runs and listens on HTTP port 3500 (default). Before we go further deep into DAPR let me explain what is Sidecar?
Sidecar is a architectural pattern , in a single Kubernetes (K8s) POD we deploy two containers One is the main applications second one is Sidecar which runs along with main application. The lifetime of the Sidecar is same as Application when application dies sidecar also dies. Sidecar pattern mostly used for cross cutting concerns like Logging , Authentication, Auditing , mTLS, SSL termination basically offloading few tasks from main application. for example if we take ISTIO , LINKERD , Open Service Mesh all service mesh runs as SIDECAR in Kubernetes cluster. DAPR and Service mesh do offer some overlapping capabilities , however DAPR is not a Service Mesh later i will describe the difference between DAPR vs Service Mesh.

Image description

Microservices
Microservices are small independently developed , deployable services or applications. Microservices built based on SOLID principle first Letter S - Single Responsibility and has it own data storage. Microservices communicates with other services using lightweight protocols often over messaging or HTTP, gRPC. When comes to deployment 100% of services deployed as Kubernetes workload as POD. POD is nothing but unit of deployment in K8s world, POD has both Docker runtime (mostly) and application.
Microservices also comes with few challenges too. When we deploying many services there is need to handle things like
Service Discovery .
Secure communication between service to service (mTLS).
Distributed tracing.
Transient failures, and Integrating with 3rd API's.
Message Q etc.
DAPR offers and solves for us the above mentioned challenges out of the box. I am sure now you wanted to learn DPAR and adopt in your Microservices project development, so let us do it.

DAPR Build Blocks

When we developing Microservices there are many architecture we can consider like Hexagonal , DDD - Domain Driven Design (Bounded context ), EDA- Event Driven Architecture etc.., However Dapr provides best practices for capabilities when building Microservices. And Dapr comes with many building blocks which exposes HTTP and gRPC based APIs for developer to consume and plug into their applications.

Image description

Image description

If we use DAPR we can abstract that from our Microservices code and handover all the Data store operations to DAPR State store management building blocks . suppose later on we decided to use AWS DynamoDB , or Azure Cosmos DB without single line of code change we can switch over different state store using just placing different configuration of DAPR building block components.
How to Install DAPR in our Local environment
DAPR can be installed in two modes 1. Self hosted -mode or local in our development computer 2. Kubernetes mode. When we install in our local environment we need to have either docker runtime or podman should be installed. Because DAPR uses local docker runtime to place the DPAR sidecar.

Here is the command to install in self hosted mode
$ dapr init – To install in local [Self-mode]
when we install DAPR in self hosted mode the following Docker containers are get installed . We can verify using docker command $docker ps. FYI, I am using Docker desktop when you install docker desktop it installs Docker runtime and Kubernetes (developer version).

Image description

At the time of DAPR installation DAPR also create the folder called Components and place the following file in Userprofile directory . In Mac we can find it under /Users/ **

Image description

DPAR installing on Kubernetes (K8s)

When we install the DAPR in Kubernetes world we use the following command $ dapr init –k. This command can be executed from local environment once we set the context of K8S cluster using Kubectl command

Here is the list of Kubectl commands to set the Kubernetes cluster context

Image description

DAPR Components Specs : Just changing the components configuration we can easily fallback to any components without single line of code change.

Image description

DPAR Framework supports the following languages

Image description

Thanks
Sreeni Ramadurai

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player