scala - How heavy are akka actors? -
i aware imprecise question , might deemed inappropriate stack. unfortunately smaller applications (in terms of number of actors) , 'tutorial-like' ones don't me develop intuition overhead of message dispatch , swift spot granularity between 'scala object' , 'corba object'.
while keeping state of conversation client example deserves actor, in real use cases involve conditional/parallel/alternative interactions modelled many classes. leaves choice between treating actors facades quite complex services, similar justly retired ejb, or akin smalltalk objects, firing messages between each other willy-nilly whenever communication can possibly implemented in asynchronous manner.
apart overhead of message passing itself, there overhead involved lifecycle management, , wary of potential problems caused chained-restarts of whole subtrees of actors due exceptions or other errors in root.
for sake of question may assume vast majority of communication happens within single machine , network crossing insignificant.
i not sure mean "overhead of message passing itself". when network/serialisation not involved overhead negligible: 1 side pushes message in queue, reads it.
akka claims can go fast 50 millions messages per second on single machine. means wouldn't use actors façade complex subsystems. rather model them mush smaller "working units". can more complex compare smalltalk objects when convenient. have, say, kafkaconsumeractor
utilise internally other "normal" classes such connection, configuration, etc., these don't have akka actors. still small enough simple working unit doing 1 simple thing (consuming message , sending somewhere).
50 millions second lot.
a memory footprint extremely small. akka claims can have ~2.5 millions actors 1gb of heap. compare typical system is, indeed, nothing.
as lifecycle, creating actor not heavier creating class instance , mailbox don't expect significant.
saying that, typically don't have many actors in system handle 1 message , die. spawn actors live longer. like, actor calculates mortgage repayments based on parameters provide doesn't have reason die @ all.
akka makes simple use actor pools (different kinds of them).
performance here tweakable.
last point should compare akka overhead in context. example, if system doing database queries, or serving/performing http requests, or doing significant io of sort, overhead of these activities makes overhead of akka insignificant wouldn't bother thinking it. roundtrip db 50 millis equivalent of overhead ~2.5 millions akka messages. matter?
so can find edge case scenario akka force pay performance penalties? probably. akka not golden hammer (and nothing is).
above in mind should think if akka performance bottleneck in specific context or wasting time in micro-optimisation.
Comments
Post a Comment