-
Notifications
You must be signed in to change notification settings - Fork 104
feat(kafka): Sharding into many topics based on partition key #4861
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
Conversation
84b4ef5
to
cc3919e
Compare
cc3919e
to
6166f59
Compare
@@ -112,7 +112,6 @@ ed25519-dalek = "2.1.1" | |||
enumset = "1.0.13" | |||
flate2 = "1.0.35" | |||
flume = { version = "0.11.1", default-features = false } | |||
fnv = "1.0.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fnv was entirely unused
relay-kafka/src/producer/mod.rs
Outdated
None => { | ||
// fetch_add wraps on overflow | ||
let count = self.round_robin_counter.fetch_add(1, Ordering::Relaxed); | ||
count % self.topic_producers.len() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think doing round-robin between shards in case of no key is probably cheaper than actually-random, wdyt
feda1a6
to
bffc0cf
Compare
01ff5f8
to
f6c2330
Compare
Inner::ShardedSecondary(configs) => configs, | ||
}; | ||
|
||
Ok(Self(configs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should guard somewhere against empty lists, can be here or in the config conversion to the Kafka* types.
Co-authored-by: David Herberth <[email protected]>
Introduce sharding into the kafka producer, even with shards distributed across many brokers.
We could've had a different implementation where we have a ShardingProducer wrapping many Producers, but while this would avoid touching the most critical parts of the codebase, it would also mean a ton of additional code. I think it's cleaner to work towards a design where non-sharded topics are a special case of sharded topics.
ref RELAY-115