Klife is a high-performance Kafka client built from the ground up with minimal dependencies. Currently, Klife supports producer functionality, with plans to add consumer features in the future.
To achieve high batch efficiency and ensure compatibility with evolving protocol versions, Klife leverages Klife Protocol. This efficiency allows Klife to deliver exceptional performance, with throughput improvements of up to 15x over other community Kafka clients in some scenarios.
Currently, Klife provides producer functionality, with plans to expand into consumer features as the project develops. Key features include:
- Efficient Batching: Batches data to the same broker in a single TCP request per producer.
- Minimal Resource Usage: Only one connection per broker for each client, optimizing resource usage.
- Exactly Once Semantics (EOS): Providing safe retries with idempotency on the protocol level.
- Synchronous and Asynchronous Produce Options: Synchronous produces return the offset, while asynchronous produces support callbacks.
- Batch Produce API: Allows batching for multiple topics and partitions.
- Automatic Cluster and Metadata Management: Automatically adapts to changes in cluster topology and metadata.
- Testing Utilities: Includes helper functions for testing against a real broker without complex mocking.
- Simple Configuration: Streamlined setup for straightforward use.
- Comprehensive Documentation: Includes examples and explanations of trade-offs.
- Custom Partitioner per Topic: Configurable partitioning for each topic.
- Transactional Support: Supports transactions in an Ecto-like style.
- SASL Authentication: Currently supports plain authentication.
- Protocol Compatibility: Supports recent protocol versions, with forward compatibility in mind.
def deps do
[
{:klife, "~> 0.1.0"}
]
end
defmodule MyApp.Client do
use Klife.Client, otp_app: :my_app
end
config :my_app, MyApp.Client,
connection: [
bootstrap_servers: ["localhost:19092", "localhost:29092"],
ssl: false
]
children = [ MyApp.Client ]
opts = [strategy: :one_for_one, name: Example.Supervisor]
Supervisor.start_link(children, opts)
my_rec = %Klife.Record{value: "my_val_1", topic: "my_topic_1"}
{:ok, %Klife.Record} = MyApp.Client.produce(my_rec)
Checkout the Klife.Client
docs for more details