Dapr service mesh
Why Dapr
Section titled “Why Dapr”- 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 service calls
Section titled “Internal service calls”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/apiState management
Section titled “State management”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/v1alpha1kind: Componentmetadata: name: statestorespec: type: state.redis version: v1 metadata: - name: redisHost value: localhost:6379Pub/sub
Section titled “Pub/sub”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.
Resiliency
Section titled “Resiliency”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/v1alpha1kind: Resiliencymetadata: name: defaultspec: 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: defaultLocal development
Section titled “Local development”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.
Further readings
Section titled “Further readings”- Microservices for in-service structure.
- Kubernetes and Helm for the runtime layer.
- Dapr documentation
