1
votes

The documentation says that on Http().bindAndHandle() :

there is no backpressure being applied to the connections Source, i.e. all connections are being accepted at maximum rate, which, depending on the applications, might present a DoS risk!

The same applies for bindAndHandleAsync() bindAndHandleSync().

The documentation also states that even higher level systems such as file IO or TCP, I suppose HTTP being on top of TCP will work by the reactive-streams mechanisms.

Is Http().bind() the magic function? Does that apply back-pressure?

How do I expose a back-pressured HTTP endpoint with akka-streams?

1
The documentation has beed fixed in github.com/akka/akka/commit/… .Roland Kuhn
Thanks Roland! I appreciate all the akka work, it's one of the greatest in Computer Science :D !!Hunor Kovács

1 Answers

3
votes

in java this will look like this

Flow<ByteString, ByteString, BoxedUnit> dataFlow = ...;
Http
            .get(actorSystem)
            .bind(host, port, materializer)
            .to(foreach(con -> {
                logger.info("Accepted connection from {}.", con.remoteAddress());
                con.handleWith(dataFlow, materializer)
            }))
            .run(materializer);

the dataFlow is any flow that transforms incomming messages and maps them to response events. this way you will benefit from all reactive stream's goodies.

you can also try with http routing and simple Tcp.