Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU Usage on Consumer application #2170

Open
8 tasks
ksdvishnukumar opened this issue Jan 15, 2024 · 0 comments
Open
8 tasks

High CPU Usage on Consumer application #2170

ksdvishnukumar opened this issue Jan 15, 2024 · 0 comments

Comments

@ksdvishnukumar
Copy link

Description

Hello,

Im working on implementing kafka consumer and observed that the consumer caused high CPU utilization when multiple consumer application from different group is trying to read the message. Even though no messages are available in the partition seeing the CPU is more. All the applications waiting for the messages to receive and process.

I have a consumer close to 20 different applications. each application has 3 replicas (instances) subscribed to a single topic which has 10 partitions.

Am running the all the applications in AKS and application is trying to connect to Eventhub.

How to reproduce

Any simple application could re produce the scenario..

var consumerConfig = new ConsumerConfig
{
BootstrapServers = EventhubUrl,
EnableAutoCommit = false,
GroupId = consumerGroup,
AutoOffsetReset = AutoOffsetReset.Earliest,
CancellationDelayMaxMs = 200
};

using (var c = new ConsumerBuilder<Ignore, string>(consumerConfig).Build())
        {
            c.Subscribe(kafkaTopic);
            try
            {
                while (true)
                {
                    try
                    {
                        Console.WriteLine("Consumer running, waiting for messages");
                        var msg = c.Consume(cancellationToken);
                        Console.WriteLine($"Consumed message '{msg.Value}' at: '{msg.TopicPartitionOffset}'.");
                        c.Commit();
                    }
                    catch (ConsumeException e)
                    {
                        Console.WriteLine($"Error occured: {e.Error.Reason}");
                        Log.Error(e.Error.Reason);
                    }
                }
            }
            catch (Exception ex)
            {
                // Ensure the consumer leaves the group cleanly and final offsets are committed.
                c.Close();
                Log.Information(ex.Message);
            }
        }

The above issue happens only with when I use Subscribe method (1000 Mi CPU).

But if I use the Assign method to assign the Topic partition I don't see the CPU usage. Just to cross check and confirm with single application, consumer applications spins up with 10 consumer as a task with the single topic and different consumer group i see the CPU usage in 79 Mi CPU.

Checklist

Please provide the following information:

  • A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • Confluent.Kafka nuget version.
    2.1.1
  • Apache Kafka version.
  • Client configuration.
  • Operating system.
  • Provide logs (with "debug" : "..." as necessary in configuration).
  • Provide broker log excerpts.
  • Critical issue.

Illustrative Diagram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant