docs/use-cases/README.md

6.7 KiB

Dapr use cases

This document briefly describes scenarios that Dapr enables for your microservices. Each use case is accompanied with a link to learn more details.

Service invocation

Dapr provides a uniform API that your microservice can use to find and reliably communicate with other microservices in your system. By using this API, your code can seamlessly take advantage of several built-in features:

  • HTTP and gRPC support
  • Intelligent error handling
  • Distributed tracing

Visit the following documents to learn more:

State management

Dapr provides an abstraction API that abstracts over many different databases. Your microservice can leverage these APIs to utilize any supported database without finding or adding a third party SDK to your codebase. The Dapr state management system also gives your app some features for free that are otherwise complicated and error-prone to build yourself:

  • Distributed concurrency and data consistency
  • Retry policies
  • Bulk CRUD operations

Visit the following documents to learn more:

Pub/Sub

Dapr provides an API that enables event-driven architectures in your system. Each microservice can utilize the same API to leverage one of many supported event buses. Microservices can communicate each other by sending or subscribing to events on specific topics. By leveraging this communication style, your microservices remain flexible and loosely coupled.

Visit the following documents to learn more:

Bindings

Similar to pub/sub, Dapr provides a mechanism that can trigger your app in response to an event. Dapr provides bindings to enable your app to respond to events that come from external (outside your system) sources, while pub/sub events come from internal sources.

For example, your microservice can respond to incoming Twilio/SMS messages using bindings. Your app can focus on the business logic to responds to the incoming SMS event rather than adding and configuring a third party Twilio SDK.

Similarly, your application can send messages to external destinations using the bindings feature. In the Twilio example, your application would send an SMS, again without adding or configuring a third party Twilio SDK.

Visit the following documents to learn more:

Actors

Dapr provides an API and runtime that allows you to write your business logic as an isolated unit, without worrying about concurrency or other actors. Dapr calls this single isolated unit an "actor". Your running actors can send a message to another actor or can request to create a new actor. In the former case, Dapr manages routing the message to the proper destination. In the latter case, Dapr manages all the state management, synchronization, and concurrency involved with starting the new actor.

The actor model is a battle-tested programming pattern and as such, comes with very specific use cases:

  • You have a large system composed of many (thousands or more) small microservices, in which the code to manage these microservices (e.g. distribution across nodes, failover, ...) is very complex
  • Your microservice(s) do not need concurrent access to state and can instead can share state by communicating
  • Your code does operations that have unpredictable latency, such as I/O operations to external web services

Visit the following documents to learn more:

Mutual TLS

Dapr enables code-free end-to-end encryption in communication between microservices, called mutual TLS (mTLS). In short, mTLS is a commonly-used security mechanism that provides the following features:

  • Two way authentication - the client proving its identify to the server, and vice-versa
  • An encrypted channel for all in-flight communication, after two-way authentication is established

Mutual TLS is useful in almost all scenarios, but especially so for systems subject to regulations such as HIPAA and PCI.

Visit the following documents to learn more:

Secrets storage

Dapr provides a consistent, secure API for accessing sensitive data, such as private keys for cloud services or database passwords, that your business logic needs. Using secret stores, you can remove secrets from your source code repositories and replace them with references to secrets in a Dapr secret store. Not only is doing so more secure, it also enables best security practices such as key rotation.

Visit the following documents to learn more: