Alex Alex
08/24/2024, 10:08 PMTim Wolfe
08/29/2024, 5:39 PMSubscriberEvents, which currently has a segment granularity of 12 hours and uses hash-based partitions, it's important to understand how Druid handles compaction tasks, especially when changing parameters like segment granularity and number of shards.
When you initiate a compaction process in Druid, it typically operates on an entire time interval covered by segments. In your case, if you have existing segments for the 12-hour period containing 1 billion events, the compaction will involve reading through these segments to create the new segments with 1-day granularity and the adjusted number of shards.
1. Segment Scanning Requirement: Yes, Druid will indeed need to scan all existing segments, which means it will look at the 100 segments corresponding to the 12-hour granularity. Each of these segments will be referenced as Druid calculates the new partitions for the 1-day granularity. The result will be 200 segments for each day, effectively doubling your number of shards.
2. Compaction Process: Druid performs compaction in a way that it processes segments at once, rather than on a per-segment basis when transitioning from a smaller segment size to a larger one. This means it will read data from all 100 corresponding segments of the previous granularity in order to compute the new segments. This is necessary to ensure that the partitioning by SUBSCRIBER_ID is correctly maintained across the entire data set.
3. Efficiency Considerations: While the process can be time-consuming due to the sheer volume of data (1 billion events for 12 hours), Druid is optimized for such tasks. The compaction will focus on reorganizing your data effectively, but because you're dealing with a large amount of data and a change in partitioning, you might need to plan the execution during off-peak hours to mitigate performance degradation during the compaction.
4. Possibility of Per-Segment Handling: Druid is unlikely to split and concatenate on a per-segment basis as you suggested. Instead, it will aggregate data at a broader level throughout all the relevant segments in the specified time range. This ensures that all data contributing to a partition is considered in the final compacted segment, maintaining integrity and performance.
Thus, while the compaction process will indeed take a significant amount of time given the data volume, Druid optimizes the data restructuring to enhance query performance effectively after compaction is completed. You can expect improved scanning performance for queries based on SUBSCRIBER_ID post-compaction.
Sources:
- Compaction Overview: compaction.md (internal document)
- Automatic Compaction Details: automatic-compaction.md (internal document)
- Managing Partitioning Schemes: multitenancy.md (internal document)