Reputation: 1712
What is the correct way to fire a load-balancer using akka http? Currently I’m using the follow piece of code:
val poolClientFlow = Http().cachedHostConnectionPool[String](host, port)
source
.map(url => HttpRequest(uri = url) -> url)
.via(poolClientFlow)
.to(Sink.actorRef(myActor, IsDone))
.run()
Since I open the connection before, the load balancer understand I want to send to the same machine, so the roundrobin does not work properly.
Should I move the poolClientFlow
to the .via
, open and closing it every time?
Upvotes: 3
Views: 736
Reputation: 824
I wrote one a few weeks back as an experiment:
It uses the graph DSL to balance the request over a number of separate connection pools.
Upvotes: 2