---
title: "Writing High-Performance Clients for Tigerbeetle"
description: "TigerBeetle builds every language client as a thin wrapper over a single Zig client library, tb_client, exposed through FFI."
url: "https://swe.quest/articles/writing-high-performance-clients-for-tigerbeetle-359130491cf9dbd8"
canonical: "https://tigerbeetle.com/blog/2023-02-21-writing-high-performance-clients-for-tigerbeetle"
source: "TigerBeetle"
published: "2023-02-21"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 6
tags: ["zig","api-design","performance","jvm","memory-management"]
---

# Writing High-Performance Clients for Tigerbeetle

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2023-02-21, 6 min read, Deep dive. Original: [https://tigerbeetle.com/blog/2023-02-21-writing-high-performance-clients-for-tigerbeetle](https://tigerbeetle.com/blog/2023-02-21-writing-high-performance-clients-for-tigerbeetle)

## Summary

TigerBeetle builds every language client as a thin wrapper over a single Zig client library, tb\_client, exposed through FFI. This avoids reimplementing the VSR protocol, io\_uring and static allocation in each language. Zero-deserialization works directly with Go and C# structs. Java instead uses a ByteBuffer-backed Batch object so JNI can read contiguous memory without per-object copying or GC pressure. tb\_client runs a dedicated thread with completion callbacks, which each binding wraps in its own concurrency idiom: goroutines, async/await and CompletableFuture. A client-side benchmark of 1M rejected transfers shows near-native throughput (Zig 1.56M/s, C# 1.52M/s, Go 1.47M/s, Java 1.27M/s). Zig's cross-compilation offsets the cost of per-platform builds.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Zig](https://swe.quest/tags/zig.md) (Languages)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)

## Prerequisites

- FFI basics
- memory layout of structs
- async/callback concurrency ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))

## Keywords

TigerBeetle, tb\_client, JNI, Viewstamped Replication, CGO, P/Invoke, N-API, ByteBuffer

## Related posts

- [A Database Without Dynamic Memory Allocation](https://swe.quest/articles/a-database-without-dynamic-memory-allocation-4be7684fa723cb5d.md): TigerBeetle · 2022-10-12 · Medium · 6 min read · Memory management, Zig, Databases, Storage engines, Testing
  TigerBeetle allocates all memory once at startup and never again, using fixed limits for connections, in-flight messages per client, replicas, message size and queries per message so that total memory is a simple compile-time sum.
- [We Put a Distributed Database In the Browser – And Made a Game of It!](https://swe.quest/articles/we-put-a-distributed-database-in-the-browser-and-made-a-game-of-it-0b24aa4c3e59c84b.md): TigerBeetle · 2023-07-11 · Easy · 5 min read · Formal methods, Consensus, Testing, WebAssembly, Zig
  TigerBeetle's deterministic simulator, the VOPR, is compiled to WebAssembly via Zig and wrapped in a playable browser game that runs real TigerBeetle replicas across three levels.
- [Enum of Arrays](https://swe.quest/articles/enum-of-arrays-39cf1c2fe738e424.md): TigerBeetle · 2024-12-19 · Medium · 3 min read · Performance engineering, Data structures, Zig, Hardware
  Struct-of-Arrays has a dual for tagged unions: an Enum of Arrays, where one tag covers a whole batch of homogeneous payloads instead of each element carrying its own tag.
- [Bun v0.1.9](https://swe.quest/articles/bun-v0-1-9-4ecfe167e5b29929.md): Bun · 2022-08-18 · Medium · 3 min read · Runtimes & VMs, JavaScript, Zig, Performance engineering, Compilers
  Bun v0.1.9 starts using JavaScriptCore's DOMJIT API to JIT-optimize native functions, making \`ptr()\` in \`bun:ffi\` 6-10x faster and \`TextEncoder.encodeInto\` 1.5-5x faster.
- [Synadia and TigerBeetle Pledge $512,000 to the Zig Software Foundation](https://swe.quest/articles/synadia-and-tigerbeetle-pledge-512-000-to-the-zig-software-foundation-124e30142ae18e3c.md): TigerBeetle · 2025-10-25 · Easy · 8 min read · Zig, Language design, Memory safety, Open source
  Synadia and TigerBeetle are jointly donating $512,000 to the Zig Software Foundation over two years, with no strings attached.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
