Actor | Sent | Received | Send Rate | Receive Rate | Activity |
---|---|---|---|---|---|
load_balancer | 45 | 0 | 45.0 msg/s | 0.0 msg/s | 45 total |
worker1 | 15 | 15 | 15.0 msg/s | 15.0 msg/s | 30 total |
worker2 | 15 | 15 | 15.0 msg/s | 15.0 msg/s | 30 total |
worker3 | 15 | 15 | 15.0 msg/s | 15.0 msg/s | 30 total |
result_collector | 0 | 45 | 0.0 msg/s | 45.0 msg/s | 45 total |
This is the Elixir code that defines the actor simulation model:
simulation =
ActorSimulation.new(trace: true)
|> ActorSimulation.add_actor(:load_balancer,
send_pattern: {:burst, 3, 200, :work},
targets: [:worker1, :worker2, :worker3]
)
|> ActorSimulation.add_actor(:worker1,
on_match: [
{:work, fn state -> {:send, [{:result_collector, :result}], state} end}
]
)
|> ActorSimulation.add_actor(:worker2,
on_match: [
{:work, fn state -> {:send, [{:result_collector, :result}], state} end}
]
)
|> ActorSimulation.add_actor(:worker3,
on_match: [
{:work, fn state -> {:send, [{:result_collector, :result}], state} end}
]
)
|> ActorSimulation.add_actor(:result_collector)
|> ActorSimulation.run(duration: 1000)