From 6ef4bf248be773945135cf184d20ea47426413e8 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Fri, 25 Aug 2017 15:29:21 +0300 Subject: [PATCH] producer: Make ProduceChannel unbuffered Part of #39. --- rafka.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rafka.go b/rafka.go index f5c3f1f..4bdbf38 100644 --- a/rafka.go +++ b/rafka.go @@ -133,6 +133,20 @@ func main() { } } + // We don't use the channel-based producer API, but even then + // confluent-kafka-go still preallocates a channel with the + // default buffer size of 1000000. Thus, this reduces memory + // usage significantly, especially in the case of many, + // short-lived producers. + // + // NOTE: If we ever want to change to the channel-based + // producer API, this should be set via the config file + // instead. + err = cfg.Librdkafka.Producer.SetKey("go.produce.channel.size", 0) + if err != nil { + return fmt.Errorf("Error setting go.produce.channel.size: %s", err) + } + return nil }