DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Authors: Greg Harris, Ivan Yurchenko, Jorge Quilcate, Giuseppe Lillo, Anatolii Popov, Juha Mynttinen, Josep Prat, Filip Yonov
Status
Current state: Under Discussion (Re-Opened)
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA: KAFKA-19161
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
This KIP was discarded due to a design change in KIP-1163 which made it unnecessary.
Glossary
- Diskless Topic: A topic which does not append to or serve from block storage devices.
- Object Storage: A shared, durable, concurrent, and eventually consistent storage supporting arbitrary sized byte values and a minimal set of atomic operations: put, delete, list, and ranged get.
- Object Key: A unique reference to an object within Object Storage.
- Batch: A container for Kafka records and a unit of record representation in the network protocol and storage format in both status quo Kafka and diskless topics.
- Shared Log Segment Object: An object containing a shared log segment for one or more diskless topic-partitions on the object storage. Contains record batches similar to classic Kafka topics.
- Batch Coordinate: A reference to a record batch within a shared log segment object, at some byte range.
- Diskless Batch Coordinator: Component serving as source of truth about batch coordinates and log segment objects. Establishes a global order of batches within a diskless topic, and serves coordinates to enable retrieval of batches.
- Object Compaction: Distinct from log compaction. A background asynchronous process which reads from and writes to multiple shared log segment objects to manage already-written objects.
Motivation
KIP-1150: Diskless Topics introduces the concepts of diskless topics, KIP-1163: Diskless Core describes in detail how data is written to and read from diskless topics. According to these KIPs, first-generation WAL segments are optimized for the initial produce phase, and have poor properties for long-term storage:
- Having many small objects instead of fewer bigger ones limits the possibility of sequential reads from the object storage. This increases the demand for parallel operations, the costs of object storage GET operation, and consume latency. It would be beneficial to merge several small (e.g. 8 MiB) recently uploaded objects into one big (e.g. 100-1000 MiB) while laying out neighbouring batches sequentially.
- The cluster may benefit from merging neighboring small batches themselves. Storing fewer distinct batches will reduce the batch metadata overhead. Data compression in batches may benefit from merging as well. This is something that the Apache Kafka permits, and is not implemented for classic topics, but would be beneficial to manage the Diskless metadata size.
- Performing topic compaction in the Kafka’s sense would require effectively rewriting batches.
- A batch may be deleted logically, but its data may still exist in the original object for the whole lifetime of the object because some other batch keeps the object alive, potentially forever. There may be a topic-level setting that specifies how sensitive is this data to be physically deleted. To satisfy this requirement, the object needs to be scanned and filtered for the dead batches, or data needs to be grouped by retention properties into multiple objects.
Proposed Changes
The desired characteristics listed in the Motivation sections are possible to achieve with object compaction. Compaction agents will run inside brokers (e.g. a dedicated thread). They ask for compaction jobs from the Batch Coordinator. Each job may be focused on one or multiple tasks:
- Merge small freshly uploaded files (including batch merging).
- Perform a partition compaction for compacted topics.
- Enforce a deletion deadline.
The compaction agent will perform the operation in the streaming manner (i.e. using as little local memory buffer as possible). Ordering batches by offsets and grouping by topic-partition in input and output files will play a key role in this. During the job, one or multiple output files will be produced. After finishing the job, the compaction agent will commit the performed changes atomically to the Batch Coordinator.
Objects uploaded by the merging stage will contain data from multiple partitions, stored together to amortize object access costs.
Heuristics
Object merging will require extensive use of heuristics to choose when and which objects to merge together. For example:
- Minimum and Maximum first-generation WAL Segment lifetime (~15 mins)
- Grouping partitions by expected expiration time bucket (~1 day)
- Maximum WAL Segment dirty ratios (50%)
- Minimum and Maximum WAL Segment lifetime (~30 days)
- Target WAL Segment size (~100MB)
These will be configurable to permit operators to tune object merging to best correspond to their workloads, while providing some reasonable defaults.
For example, in a cluster where most partitions roll their segments and upload to tiered storage after 20 minutes, an operator may wish to increase the Minimum first-generation WAL Segment lifetime to 30 minutes, to prevent merging data that will almost immediately be offloaded to tiered storage.
Public Interfaces
Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.
A public interface is any change to the following:
Binary log format
The network protocol and api behavior
Any class in the public packages under clientsConfiguration, especially client configuration
org/apache/kafka/common/serialization
org/apache/kafka/common
org/apache/kafka/common/errors
org/apache/kafka/clients/producer
org/apache/kafka/clients/consumer (eventually, once stable)
Monitoring
Command line tools and arguments
- Anything else that will likely break existing users in some way when they upgrade
Compatibility, Deprecation, and Migration Plan
- What impact (if any) will there be on existing users?
- If we are changing behavior how will we phase out the older behavior?
- If we need special migration tools, describe them here.
- When will we remove the existing behavior?
Test Plan
Describe in few sentences how the KIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?
Rejected Alternatives
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.
Separate data into per-partition segment files
This is considered out-of-scope for the Merging subsystem, because large-throughput partitions which justify the use of isolated segment files are instead handled by the Tiered Storage subsystem. This permits the Merging subsystem to optimize for only lower-volume data.