Skip to content

Commit

Permalink
producer: Make ProduceChannel unbuffered
Browse files Browse the repository at this point in the history
Part of #39.
  • Loading branch information
agis committed Aug 25, 2017
1 parent 2dcf24c commit 6ef4bf2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 6ef4bf2

Please sign in to comment.