Skip to content

Dapr service mesh

  • Service discovery without hard-coded URLs.
  • State management with swappable stores (Redis, PostgreSQL, MongoDB, …).
  • Pub/sub for asynchronous communication.
  • Resiliency — retries, circuit breakers, timeouts — configured, not coded.
  • Observability built in.

Internal REST calls between microservices may use Dapr endpoints (service invocation), instead of direct service URLs. That keeps networking, retries and tracing in one place.

# Instead of calling http://other-service:8080/api
# call the Dapr sidecar:
curl http://localhost:3500/v1.0/invoke/other-service/method/api

A service reads and writes state through Dapr’s state API. The backing store is selected by a component YAML, so the same code runs against Redis locally and PostgreSQL in production.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379

Asynchronous events flow through Dapr pub/sub components. Publishers and subscribers are decoupled: a service publishes to a topic, another subscribes. The broker (Redis, Kafka, …) is configured, not coded.

Retry policies, circuit breakers and timeouts are declared in resiliency specs rather than sprinkled through service code. That keeps failure handling consistent and auditable.

apiVersion: dapr.io/v1alpha1
kind: Resiliency
metadata:
name: default
spec:
policies:
retries:
default:
policy: constant
maxRetries: 3
duration: 2s
circuitBreakers:
default:
maxRequests: 1
interval: 10s
timeout: 30s
trip: consecutiveFailures >= 5
targets:
apps:
"*":
retry: default
circuitBreaker: default

Dapr runs as a sidecar alongside the microservice. Each microservice ships its own Dapr component files so dapr run works from the service directory with no cluster.