I totally agree with Patrik, simplicity is going to be the key.

The approach I have shown you wasn't the first instance of my code when I 
started,
it is just the current state where my application has evolved to, you will 
eventually evolve it when the need arises.

Also I was trying to show you the choices you will have in the future if 
you need to go one way or the other,
the concept of using workers is well known and has proven to scale even 
with slower frameworks than Akka

*-that also says that I consider Akka a hell of a good toolkit to work 
with; it gives you many ways of solving one problem and each way does it 
well-*

You are prototyping and coding at the same time, I believe the more choices 
you are aware of the better you will build your application.

HTH,

Guido.

On Thursday, June 30, 2016 at 7:27:41 AM UTC+1, Patrik Nordwall wrote:
>
> I agree that there is a performance cost involved in creating actors, but 
> if you don't have extreme performance requirements PerRequest actors can 
> make the code more clear and easier to reason about. I would start simple 
> and only introduce a more complex solution when I have measured and 
> confirmed that it is needed. 
>
> Cheers,
> Patrik
>
> On Wed, Jun 29, 2016 at 11:50 PM, Guido Medina <[email protected] 
> <javascript:>> wrote:
>
>> Even if the cost of creating new actors is low, there is still a cost, 
>> its lifecycle for example has to be ran per actor creation,
>> a mailbox has to be created and that adds up to the GC, you could even 
>> use specific mailboxes for these set of actors that are inside a router,
>> for example, I use two types of "faster" and "cheaper" mailboxes for 
>> worker's like actors, like:
>>
>> https://gist.github.com/guidomedina/ddd729492c8fb8148032
>>
>> That way my workers are always ready to process whatever.
>> Just my opinion though,
>>
>> Guido.
>>
>>
>> On Wednesday, June 29, 2016 at 10:41:52 PM UTC+1, Guido Medina wrote:
>>>
>>> *Correction:* is actors.size(), not value.size(), value came from the 
>>> original code which iterates over a Map, something else, which is my DDD 
>>> shard distributor:
>>>
>>> On Wednesday, June 29, 2016 at 10:40:20 PM UTC+1, Guido Medina wrote:
>>>>
>>>> Here is how to create your Router programmatically:
>>>>
>>>> final List<ActorRef> actors = ...
>>>> Router router = new Router(new RoundRobinRoutingLogic(), 
>>>> actors.stream().map(ActorRefRoutee::new).
>>>>             collect(toCollection(() -> new ArrayList<>(actors.size())));
>>>>
>>>> In this case I'm using RoundRobinRoutingLogic, you can use any of the 
>>>> pre-defined ones or you could implement your own.
>>>> You want the size of that list to be something like:
>>>>
>>>> *Runtime.getRuntime().availableProcessors()* * *N* where N in [1..4]
>>>>
>>>> HTH,
>>>>
>>>> Guido.
>>>>
>>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Patrik Nordwall
> Akka Tech Lead
> Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
> Twitter: @patriknw
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to