--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
How does this solve the problem?
Do those methods become available with a bounded mailbox?
Also, what happens to new messages with a bounded mailbox when full?
> For what it's worth, I recently implemented production monitoring which uses mailbox sizes, and it's been very useful to us. If that was not available in 2.0 would be a significant reason for us to not update, because we need to know more than just "is the mailbox full or not". Knowing that the actors are not able to keep up with what we're sending them is key to preventing problems, instead of just reacting to them.
We monitor mailbox sizes without using getMailboxSize. Timestamped events are generated for message send and receive (start of message processing) and many other things. Given a stream of events like this it's easy enough to calculate a mailbox size at a particular time. The send and receive events for any particular message are also connected with a unique trace id so it's also possible to say how much time messages spend in the mailbox, how long from sending to completing processing of a message, how long messages take to process on average, and so on.
• it takes O(n) time to get some size answer from a concurrent queue
• the answer is not correct, i.e. it does not need to match the real size at neither the beginning nor the end of processing this request
• making it “more correct” involves book-keeping which severely limits scalability
• and even then the number might have changed completely by the time you receive it in your code (e.g. your thread is scheduled out for 100ms and you get 10^5 new messages during that time).
So, no mailboxSize in the default implementation. You can write you own mailbox (that's really trivial, look at https://github.com/jboner/akka/blob/master/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala) and do exactly the book-keeping you like. RRDTool sounds interesting here, but be aware that this incurs a cost and ask youself if it is justified.
Switching angle: given a way for an actor to obtain its mailbox size, what would it do in case it measures that it does not keep up? Slowing down the senders—by way of a bounded queue—is basically the only thing it can do itself. Other than that only the supervisor can do something, but your application is likely not prepared to handle that, since all the supervisor can do is terminate the poor guy, invalidating all the references the senders have. There is no generic solution other than designing your application to be scalable at the required points by adding resizable routers from the beginning. Without knowing the points of contention, this is not possible.
I should probably turn this into a blog post for future reference.
Regards,
Roland Kuhn
Typesafe — The software stack for applications that scale
twitter: @rolandkuhn
Also, to expand on Rolands argument, you have to take into
consideration, system messages that are sent by Akka to actors to
handle fault-tolerance, starting, stopping etc.
To reiterate: Actors is not about hogging a thread on one message,
it's about reactive programming.
If you want to do long running one-off tasks, that's where Futures are
really good.
Also inspecting mailboxSize from within the actor itself turns a
reactive model into an active model, which is a different paradigm.
And then we have the scenario where if you'd poll let's say a, durable
mailbox, where the actual polling of the mailbox size, could take
several hundred milliseconds, or even seconds in the case of high
load.
>
> Switching angle: given a way for an actor to obtain its mailbox size, what would it do in case it measures that it does not keep up? Slowing down the senders—by way of a bounded queue—is basically the only thing it can do itself. Other than that only the supervisor can do something, but your application is likely not prepared to handle that, since all the supervisor can do is terminate the poor guy, invalidating all the references the senders have. There is no generic solution other than designing your application to be scalable at the required points by adding resizable routers from the beginning. Without knowing the points of contention, this is not possible.
Or you create your own mailbox implementation that when the mailbox
has more than X messages, it sends the messages to some other actor
instead? (seems weird but you could do that)
>
> I should probably turn this into a blog post for future reference.
Excellent, that'd save a lot of time.
Cheers,
√
--
Viktor Klang
Akka Tech Lead
Typesafe - The software stack for applications that scale
Twitter: @viktorklang
Or Agent.sendOff
--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner
Not that you need my approval for anything, but the ability in 2.0 to create one's own mailbox implementation sufficiently addresses the issue for me… apologies for bringing up a well trod and addressed topic.
Happily, custom mailboxes also address the question I brought up in another thread. Hurray for custom mailboxes!
Now I will patiently await the full release of 2.0.