Skip to content

High memory usage when producing messages #1060

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

Open
3 tasks done
intfish123 opened this issue Sep 18, 2023 · 2 comments
Open
3 tasks done

High memory usage when producing messages #1060

intfish123 opened this issue Sep 18, 2023 · 2 comments

Comments

@intfish123
Copy link

intfish123 commented Sep 18, 2023

Description

I run a process to write messages to redpanda for pressure test, the memory usage is very high with kafka._Cfunc_GoBytes. It's so weird.

How to reproduce

Run redpanda with HDD that is lower write performance, then read messages and write to redpanda.

producer code:

p, err := kafka.NewProducer(kafkaconf)
if err != nil {
	return err
}

go func() {
	i := 0
	for {
		e, ok := <-ck.producer.Events()
		if !ok {
			zap.S().Infof("producer.Events() exited")
			return
		}
		switch ev := e.(type) {
		case *kafka.Message:
			m := ev
			if m.TopicPartition.Error != nil {
				zap.S().Errorf("Delivery %v failed: %v, data size: %vbytes\n", *m.TopicPartition.Topic, m.TopicPartition.Error, len(m.Value))
			}
		default:
			zap.S().Warnf("Ignored event: %v", ev)
		}
	}
}()

send message to chan


for m :=  range readChan {
    p.ProduceChannel() <- m
}

Client configuration:

        defaultBatchSize := 1 * 1024 * 1024           // in bytes
	defaultMessageMaxBytesSize := 2 * 1024 * 1024 // in bytes
	defaultBatchNumMessages := 10000
	defaultLingerMs := 1000
	
	kafkaconf := &kafka.ConfigMap{
		"bootstrap.servers":             strings.Join(address, ","),
		"compression.type":              compressType,
		"batch.size":                    defaultBatchSize,
		"message.max.bytes":             messageMaxBytesSize,
		"batch.num.messages":            batchNumMessages,
		"linger.ms":                     lingerMs,
		"sticky.partitioning.linger.ms": 2 * lingerMs,
		"acks":                          1,
	}

pprof001
image

image

Checklist

Please provide the following information:

  • confluent-kafka-go and librdkafka version (v1.8.2):
  • Apache Kafka broker version: 2.2.0
  • Client configuration
@yanmxa
Copy link

yanmxa commented Apr 3, 2024

I encountered a similar issue with kafka._Cfunc_GoBytes.

@dingteddy
Copy link

I encountered a similar issue with kafka._Cfunc_GoBytes.

i got same issue, how do you solve this problem?

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

3 participants