We are experiencing something weird on Akka streams implementation. When so many incoming messages are there(after creating a set of actors simultaneously), we get full GC issues. We have analyzed backend using MAT and VisualVM. It complains that we have lot of immutable scala lists(Top dominators seen in MAT) connected to BroadcasHub is remaining in the heap, which is taking much space. When actors are killed, still MergeHub, BroadcastHub and AbstractNodeQueue and not cleaning in the heap area. They are keeping growing more and more when we instantiate more actors. But Flow is getting cleared though under this situation also.
Play version: 2.7.3
Akka version: 2.6.18
Code for creating hub sink.
Pair<Sink<JsonNode, NotUsed>, Source<JsonNode, NotUsed>> sinkSourcePair =
MergeHub.of(JsonNode.class, 16).toMat(BroadcastHub.of(JsonNode.class, 256), Keep.both()).run(getContext().getSystem());
this.hubSink = sinkSourcePair.first();
Source<JsonNode, NotUsed> hubSource = sinkSourcePair.second();
adminResponseQueue = hubSink.runWith(Source.queue(1, OverflowStrategy.dropHead()), getContext().getSystem());
Sink<JsonNode, CompletionStage<Done>> jsonSink = Sink.foreach(this::messageReceivedFromClient); // this method accepts json messages
this.clientFlow = Flow.fromSinkAndSourceCoupled(jsonSink, hubSource)
.watchTermination((n, stage) -> {
// When the flow shuts down, make sure this actor also stops.
stage.whenComplete((__, error) -> {
if(error != null) {
logger.error("Sink completed with exception", error);
}
context().stop(self());
});
return NotUsed.getInstance();
}
);
We expect a possible kind answer here.
Can you give me any possible solution? @jrudolph
5 posts - 2 participants