IBM/sarama: a Go Kafka client with a two-release compatibility promise
Sarama is a Go library for Apache Kafka.
At a glance
- What is it?
- Sarama is the MIT-licensed Go client for Apache Kafka maintained under the IBM organisation. It ships producers, consumers, admin APIs and mocks, and it commits to supporting only the two latest stable releases of Kafka and Go.
- Who is it for?
- Adopt Sarama when your service is written in Go and you want a Kafka client that is versioned with Go modules and offers a stated compatibility window, plus a mocks subpackage for unit tests. Do not adopt it if you need a client for a language other than Go, or if you are pinned to a Kafka release older than the two latest stable ones and cannot tolerate the two month grace period.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.
Star history
- IBM/sarama12,524 ★ · +3
| Repository | 2026-09-22 | 2026-11-14 |
|---|---|---|
| IBM/sarama | 12.5k | 12.5k |
3 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What Sarama solves, and who ends up using it
Kafka's wire protocol is not something an application team wants to implement. Sarama is a Go library that speaks that protocol, so a Go service can produce records, join a consumer group, or call admin operations without shelling out to a JVM process or depending on a broker-side component. The README describes it plainly as an MIT-licensed Go client library for Apache Kafka, and the repository layout backs that up: the top level is dense with request and response types such as acl_create_request.go, add_offsets_to_txn_request.go and alter_configs_request.go, which are protocol messages rather than application conveniences.
The audience is therefore narrow and specific. It is Go engineers building services that talk to Kafka, plus the people who maintain those services and need to test them. The README points at three places beyond the library itself: a mocks subpackage for testing, an examples directory with more elaborate applications, and a tools directory with command line utilities for testing, diagnostics and instrumentation. That last one matters more than it first appears. A client library that also ships diagnostic tooling is acknowledging that when a Kafka consumer misbehaves, the failure is often in the protocol exchange rather than in your handler function.
If you are not writing Go, nothing here applies. The library is Go source; the module path is github.com/IBM/sarama. There is no sidecar, no proxy, no language-agnostic daemon.
The protocol-level design visible in the repository tree
Sarama does not hide Kafka behind a thin abstraction. The file naming pattern at the top level is a direct mapping onto the Kafka protocol specification, which the README links as useful background. Each API area gets a request file and a response file, and each of those has a matching test file. That structure tells you where to look when a broker returns something unexpected: the decode path is a named file, not a generated blob.
Admin operations are separated out. There is admin.go, plus admin_offsets.go and admin_transactions.go, which suggests the maintainers treat offsets and transactions as distinct enough from general cluster administration to live in their own files. Transactions appear again in the examples directory as examples/txn_producer/ and examples/exactly_once/, and the top level carries the transaction protocol pieces such as add_offsets_to_txn_request.go and add_partitions_to_txn_request.go. Exactly-once semantics in Kafka depend on those transaction APIs, so the presence of a dedicated example is a reasonable signal that the path is supported rather than theoretical.
Consumer behaviour gets its own attention. Examples include examples/consumergroup/ and examples/consumer_load_aware/, the latter implying some form of load-aware consumption strategy. There is also examples/interceptors/, which points at a hook mechanism for observing or modifying client behaviour without forking the library, and examples/http_server/, which is a reminder that Sarama is a library you embed rather than a service you run.
Dependencies are modest for a client at this level. The go.mod requires a compression set (klauspost/compress, pierrec/lz4), Kerberos support (jcmturner/gokrb5 and friends), go-resiliency, go-metrics, testify and goleak. Kerberos in the list is the tell that enterprise authentication was a design target, not an afterthought.
Installing Sarama and sending a first message
Sarama is consumed as a Go module. The README directs readers to pkg.go.dev for API documentation and examples, and the module path is fixed by go.mod. Add it to an existing module with the standard tooling:
go get github.com/IBM/saramaAfter this, github.com/IBM/sarama appears in your go.mod require block. Note the minimum Go version declared in Sarama's own go.mod before you upgrade: if your project builds on an older toolchain, the module will refuse to resolve until you move forward.
The repository also carries a docker-compose.yml that builds a Kafka image from Dockerfile.kafka, parameterised by KAFKA_VERSION and SCALA_VERSION. The default KAFKA_VERSION in that file is 4.3.1 and the default SCALA_VERSION is 2.13. This is the maintainers' own functional test harness rather than a supported deployment recipe, but it is the fastest way to get a broker matching the version the library is tested against. Read the file before running it: it defines multiple profiles, including a zookeeper profile, and it depends on a toxiproxy service, so bringing it up is not a single-container affair.
Once a broker is reachable, the smallest useful program is a synchronous producer. The README does not print a full producer example inline; it defers to pkg.go.dev and the examples directory. The shape of the configuration is worth knowing before you go there, because it is where most first-run confusion comes from: check pkg.go.dev and the examples directory for how the producer is configured.
For tests, the README names the mocks subpackage as the intended route. Use it rather than standing up a broker in unit tests. The functional test target in the Makefile exists for the cases where mocks are not enough, and it is gated behind a build tag.
The compatibility guarantee is the real constraint
The most consequential sentence in the README is the compatibility policy: Sarama supports the two latest stable releases of Kafka and Go, with a two month grace period for older releases. The README adds that older Kafka releases are still likely to work. That word, likely, is doing a lot of work. It means the project will not treat a bug on an older broker as a supported regression.
This is a deliberate trade-off and it cuts both ways. On the positive side, it keeps the codebase from accumulating compatibility shims for brokers nobody runs, and it gives you a predictable answer when you ask whether a given Kafka version is in scope. On the negative side, if your organisation runs a Kafka cluster that lags the upstream release cadence, you are outside the guarantee even if the library happens to work. The two month grace period is short. A quarterly upgrade cycle can put you outside support without any change on your side.
The Go side of the same policy has a sharper edge. Sarama's go.mod declares go 1.26.0. If your build images or CI runners are older, you will find out at dependency resolution time, not at runtime, which is at least a clean failure. But it does mean that adopting Sarama couples your Go toolchain upgrade schedule to the library's, at a two-release cadence.
The retract block in go.mod is worth reading before you pin a version. It withdraws v1.32.0 for a producer hang on retry, the range v1.31.0 to v1.31.1 for a producer deadlock, v1.26.0 to v1.26.1 for consumer fetch session allocation, and v1.24.1 to v1.25.0 for consumer group metadata requests. These are the failure modes the project has publicly withdrawn versions over, and they cluster around exactly the two areas you would expect: producer retry paths and consumer group coordination. If you are debugging a hang in either area, check whether your pinned version is in that list.
Where Sarama is the wrong choice
The clearest disqualifier is language. Sarama is a Go library. If your producers are Python, Java or Rust, this project offers you nothing, and the examples and mocks are equally Go-specific.
The second is version lag. Because the compatibility guarantee covers only the two latest stable Kafka releases plus two months, a team running a long-term-support Kafka distribution with a slower upgrade path is outside the stated support window. The README's phrasing that older releases are still likely to work is honest but not a commitment. If your organisation cannot move Kafka forward on that cadence, a client whose maintainers track upstream more conservatively may be a better fit, even if it means a different programming model.
Third, if you want a client that presents Kafka as a plain queue with minimal configuration surface, Sarama's protocol-level organisation is a liability rather than a feature. The top-level files are protocol messages. That is excellent when you need to reason about what went on the wire, and unnecessary exposure when you do not.
Finally, consider the operational surface. The docker-compose.yml depends on toxiproxy and defines multiple profiles. That is a test harness built to inject network faults, which tells you the maintainers care about failure behaviour under adverse conditions. It also means that if you were hoping the repository would hand you a simple local broker, you will be reading the compose file carefully before anything starts.
How Sarama differs from franz-go and confluent-kafka-go
The two alternatives Go engineers most often weigh against Sarama are franz-go and confluent-kafka-go, and the difference is architectural rather than cosmetic.
confluent-kafka-go wraps librdkafka, the C client, through cgo. That means your build depends on a C toolchain and a shared library, and the Kafka protocol implementation lives outside your Go binary. Sarama is pure Go: the Makefile builds with CGO_ENABLED=0, and the dependency list in go.mod contains no librdkafka binding. If you ship static binaries or build in minimal containers, that distinction decides the question before any API comparison happens. The trade-off is that you inherit Sarama's protocol implementation and its release cadence rather than librdkafka's.
franz-go is also pure Go, so the cgo argument does not separate them. The difference is in API shape and in how the client exposes the protocol. Sarama's structure, visible in the request and response files at the top level, keeps the protocol messages close to the surface, and its admin, offset and transaction operations are split across separate files. Which of the two fits depends on whether you want the client to present Kafka's primitives directly or to compose them into a higher-level API. That is a judgement about your team, not a fact about the libraries, and neither README will make it for you.
One thing Sarama offers that is easy to overlook in a comparison table: the mocks subpackage. If your test strategy depends on substituting the client without a broker, that is a concrete capability to check for in whichever alternative you consider.
Maintenance, licence and upgrade cost
The repository is not archived and the last push was on 2026-10-27. Releases are frequent: v1.60.2 on 2026-08-24, v1.61.0 on 2026-09-22 and v1.61.1 on 2026-09-27. Sarama follows semantic versioning, and the README states that API stability is provided through the standard Go module version numbering scheme. In practice that means breaking changes should arrive at a major version boundary, and your go.mod will record the version you depend on.
The upgrade cost is dominated by the compatibility policy rather than by the release cadence. Every time you move Sarama forward, you are implicitly agreeing that your Kafka broker and your Go toolchain fall inside the two-latest-releases window. Budget for that as a recurring task, not a one-off. The retract entries in go.mod are the historical evidence for why pinning matters: four separate version ranges have been withdrawn, two of them for producer problems. A dependency update bot that blindly moves you to the newest tag will eventually walk you into a version the project has since retracted, so the retract block is worth reading as part of the update.
On licensing, Sarama is MIT-licensed, and the LICENSE.md file is at the repository root. MIT is permissive: it allows use in proprietary software provided the copyright notice and permission notice are retained. That is a description of the licence text, not legal advice, and if your organisation has a policy review for third-party dependencies, the MIT terms and the dependency list in go.mod are the two documents that review will want.
One maintenance signal worth noting for anyone evaluating longevity: the repository carries OpenSSF Scorecard and OpenSSF Best Practices badges in the README, and a SECURITY.md at the top level. Those indicate a project that has thought about its own supply chain, which is relevant when the library sits directly on your message path.
Editorial conclusion
Adopt Sarama when your service is written in Go and you want a Kafka client that is versioned with Go modules and offers a stated compatibility window, plus a mocks subpackage for unit tests. Do not adopt it if you need a client for a language other than Go, or if you are pinned to a Kafka release older than the two latest stable ones and cannot tolerate the two month grace period. Before committing, check the go.mod for the minimum Go version, read the retract block to see which historical versions are withdrawn, and confirm your Kafka broker version falls inside the compatibility guarantee.
Frequently asked questions
What is IBM/sarama?
It is an MIT-licensed Go client library for Apache Kafka, maintained under the IBM organisation. It provides producers, consumer groups, admin operations and transaction support, with a mocks subpackage for testing.
How does IBM/sarama compare with confluent-kafka-go?
confluent-kafka-go wraps the librdkafka C client, so builds depend on cgo and a shared library. Sarama is pure Go, and its Makefile builds with CGO_ENABLED=0, so it produces a self-contained binary. The trade-off is that you rely on Sarama's own protocol implementation and its release cadence.
How does IBM/sarama compare with franz-go?
Both are pure Go clients, so the cgo distinction does not apply. The difference is API shape: Sarama keeps Kafka protocol request and response types close to the surface in top-level files, while franz-go composes them differently. Which fits depends on how directly you want to work with Kafka's primitives.
Official sources
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.
[](https://hysenlabs.com/projects/ibm-sarama)Star history chart for your README
[](https://hysenlabs.com/projects/ibm-sarama)Was this useful?