below method using large amount of CPU can anyone help me to minimize the CPU usage with proper solution.
KafkaConsumer.PlainSource(
consumerSettings, subscription)
.RunForeach(result =>
{
_ActorRef.Tell(result.Message.Value);
}, materializer);
I'm running the
SimpleProducerandSimpleConsumersamples baked into the Akka.Streams.Kafka repository - and thePlainSourceis designed in a nearly identical fashion to yours:Here's what my CPU utilization looks like - bearing in mind that the producer is continuously producing new events for my consumer:
This is extremely low resource consumption - which is what Akka.Streams and all of its plugins (such as Kafka) provide out of the box.
Your setup has no backpressure support (since
IActorRef.Tellis non-blocking) and therefore this stream is going to run at full blast inside your system. Whatever your actors are doing is probably what's responsible for high CPU utilization.Your other ticket is asking about how to add backpressure support to your Akka.Streams.Kafka application, so I'll help answer that too.