# kesh

> An in-memory store that speaks the Redis protocol (RESP2), built as one Kotlin/Native linuxX64 binary, so redis-cli and ordinary Redis clients work against it unchanged. Every command it has is held byte for byte to Redis 7.2 by a differential harness.

Page: https://kotlin.website/kesh

## Why it exists

[kesh](https://github.com/youndie/kesh) is an answer to a narrow question: how much of Redis can a
single Kotlin/Native binary carry, and at what cost, if the only acceptable definition of "works" is
*the same bytes Redis would have sent*. It speaks RESP2 over TCP, so `redis-cli` and the client
library you already use talk to it unchanged, and every command it has runs through a differential
harness against Redis 7.2 — a change to a reply is accepted when the harness ends with "all agree".

One thread reads, executes and writes, on kesh's own `epoll` loop. The research in the repository
says why, and the throughput numbers below say what that costs.

## What you get

- **RESP2 over TCP** — pipelining and inline commands, one shared password, Redis's request limits.
- **Strings, hashes, lists, sets and sorted sets** with their core commands; keys, `SCAN` and its
  family; per-key expiry, both lazy and active.
- **`maxmemory`** with Redis's eviction policies, LFU excepted — and a `maxmemory` the container's
  memory limit cannot hold is refused at start-up.
- **Snapshots** in kesh's own format: `SAVE`, `BGSAVE` through `fork`, loaded before the listener
  binds.
- **Pub/Sub** — `PUBLISH`, `SUBSCRIBE`, `PSUBSCRIBE` in RESP2 subscribe mode.
- **Operations** — `INFO`, HTTP health probes, Prometheus metrics including the collector's pauses, a
  container image, a Helm chart sized from measurements, and an ordered stop.

## How fast

At a sixteenth of the reference dataset on a two-host stand, 50 connections:

| | kesh | Redis 7.2, same host |
|---|---|---|
| pipeline 1 | 14 249–14 683 ops/s, p99 8–9 ms | 14 640–15 126 ops/s, p99 7 ms |
| pipeline 16 | 77 467–79 637 ops/s | 134 932–135 763 ops/s |

At pipeline 16 the limit is the one thread that runs every command. Over 24 hours of the same mix at
an eighth of the dataset, with TTL churn, it ran without an error and held resident memory flat at
2.5 GiB for the last fourteen hours; the collector's stop-the-world pause averaged about 1 ms.

## Run

The image is published to GHCR on every push to `main`, as `main` and as `sha-<commit>`:

```bash
docker run -d -p 6379:6379 ghcr.io/youndie/kesh:main
redis-cli -p 6379 PING
```

Or build it — the target is `linuxX64` only:

```bash
./gradlew :server:linkReleaseExecutableLinuxX64
KESH_PORT=6379 server/build/bin/linuxX64/releaseExecutable/kesh.kexe
```

Configuration is environment variables, `KESH_*`. The chart is in `deploy/chart`.

## What it will deliberately not do

Cluster mode, replication, Sentinel; RESP3; transactions, Lua, modules, blocking commands, ACL users
beyond one password; Redis's RDB and AOF file formats; `SHUTDOWN`, `TIME`, `MEMORY USAGE`, `DEBUG`.

## Limitations

- **Measured up to an eighth of the reference dataset**, on machines that are not reference hosts.
  Full scale is arithmetic, not a measurement.
- **No release is published.** v1 is built and every backlog item is closed; the image tracks `main`.
- Linux x86-64 only.

Redis is a trademark of Redis Ltd. kesh is not affiliated with, endorsed by, or sponsored by Redis Ltd.
