Dapr Placement control plane service overview

Overview of the Dapr Placement service

The Dapr Placement service is used to calculate and distribute distributed hash tables for the location of Dapr actors running in self-hosted mode or on Kubernetes. Grouped by namespace, the hash tables map actor types to pods or processes so a Dapr application can communicate with the actor. Anytime a Dapr application activates a Dapr actor, the Placement service updates the hash tables with the latest actor location.

Self-hosted mode

The Placement service Docker container is started automatically as part of dapr init. It can also be run manually as a process if you are running in slim-init mode.

Kubernetes mode

The Placement service is deployed as part of dapr init -k, or via the Dapr Helm charts. For more information on running Dapr on Kubernetes, visit the Kubernetes hosting page.

Placement tables

There is an HTTP API /placement/state for Placement service that exposes placement table information. The API is exposed on the sidecar on the same port as the healthz. This is an unauthenticated endpoint, and is disabled by default. You need to set DAPR_PLACEMENT_METADATA_ENABLED environment or metadata-enabled command line args to true to enable it. If you are using helm you just need to set dapr_placement.metadataEnabled to true.

Important

When deploying actors into different namespaces (https://docs.dapr.io/developing-applications/building-blocks/actors/namespaced-actors/)), it is recommended to disable the metadata-enabled if you want to prevent retrieving actors from all namespaces. The metadata endpoint is scoped to all namespaces.

Usecase:

The placement table API can be used to retrieve the current placement table, which contains all the actors registered across all namespaces. This is helpful for debugging and allowing tools to extract and present information about actors.

HTTP Request

  1. GET http://localhost:<healthzPort>/placement/state

HTTP Response Codes

CodeDescription
200Placement tables information returned
500Placement could not return the placement tables information

HTTP Response Body

Placement tables API Response Object

NameTypeDescription
tableVersionintThe placement table version
hostListActor Host Info[]A json array of registered actors host info.

Actor Host Info

NameTypeDescription
namestringThe host:port address of the actor.
appIdstringapp id.
actorTypesjson string arrayList of actor types it hosts.
updatedAttimestampTimestamp of the actor registered/updated.

Examples

  1. curl localhost:8080/placement/state
  1. {
  2. "hostList": [{
  3. "name": "198.18.0.1:49347",
  4. "namespace": "ns1",
  5. "appId": "actor1",
  6. "actorTypes": ["testActorType1", "testActorType3"],
  7. "updatedAt": 1690274322325260000
  8. },
  9. {
  10. "name": "198.18.0.2:49347",
  11. "namespace": "ns2",
  12. "appId": "actor2",
  13. "actorTypes": ["testActorType2"],
  14. "updatedAt": 1690274322325260000
  15. },
  16. {
  17. "name": "198.18.0.3:49347",
  18. "namespace": "ns2",
  19. "appId": "actor2",
  20. "actorTypes": ["testActorType2"],
  21. "updatedAt": 1690274322325260000
  22. }
  23. ],
  24. "tableVersion": 1
  25. }

Learn more about the Placement API.

Last modified October 11, 2024: Fixed typo (#4389) (fe17926)