Random partitioner does not distribute messages between Kafka topic partitionsData Modeling with Kafka? Topics and PartitionsKafKa partitioner class, assign message to partition within topic using keyTopics, partitions and keysKafka – check number of messages in each partitionMessage not getting distributed in RoundRobin order when increasing the number of partition in KafkaKafka Consumer partition mappingWhy is data not evenly distributed among partitions when a partitioning key is not specified?What's the best way to design message key in Kafka?Matching Kafka consumer and producer partitionHow Can a Consumer in Kafka be assigned to a Specific partition ;The partition in my case is assigned through the hash value of the Key
Notepad++ cannot print
Architectural feasibility of a tiered circular stone keep
Do Bayesian credible intervals treat the estimated parameter as a random variable?
Could George I (of Great Britain) speak English?
Compelling story with the world as a villain
Non-visual Computers - thoughts?
Why did Khan ask Admiral James T. Kirk about Project Genesis?
Duplicate instruments in unison in an orchestra
Obtaining the intermediate solutions in AMPL
How do proponents of Sola Scriptura address the ministry of those Apostles who authored no parts of Scripture?
Can I get temporary health insurance while moving to the US?
Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?
Where can/should I, as a high schooler, publish a paper regarding the derivation of a formula?
Are the A380 engines interchangeable (given they are not all equipped with reverse)?
Two questions about typesetting a Roman missal
What is the best type of paint to paint a shipping container?
Another solution to create a set with two conditions
How do I make my image comply with the requirements of this photography competition?
Can a Rogue PC teach an NPC to perform Sneak Attack?
How do I prevent other wifi networks from showing up on my computer?
I don't have the theoretical background in my PhD topic. I can't justify getting the degree
Can RMSE and MAE have the same value?
Why doesn't 'd /= d' throw a division by zero exception?
How long do you think advanced cybernetic implants would plausibly last?
Random partitioner does not distribute messages between Kafka topic partitions
Data Modeling with Kafka? Topics and PartitionsKafKa partitioner class, assign message to partition within topic using keyTopics, partitions and keysKafka – check number of messages in each partitionMessage not getting distributed in RoundRobin order when increasing the number of partition in KafkaKafka Consumer partition mappingWhy is data not evenly distributed among partitions when a partitioning key is not specified?What's the best way to design message key in Kafka?Matching Kafka consumer and producer partitionHow Can a Consumer in Kafka be assigned to a Specific partition ;The partition in my case is assigned through the hash value of the Key
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've created a topic in Kafka with 9 partitions, naming it aptly 'test', and knocked together two simple applications in C# (.NET Core), using Confluent.Kafka
client library: a producer and a consumer. I did little more than tweak examples from the documentation.
I am running two instances of the consumer application and one instance of the producer. I don't see much point in pasting the consumer code here, it's a trivial 'get a message, print it on screen' app, however, it does also print the number of the partition the message came from.
This is the producer app:
static async Task Main(string[] args)
var random = new Random();
var config = new ProducerConfig
BootstrapServers = "10.0.0.5:9092",
Partitioner = Partitioner.ConsistentRandom
;
int counter = 0;
while (true)
using (var p = new ProducerBuilder<string, string>(config).Build())
try
p.BeginProduce(
"test",
new Message<string, string>
//Key = random.Next().ToString(),
Value = $"test ++counter"
);
if (counter % 10 == 0)
p.Flush();
catch (ProduceException<Null, string> e)
Console.WriteLine($"Delivery failed: e.Error.Reason");
Problem: If the Key
property of the message is not set, all messages get sent to the partition number 7, meaning that one of my consumer instances is idle. I had to manually randomise the key in order to distribute them between partitions (see the commented out line). (The original code, as copied from the docs, used Null
as the type of the key, and this sent all messages to the 7th partition too.)
Why is that? According to the documentation of the ProducerConfig.Partitioner
property, the consistent_random
option should ensure random distribution if the key is not specified. I tried using the Partioner.Random
option, which should use random distribution regardless of the key, but this did not help.
Is this the expected behaviour, am I doing something wrong, or did I come across a bug?
I am using version 1.0.0-RC2 of Confluent.Kafka NuGet.
Complete documentation of the Partitioner config:
// Summary:
// Partitioner: `random` - random distribution, `consistent` - CRC32 hash of key
// (Empty and NULL keys are mapped to single partition), `consistent_random` - CRC32
// hash of key (Empty and NULL keys are randomly partitioned), `murmur2` - Java
// Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
// `murmur2_random` - Java Producer compatible Murmur2 hash of key (NULL keys are
// randomly partitioned. This is functionally equivalent to the default partitioner
// in the Java Producer.). default: consistent_random importance: high
c# apache-kafka confluent-kafka
add a comment |
I've created a topic in Kafka with 9 partitions, naming it aptly 'test', and knocked together two simple applications in C# (.NET Core), using Confluent.Kafka
client library: a producer and a consumer. I did little more than tweak examples from the documentation.
I am running two instances of the consumer application and one instance of the producer. I don't see much point in pasting the consumer code here, it's a trivial 'get a message, print it on screen' app, however, it does also print the number of the partition the message came from.
This is the producer app:
static async Task Main(string[] args)
var random = new Random();
var config = new ProducerConfig
BootstrapServers = "10.0.0.5:9092",
Partitioner = Partitioner.ConsistentRandom
;
int counter = 0;
while (true)
using (var p = new ProducerBuilder<string, string>(config).Build())
try
p.BeginProduce(
"test",
new Message<string, string>
//Key = random.Next().ToString(),
Value = $"test ++counter"
);
if (counter % 10 == 0)
p.Flush();
catch (ProduceException<Null, string> e)
Console.WriteLine($"Delivery failed: e.Error.Reason");
Problem: If the Key
property of the message is not set, all messages get sent to the partition number 7, meaning that one of my consumer instances is idle. I had to manually randomise the key in order to distribute them between partitions (see the commented out line). (The original code, as copied from the docs, used Null
as the type of the key, and this sent all messages to the 7th partition too.)
Why is that? According to the documentation of the ProducerConfig.Partitioner
property, the consistent_random
option should ensure random distribution if the key is not specified. I tried using the Partioner.Random
option, which should use random distribution regardless of the key, but this did not help.
Is this the expected behaviour, am I doing something wrong, or did I come across a bug?
I am using version 1.0.0-RC2 of Confluent.Kafka NuGet.
Complete documentation of the Partitioner config:
// Summary:
// Partitioner: `random` - random distribution, `consistent` - CRC32 hash of key
// (Empty and NULL keys are mapped to single partition), `consistent_random` - CRC32
// hash of key (Empty and NULL keys are randomly partitioned), `murmur2` - Java
// Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
// `murmur2_random` - Java Producer compatible Murmur2 hash of key (NULL keys are
// randomly partitioned. This is functionally equivalent to the default partitioner
// in the Java Producer.). default: consistent_random importance: high
c# apache-kafka confluent-kafka
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37
add a comment |
I've created a topic in Kafka with 9 partitions, naming it aptly 'test', and knocked together two simple applications in C# (.NET Core), using Confluent.Kafka
client library: a producer and a consumer. I did little more than tweak examples from the documentation.
I am running two instances of the consumer application and one instance of the producer. I don't see much point in pasting the consumer code here, it's a trivial 'get a message, print it on screen' app, however, it does also print the number of the partition the message came from.
This is the producer app:
static async Task Main(string[] args)
var random = new Random();
var config = new ProducerConfig
BootstrapServers = "10.0.0.5:9092",
Partitioner = Partitioner.ConsistentRandom
;
int counter = 0;
while (true)
using (var p = new ProducerBuilder<string, string>(config).Build())
try
p.BeginProduce(
"test",
new Message<string, string>
//Key = random.Next().ToString(),
Value = $"test ++counter"
);
if (counter % 10 == 0)
p.Flush();
catch (ProduceException<Null, string> e)
Console.WriteLine($"Delivery failed: e.Error.Reason");
Problem: If the Key
property of the message is not set, all messages get sent to the partition number 7, meaning that one of my consumer instances is idle. I had to manually randomise the key in order to distribute them between partitions (see the commented out line). (The original code, as copied from the docs, used Null
as the type of the key, and this sent all messages to the 7th partition too.)
Why is that? According to the documentation of the ProducerConfig.Partitioner
property, the consistent_random
option should ensure random distribution if the key is not specified. I tried using the Partioner.Random
option, which should use random distribution regardless of the key, but this did not help.
Is this the expected behaviour, am I doing something wrong, or did I come across a bug?
I am using version 1.0.0-RC2 of Confluent.Kafka NuGet.
Complete documentation of the Partitioner config:
// Summary:
// Partitioner: `random` - random distribution, `consistent` - CRC32 hash of key
// (Empty and NULL keys are mapped to single partition), `consistent_random` - CRC32
// hash of key (Empty and NULL keys are randomly partitioned), `murmur2` - Java
// Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
// `murmur2_random` - Java Producer compatible Murmur2 hash of key (NULL keys are
// randomly partitioned. This is functionally equivalent to the default partitioner
// in the Java Producer.). default: consistent_random importance: high
c# apache-kafka confluent-kafka
I've created a topic in Kafka with 9 partitions, naming it aptly 'test', and knocked together two simple applications in C# (.NET Core), using Confluent.Kafka
client library: a producer and a consumer. I did little more than tweak examples from the documentation.
I am running two instances of the consumer application and one instance of the producer. I don't see much point in pasting the consumer code here, it's a trivial 'get a message, print it on screen' app, however, it does also print the number of the partition the message came from.
This is the producer app:
static async Task Main(string[] args)
var random = new Random();
var config = new ProducerConfig
BootstrapServers = "10.0.0.5:9092",
Partitioner = Partitioner.ConsistentRandom
;
int counter = 0;
while (true)
using (var p = new ProducerBuilder<string, string>(config).Build())
try
p.BeginProduce(
"test",
new Message<string, string>
//Key = random.Next().ToString(),
Value = $"test ++counter"
);
if (counter % 10 == 0)
p.Flush();
catch (ProduceException<Null, string> e)
Console.WriteLine($"Delivery failed: e.Error.Reason");
Problem: If the Key
property of the message is not set, all messages get sent to the partition number 7, meaning that one of my consumer instances is idle. I had to manually randomise the key in order to distribute them between partitions (see the commented out line). (The original code, as copied from the docs, used Null
as the type of the key, and this sent all messages to the 7th partition too.)
Why is that? According to the documentation of the ProducerConfig.Partitioner
property, the consistent_random
option should ensure random distribution if the key is not specified. I tried using the Partioner.Random
option, which should use random distribution regardless of the key, but this did not help.
Is this the expected behaviour, am I doing something wrong, or did I come across a bug?
I am using version 1.0.0-RC2 of Confluent.Kafka NuGet.
Complete documentation of the Partitioner config:
// Summary:
// Partitioner: `random` - random distribution, `consistent` - CRC32 hash of key
// (Empty and NULL keys are mapped to single partition), `consistent_random` - CRC32
// hash of key (Empty and NULL keys are randomly partitioned), `murmur2` - Java
// Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
// `murmur2_random` - Java Producer compatible Murmur2 hash of key (NULL keys are
// randomly partitioned. This is functionally equivalent to the default partitioner
// in the Java Producer.). default: consistent_random importance: high
c# apache-kafka confluent-kafka
c# apache-kafka confluent-kafka
edited Mar 27 at 20:30
JR ibkr
4491 silver badge13 bronze badges
4491 silver badge13 bronze badges
asked Mar 27 at 17:51
kamilkkamilk
1,74616 silver badges33 bronze badges
1,74616 silver badges33 bronze badges
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37
add a comment |
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383644%2frandom-partitioner-does-not-distribute-messages-between-kafka-topic-partitions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383644%2frandom-partitioner-does-not-distribute-messages-between-kafka-topic-partitions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't think there would be a bug in the project. Can you add the link to Partitioner config documentation?
– JR ibkr
Mar 27 at 19:39
@JRibkr Yeah, I don't really think it's a bug either, something so obvious would surely have been spotted. I copied the documentation from the XML docs in the library itself, as seen in Visual Studio, I don't know if an online version is available at all. A google search only yielded this source file: github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/…
– kamilk
Mar 27 at 20:37