What Is New in Apache Kafka 2.0
Kafka 2.0 delivers a solid set of incremental improvements focused on stability, performance, and developer experience. It's an evolution that builds on the robust foundation of previous versions.
| Category | Key Changes |
|---|---|
| New Features | Kafka Streams Scala API, Exactly-Once v2, KTable changes |
| Improvements | Better disk failure handling, ZooKeeper session timeouts, TLS 1.3 support |
| Bug Fixes | Numerous fixes across core, streams, and connect modules |
| Deprecations | Scala 2.11 support, Message format v0 and v1 |
What are the major Kafka Streams enhancements?
The Scala API for Kafka Streams is now officially out of preview, making it a first-class citizen alongside Java. This is a big deal for teams heavily invested in the Scala ecosystem who want full type-safety and idiomatic code.
KTable got some love with new transformation methods. You can now use KTable#transformValues and KTable#flatTransformValues with a dedicated ValueTransformerWithKey supplier. In practice, this gives you more flexibility for stateful value transformations without the verbosity of the older APIs.
How is Exactly-Once processing improved?
This release introduces the second version of the transactional/Exactly-Once producer logic. The main goal here is to reduce the overhead and latency associated with transactional writes, making EOS (Exactly-Once Semantics) more practical for a wider range of workloads.
The internal bookkeeping for transactions was reworked. This matters because it streamlines the coordinator's work, leading to better overall throughput when you have many producers committing transactions frequently.
What's better for cluster stability and operations?
Brokers now handle disk failures more gracefully. If a log directory fails, the broker will automatically go offline for that specific directory but can stay online for others mounted on different disks. This prevents a single bad disk from taking down an entire broker, which is a huge win for availability.
ZooKeeper session timeouts are now handled more intelligently. The broker will only close socket connections to ZooKeeper if the session is truly expired, reducing the chance of unnecessary cluster controller elections and the churn that comes with them.
Are there any important deprecations?
Yes, support for Scala 2.11 has been deprecated. The build still supports it for now, but the writing is on the wall. You should start planning your migration to Scala 2.12 or later.
Message format versions 0 and 1 are also officially deprecated. You should be running with at least message format v2 by now. These older formats lack modern features and optimizations, so this deprecation pushes everyone towards better performance and reliability.
FAQ
Should I upgrade my clients to 2.0 immediately?
For new projects, start with 2.0. For existing clusters, plan a rolling upgrade. The 2.0 Java client maintains compatibility with older brokers, so you can upgrade clients first. Always test in a staging environment.
Is the Scala Streams API production-ready?
Yes, the kafka-streams-scala library is now stable and fully supported. It's the recommended way to write Streams applications in Scala, replacing the previous practice of using the Java API with implicit conversions.
What's the deal with the new Exactly-Once v2?
It's an internal optimization of the transactional protocol. You don't need to change your application code. Existing Exactly-Once applications will automatically benefit from reduced latency and overhead after upgrading both brokers and clients.
How does the improved disk failure handling work?
Brokers now monitor log directories individually. If one disk fails and I/O errors occur, the broker offlines only that specific log directory, keeping partitions on other healthy disks available. This requires JBOD (Just a Bunch Of Disks) setup, not a single RAID volume.
Is TLS 1.3 supported now?
Yes, Kafka 2.0 adds support for TLS 1.3 for encrypted communication between clients and brokers and between brokers. You need to run a Java version that supports TLS 1.3 (Java 11 or later) to use this feature.