Skip to content
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

ref(store): Random Kafka partitioning for sessions #1194

Merged
merged 5 commits into from
Mar 10, 2022

Conversation

jan-auer
Copy link
Member

Instead of using the session ID as partition key for producing sessions, assign
a random partitioning key. This ensures more even distribution of sessions on
the Kafka topic, even if clients are sending many updates for the same session.

We have noticed intermittent imbalance on the partitions. The theory is that
clients are sending repeat updates for the same session (ID) when a high number
of errors are occurring within that session. Every session update would go to
the same partition unless we use random partitioning.

Snuba does not have logical constraints on the partitioning.

@jan-auer jan-auer requested a review from a team February 23, 2022 10:03
@jan-auer jan-auer self-assigned this Feb 23, 2022
@@ -673,8 +673,8 @@ impl KafkaMessage {
Self::Attachment(message) => message.event_id.0,
Self::AttachmentChunk(message) => message.event_id.0,
Self::UserReport(message) => message.event_id.0,
Self::Session(message) => message.session_id,
Self::Metric(_message) => Uuid::nil(), // TODO(ja): Determine a partitioning key
Self::Session(_message) => Uuid::nil(), // Explicit random partitioning for sessions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this NIL is overwritten immediately after the match block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, can we note down the observed scenario that motivated this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping in code it's enough to say that we explicitly want uniform distribution. The full reasoning is in the PR description, and given that it's a hypothesis I wasn't gonna put this in the code.

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we are sure that the partitioning by ID wasn't there for a reason, this looks good to me!

@jan-auer jan-auer requested a review from fpacifici February 23, 2022 10:55
@jan-auer
Copy link
Member Author

Asking for @fpacifici's blessing before merging this :)

@@ -673,8 +673,8 @@ impl KafkaMessage {
Self::Attachment(message) => message.event_id.0,
Self::AttachmentChunk(message) => message.event_id.0,
Self::UserReport(message) => message.event_id.0,
Self::Session(message) => message.session_id,
Self::Metric(_message) => Uuid::nil(), // TODO(ja): Determine a partitioning key
Self::Session(_message) => Uuid::nil(), // Explicit random partitioning for sessions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, can we note down the observed scenario that motivated this change?

jan-auer added 3 commits March 9, 2022 08:39
* master:
  ref(make): Simplify M1 exports in Makefile (#1206)
  fix(metrics): Wait for project states during aggregator shutdown (#1205)
  fix(test): Find librdkafka on Apple M1 (#1204)
  build: Bump sentry-relay in dev dependencies to 0.8.9 (#1202)
  ref(metrics): Tag backdated bucket creations in statsd (#1200)
  feat(metrics): Extract user satisfaction as tag (#1197)
  fix(statsd): Add new metric_type tag to existing metrics (#1199)
  fix: Apply clippy 1.59 suggestions (#1198)
* master:
  ci(gcb): Increase timeout for self-hosted integration test (#1208)
  build: Update regex to 1.5.5 (#1207)
@jan-auer jan-auer merged commit 6c3415c into master Mar 10, 2022
@jan-auer jan-auer deleted the ref/session-partitioning branch March 10, 2022 09:33
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.

3 participants