Skip to main content

Virtual Actors

Virtual Actors in Dapr provide a programming model for managing stateful objects at scale. Each actor is a single-threaded object with its own state and logic, managed by the Dapr runtime.

Key Features

  • Simplifies concurrency by ensuring one thread per actor
  • Automatic state persistence
  • Scales to millions of actors
  • Built-in timers and reminders

Example Usage

// Define and use a Dapr actor
public interface IOrderActor : IActor
{
Task SubmitOrderAsync(Order order);
}

// Call actor method
var proxy = ActorProxy.Create<IOrderActor>(actorId, "OrderActor");
await proxy.SubmitOrderAsync(order);

Real-World Application

You use Virtual Actors to model entities such as users, devices, or orders. Each actor maintains its own state, making it easy to build scalable, stateful applications.