Skip to content

Round-robin multiple Kafka topics#299

Merged
vruello merged 5 commits intocea-sec:mainfrom
lyradc:multi_topics
Sep 26, 2025
Merged

Round-robin multiple Kafka topics#299
vruello merged 5 commits intocea-sec:mainfrom
lyradc:multi_topics

Conversation

@lyradc
Copy link
Contributor

@lyradc lyradc commented Sep 24, 2025

Allows the topic parameter to contain multiple topics delimited by comma (,).

This is to satisfy request #281 .

Initial testing shows fairly consistent distribution of logs across topics.
image

@vruello
Copy link
Collaborator

vruello commented Sep 25, 2025

Hi @lyradc,

I'm a bit concerned about the performance impact of using an atomic. That's why I proposed to use a simple "thread-local" counter in the write method. Since clients usually send much more events than there are Kafka topics to write to, this should provide a reasonable distribution across topics.

In practice, this would mean replacing l_topic_index with a simple uint local to the write method, initialized to 0.

What do you think?

@lyradc
Copy link
Contributor Author

lyradc commented Sep 25, 2025

Thank you for the feedback @vruello. I was concerned at lower volume this wouldn't distribute well... However after implementing a local uint in the write fn I observed an even distribution across topics at low volume.

@vruello
Copy link
Collaborator

vruello commented Sep 26, 2025

I made some changes:

  • The list of topics does not need to be computed for each batch of events. I computed it once in KafkaOutput::new and stored the result in KafkaOutput.topics.
  • Since KafkaConfiguration::topic_as_array is only used once by the Kafka driver, it seems cleaner to replace it with inlined code in KafkaOutput::new.
  • Since KafkaOutput.config was only used to retrieve the destination topic, it can now be removed.

@lyradc are you ok with these changes?

@lyradc
Copy link
Contributor Author

lyradc commented Sep 26, 2025

Thanks again, yeah that looks good to me.

@vruello vruello merged commit ffbaa20 into cea-sec:main Sep 26, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants