java - Akka actors processes one message at a time -


akka actor can process 1 message @ time , hence dont need worry concurrency.

consider have system pizza shop.

design this

1)webservice  2)akka ecosystem actors pizaacreater, deliveryhandler  3)web service accepts ther order , passes pizzacreater,pizzacreater creates pizza , passes deliveryhanlder. 

now there 1 instance of pizzacreater , deliveryhandler.this slow down entire system.

1)should create multiple pizzacreaters , deliveryhandler? 2)how customerservice pass order pizzacreater minimum load or how pizzacreater pass pizza delivieryhandler minimum load then? 3)is creating multiple instance of pizzacreaters / deliveryhandler ok? 

  1. if "pizza creation" blocking operation (uses network/db) create router pizzacreatorworkers (the number of workers/threads depends on scenario). if "pizza creation" non-blocking - create 1 actor per request. same thing delivery: create router fixed number of deliveryhandles if delivery blocking otherwise create actor , pass "the pizza".

  2. in cases order passing should done through non-mutable messages : should not modify order once passed down chain. should not worry "load" passing messages akka efficient - pass references between actors.

  3. the akka docs specify akka system designed handle millions of actors, never worry "multiple instances" of actors long logic of application requires.

from akka.io main page:

50 million msg/sec on single machine. small memory footprint; ~2.5 million actors per gb of heap.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -