kafkars
Repository | Documentation | PyPI | Issues | Releases
Rust-based, Arrow-powered Python Kafka client for high-throughput data pipelines.
Motivation
Python's Global Interpreter Lock (GIL) and memory management create bottlenecks when consuming high-volume Kafka streams. Traditional Python Kafka clients process messages one at a time, requiring serialization/deserialization overhead for each message and limiting throughput.
kafkars solves this by:
- Rust core: All Kafka operations (polling, buffering, ordering) happen in Rust, bypassing the GIL
- Batch processing: Messages are accumulated and returned as Apache Arrow RecordBatches, not individual Python objects
- Zero-copy where possible: Arrow's columnar format enables efficient data transfer between Rust and Python
- Vectorized operations: Process thousands of messages at once with pandas, polars, or any Arrow-compatible library
This architecture is ideal for:
- Real-time analytics pipelines
- ML feature stores consuming from Kafka
- High-volume event processing
- Data lake ingestion
Important: Analytics-Focused Design
kafkars does not commit offsets. It is designed for analytics and high-throughput batch processing, not transactional workloads.
- No exactly-once semantics: Messages may be reprocessed if your application restarts
- No offset tracking: You control where to start reading via offset policies
- Stateless consumers: Each consumer instance starts fresh based on the configured policy
If you need exactly-once processing, transactional guarantees, or automatic offset management, use a traditional Kafka client like confluent-kafka-python.
Features
- Ordered delivery: Messages released in timestamp order across all partitions
- Flexible offset policies: Start from earliest, latest, or any timestamp
- Backpressure management: Automatically pauses fast partitions to prevent memory overflow
- Arrow-native output: Returns PyArrow RecordBatch for efficient downstream processing
Installation
pip install kafkars
Quick Start
from kafkars import ConsumerManager, SourceTopic
# Define source topics with offset policies
topics = [
SourceTopic.from_earliest("events"),
SourceTopic.from_relative_time("metrics", 3600_000), # 1 hour ago
]
# Create consumer
manager = ConsumerManager(
config={"bootstrap.servers": "localhost:9092"},
topics=topics,
)
# Poll returns PyArrow RecordBatch
while True:
batch = manager.poll(timeout_ms=1000)
if batch.num_rows > 0:
# Convert to pandas/polars for processing
df = batch.to_pandas()
print(f"Received {len(df)} messages")
if manager.is_live():
print("Caught up to real-time")
break
Message Schema
Each poll returns a RecordBatch with the following schema:
| Column | Type | Description |
|---|---|---|
key |
binary |
Message key (nullable) |
value |
binary |
Message payload (nullable) |
topic |
utf8 |
Source topic name |
partition |
int32 |
Partition number |
offset |
int64 |
Message offset |
timestamp |
timestamp[ms, UTC] |
Message timestamp |
Offset Policies
| Policy | Description |
|---|---|
from_earliest(topic) |
Start from the beginning |
from_latest(topic) |
Start from the end (new messages only) |
from_relative_time(topic, ms) |
Start from N milliseconds ago |
from_absolute_time(topic, ms) |
Start from specific Unix timestamp |
Documentation
Full documentation is available at kafkars.readthedocs.io.
License
Apache 2.0
Metadata
Release files for kafkars 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kafkars-0.0.7.tar.gz | 163.4 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| kafkars-0.0.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.14 | CPython 3.14 free-threading | Linux glibc 2.17+ x86-64 | Details |
| kafkars-0.0.7-cp314-cp314t-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 free-threading | macOS 11.0+ ARM64 | Details |
| kafkars-0.0.7-cp314-cp314t-macosx_10_12_x86_64.whl | CPython 3.14 | CPython 3.14 free-threading | macOS 10.12+ x86-64 | Details |
| kafkars-0.0.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| kafkars-0.0.7-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| kafkars-0.0.7-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 7.0 MB
Release files / kafkars-0.0.7.tar.gz
| Download URL | kafkars-0.0.7.tar.gz |
|---|---|
| Size | 163.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9260d95e8664be4f5f24771aa9762dcc8ab124749734ce2d7b9b88cdec7fe6a
|
|
BLAKE2b-256 checksum How to use checksums |
856527934d168f65065b0e4d54df7b63076910079aed03b1d36eebd6c984484f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | kafkars-0.0.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ec453bbff262a5b80ed8513449887609d89a85d4c7c35f1b88f656ffc726a072
|
|
BLAKE2b-256 checksum How to use checksums |
ca2a2c7eb97ac4a66d61435535ec1bc774a013171f3ce038467906db397d737d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | kafkars-0.0.7-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
89bdc2f9a70a7dc6e6578f9897e4bd7bbd82abb70c66a2fa8886a1b6fef37509
|
|
BLAKE2b-256 checksum How to use checksums |
ced40e5c3b1a025743bbdb9e30fd64183616724f0a1c8ddf61bfcca828dd6fd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | kafkars-0.0.7-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 551.4 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
fde1ae761085ba301566402a76a5243fcf6fd6f224808b49c1e42c6fbff5e7cf
|
|
BLAKE2b-256 checksum How to use checksums |
f38d731e6be465edf982432bb27f5ecb5f2a1cbdfc73399994c62aaea66b9697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | kafkars-0.0.7-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
924dcd6ecb75f11de3fd8c739de7d88b919d5d71d8b6f7f85db788e3c35848a1
|
|
BLAKE2b-256 checksum How to use checksums |
37ae9473a8808d7ff465f439809040d51cbe8e73bbdefe746c6784dddd70737a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | kafkars-0.0.7-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
894b03e4d81ebdd4f6fe3e51ed4616ed199231051b0aa6c2d2737017ca062c34
|
|
BLAKE2b-256 checksum How to use checksums |
e895eb5cc8be288d4ff0ea24ae81e769ef43527f808e6f0f3815ff12eb63e11f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / kafkars-0.0.7-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | kafkars-0.0.7-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 552.7 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2acd4aa71c7b7ffb8653806b828aed639c432faf7a5ca3ee109e51af084835d7
|
|
BLAKE2b-256 checksum How to use checksums |
cb8d259f6f40f1420cdd6005a336e80e25ef0c621a88e84b7b9d610133720693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log