Akka stream throttle the transmission bandwidth

132 views
Skip to first unread message

Nicolas Jozwiak

unread,
Nov 26, 2014, 7:34:21 AM11/26/14
to akka...@googlegroups.com

Hello,

      I’m currently using akka stream 0.11 to process some big files and I want to throttle the transmission bandwidth.

     For example I would like to limit the throughput  to XXX Kb/s. I saw the groupedWithin function but it does not fill my needs.

     Is there a way to do that ? Or is it planned ?

Thanks for your help.

Endre Varga

unread,
Nov 26, 2014, 7:44:25 AM11/26/14
to akka...@googlegroups.com
Hi,

There are various ways to implement this. The quick'n'dirty setup is something like (pseudocode):

TickSource -> buffer -> zip.right
toBeThrottled -> zip.left
zip.map(_._2) -> // the throttled output

The above will generate tokens (ticks) periodically, then accumulating them in a buffer. The throttled stream can only progress if there are ticks available in the buffer, otherwise it has to wait for the next token.

This is just a simple example, there are various other (and more efficient) ways to solve it, the most flexible solution would probably be a FlexiMerge, but that is a little bit harder to implement.

-Endre

Thanks for your help.

--
You received this message because you are subscribed to the Google Groups "Akka Developer List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Jozwiak

unread,
Nov 26, 2014, 8:25:16 AM11/26/14
to akka...@googlegroups.com
Hi,

   Do you know if some documentations or examples exists with FlexiMerge ?

Thanks for your response ! 

Endre Varga

unread,
Nov 26, 2014, 8:41:03 AM11/26/14
to akka...@googlegroups.com
Hi,

On Wed, Nov 26, 2014 at 2:25 PM, Nicolas Jozwiak <n.jo...@gmail.com> wrote:
Hi,

   Do you know if some documentations or examples exists with FlexiMerge ?

Nicolas Jozwiak

unread,
Nov 26, 2014, 9:21:03 AM11/26/14
to akka...@googlegroups.com
Hi,

    I will look at the test code.

Thank you.

Patrik Nordwall

unread,
Nov 26, 2014, 11:21:01 AM11/26/14
to akka...@googlegroups.com
Future questions about how to use Akka are welcome at akka-user.
akka-dev is intended for discussion of how to develop Akka itself.
Thanks,
Patrik

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Reply all
Reply to author
Forward
0 new messages