ray.serve.config.DeploymentActorConfig#
- pydantic model ray.serve.config.DeploymentActorConfig[source]#
Configuration for a deployment-scoped actor.
Deployment-scoped actors are long-lived actors managed by the Serve controller that outlive any single replica but are cleaned up when the deployment is deleted or serve.shutdown() is called. They are shared by all replicas of a deployment.
The controller periodically health-checks each deployment-scoped actor (via Ray’s built-in
__ray_ready__task). If an actor fails repeatedly or its worker dies, the controller stops it and starts a new instance. Ray actor auto-restart is not used (max_restarts=0). AnActorHandleobtained before recreation may stay bound to the dead instance; callray.serve.get_deployment_actor()again (or resolve by name withray.get_actor) instead of caching a handle across potential failures.Example
from ray import serve from ray.serve.config import DeploymentActorConfig @ray.remote class PrefixTreeActor: def __init__(self, max_depth: int = 100): self.max_depth = max_depth def insert(self, text: str): self.max_depth += 1 @serve.deployment( deployment_actors=[ DeploymentActorConfig( name="prefix_tree", actor_class=PrefixTreeActor, init_kwargs={"max_depth": 100}, actor_options={"num_cpus": 0.1}, ), ], ) class MyDeployment: def __init__(self): self.tree = serve.get_deployment_actor("prefix_tree") def __call__(self, request): ray.get(self.tree.insert.remote(request.text))
PublicAPI (alpha): This API is in alpha and may change before becoming stable.
- field actor_class: type | str | ActorClass [Required]#
The actor class for this deployment-scoped actor. Can be a @ray.remote-decorated class or an import path string (e.g. ‘my_module:PrefixTreeActor’).