Library / SDK
karafka/karafka avatar
karafka/karafka

Karafka: a Kafka consumer framework that treats Rails as a first-class citizen

Ruby and Rails efficient Kafka processing framework

2,252 stars187 forksRubyNOASSERTION

At a glance

What is it?
Threads rather than processes, librdkafka under the hood, and a commercial edition that gates several operational features rather than the core.
Who is it for?
Karafka is the right shape of answer if your team writes Ruby and already runs Rails, because the parts that are usually awkward, running a long-lived consumer alongside a web app and wiring it into ActiveJob, are the parts it has already solved. What you accept is an LGPL core with a commercial edition sitting next to it, so virtual partitions, long-running jobs, granular backoffs and priority support are not in the free version.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 11, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Threads inside one process, not a fleet of processes

The framework's central claim is architectural and worth stating precisely: Karafka uses threads to handle many messages simultaneously in the same process. That distinguishes it from consumer designs that fork worker processes per partition, and it changes the memory profile, the deployment story and how code reloading has to work.

The consequences run through the feature list. Parallel processing happens in threads, and it also works for a single topic partition, which the README links to a Pro feature called virtual partitions. Multi-process scaling exists too, as a separate swarm mode, so the thread model is a default rather than a limit.

Underneath is librdkafka, the Apache Kafka C and C++ client library. Using the native client rather than a pure-Ruby implementation is the reason throughput numbers tend to hold up, and it also means native extension compilation is part of installation.

Rails is optional. The README says Karafka does not require Rails but integrates tightly with any Rails application, which is the correct framing for something that also runs standalone.

Routes, consumers and a one-minute round trip

The whole programming model is two objects: a route that binds a topic to a consumer class, and a consumer that receives messages.

ruby
# Define what topics you want to consume with which consumers in karafka.rb
Karafka::App.routes.draw do
  topic 'system_events' do
    consumer EventsConsumer
  end
end

The consumer then handles whatever arrives, and the README's example leans on `ActiveRecord#insert_all` with Karafka batch processing to store incoming events.

The quick start is genuinely quick. Install the gem and run the installer:

bash
# Make sure to install Karafka 2.6
bundle add karafka --version ">= 2.6.0"

bundle exec karafka install

Then produce a message and start the server:

ruby
Karafka.producer.produce_sync(topic: 'example', payload: { 'ping' => 'pong' }.to_json)
bash
bundle exec karafka server

[86d47f0b92f7] Polled 1 message in 1000ms
[3732873c8a74] Consume job for ExampleConsumer on example started
{"ping"=>"pong"}
[3732873c8a74] Consume job for ExampleConsumer on example finished in 0ms

That console output is the whole feedback loop, and seeing a message you produced come back through a consumer is the fastest way to understand the model.

Dead letter queue, ActiveJob and code reloading

Three features separate this from a bare consumer library.

The dead letter queue is built in rather than something you assemble from retry topics. The README calls it seamless, and in practice that means a consumer that raises does not silently drop the message; it moves somewhere you can inspect and replay.

ActiveJob support means Kafka can act as the backend for background jobs in a Rails app, including ordered jobs, which the README attributes to the Pro tier. That is a different kind of integration from consuming events, because it lets existing ActiveJob code publish to Kafka without changing its interface.

Code reloading in development is supported and flagged as in-development, which is a sensible caveat for a feature that depends on how your Rails app boots. The repository carries a `.console_irbrc` and a `config/` directory, and the tree includes `docker-compose.yml` alongside a `docker-compose.multi-broker.yml`, so both single-broker and multi-broker local setups are handled.

Where the open core line falls

The licensing arrangement is stated in the README without much fuss. Karafka ships under LGPL, and the author also sells a Karafka Pro subscription with a commercial-friendly license, priority support, architecture consultations, an enhanced web UI and features described as high throughput data processing related: virtual partitions, long-running jobs and more.

The release notes make the split concrete. v2.6.0 notes that per-topic overriding of pause settings remains a Pro feature, while in the OSS version `topic.pause` simply reflects the global `config.pause.*` settings. v2.6.1 added envelope encryption for messages at rest as a Pro feature.

Monitoring spans both tiers: AppSignal, StatsD and DataDog, plus New Relic, with dashboard templates for AppSignal and DataDog. There is a built-in web UI for monitoring and managing applications, with the Pro edition described as enhanced.

The GitHub license field reads `NOASSERTION`, but the tree contains three license files: `LICENSE`, `LICENSE-COMM` and `LICENSE-LGPL`. Read them rather than relying on the API metadata, since the split between them is the whole point of the commercial model.

Configuration churn is the thing to watch

v2.6.0, published 2026-08-05, is a breaking release and the upgrade notes are detailed enough to be worth reading. The flat global pause accessors `config.pause_timeout`, `config.pause_max_timeout` and `config.pause_with_exponential_backoff`, deprecated back in 2.5.2, were removed in favour of a nested `config.pause.*` namespace. The same happened per topic: `topic.pause_timeout` and friends became `topic.pause.timeout`, and `topic.to_h` now emits a nested `pause:` hash.

v2.6.1, published 2026-08-24, added an opt-in envelope encryption mode that works around a real ceiling: direct RSA encryption limits payloads to roughly 245 bytes with 2048-bit keys. Envelope mode wraps a one-time AES-256-GCM key with RSA instead, so message size is no longer bounded by the key. Older consumers cannot decrypt envelope payloads, so the release note is explicit that you must upgrade all consuming processes before enabling it. Both formats are recognised on read, which makes the switch reversible.

That release also mentions key material being parsed at setup, and the note pre-empts the obvious worry by saying no new boot failure modes are introduced because configuration has always been validated at boot.

The repository was pushed to on 2026-09-28, with 81 open issues.

Editorial conclusion

Karafka is the right shape of answer if your team writes Ruby and already runs Rails, because the parts that are usually awkward, running a long-lived consumer alongside a web app and wiring it into ActiveJob, are the parts it has already solved. What you accept is an LGPL core with a commercial edition sitting next to it, so virtual partitions, long-running jobs, granular backoffs and priority support are not in the free version. Read the upgrade notes before you pin a version: 2.6.0 broke the flat pause configuration accessors in favour of nested namespaces, and 2.6.1 added an opt-in encryption mode that changes the rollout order you need. Start with the bundled example apps rather than the README, since the framework's assumptions show up faster in running code than in prose.

Frequently asked questions

Does Karafka require Ruby on Rails?

No. Karafka is a standalone Ruby framework that will integrate tightly with a Rails application if you use one. It ships an ActiveJob backend, so Kafka can carry background jobs, but the routing and consumer model works in plain Ruby.

What is Karafka built on top of?

librdkafka, the Apache Kafka C and C++ client library. That choice is why installation involves compiling a native extension, and it is the main reason throughput tends to hold up compared with pure-Ruby Kafka clients.

Is there a dead letter queue in the free version?

Yes, the README lists dead letter queue functionality as built in rather than something you assemble yourself. It is listed among the open-source capabilities, while virtual partitions, long-running jobs and granular per-topic backoff overrides are described as Pro features.

What changed in Karafka 2.6 and how should I upgrade?

Version 2.6.0 was breaking: flat pause settings like `config.pause_timeout` and `topic.pause_timeout` were removed in favour of nested `config.pause.*` and `topic.pause.*` namespaces. Then 2.6.1 added an opt-in envelope encryption mode for messages at rest. Because older consumers cannot read envelope payloads, upgrade every consuming process before you turn it on.

Official sources

  1. Issues
  2. karafka/karafka on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/karafka-karafka.svg)](https://hysenlabs.com/projects/karafka-karafka)