Dapr (Distributed Application Runtime) gives microservices superpowers — service discovery, pub/sub, state management, and secrets — through simple HTTP/gRPC APIs. No SDKs needed.
Why Dapr?
- Sidecar pattern: Runs alongside your app, any language
- Building blocks: State, pub/sub, service invocation, bindings
- Pluggable: Swap Redis for Postgres without code changes
- No SDK needed: Just HTTP calls
- Kubernetes-native: First-class K8s support
- Local development: Run without K8s
Install
# CLI
curl -fsSL https://raw.githubusercontent.com/dapr/cli/master/install/install.sh | bash
# Initialize (local Docker)
dapr init
Run Your App with Dapr
dapr run --app-id myapp --app-port 3000 -- node app.js
Dapr starts a sidecar on port 3500 next to your app.
State Management
# Save state
curl -X POST http://localhost:3500/v1.0/state/statestore \
-H 'Content-Type: application/json' \
-d '[{"key": "user:1", "value": {"name": "Alice", "email": "alice@example.com"}}]'
# Get state
curl http://localhost:3500/v1.0/state/statestore/user:1
# Delete state
curl -X DELETE http://localhost:3500/v1.0/state/statestore/user:1
Swap Redis for PostgreSQL by changing config — zero code changes.
Pub/Sub
# Publish event
curl -X POST http://localhost:3500/v1.0/publish/pubsub/orders \
-H 'Content-Type: application/json' \
-d '{"orderId": "123", "amount": 49.99}'
// Subscribe in your app
app.post('/orders', (req, res) => {
console.log('Order received:', req.body.data);
res.json({ status: 'SUCCESS' });
});
Service-to-Service Calls
# Call another service (Dapr handles discovery)
curl http://localhost:3500/v1.0/invoke/payment-service/method/charge \
-H 'Content-Type: application/json' \
-d '{"orderId": "123", "amount": 49.99}'
No service URLs, no load balancers — Dapr finds the service by name.
Secrets
curl http://localhost:3500/v1.0/secrets/my-secret-store/DB_PASSWORD
Works with Kubernetes secrets, HashiCorp Vault, AWS Secrets Manager, Azure Key Vault.
Input/Output Bindings
# Trigger on Kafka message (input binding)
# Your app receives POST /kafka-input with message data
# Send to external system (output binding)
curl -X POST http://localhost:3500/v1.0/bindings/email \
-d '{"operation": "create", "data": {"to": "user@example.com", "subject": "Hello"}}'
Real-World Use Case
A team had 8 microservices with custom service discovery, retry logic, and message queue code in each. After adding Dapr, they deleted 3,000 lines of infrastructure code. Each service just calls localhost:3500 — Dapr handles routing, retries, and message delivery.
Need to automate data collection? Check out my Apify actors for ready-made scrapers, or email spinov001@gmail.com for custom solutions.
Top comments (0)