HUB
Sign inSign up

sbansal793/thunderstrike

By sbansal793

•Updated 10 days ago

Key-value database server: TLS 1.3, encrypted at rest, io_uring. Proprietary, free to run.

Image
Databases & storage
1

1.1K

sbansal793/thunderstrike repository overview

⁠thunderstrike

Thunder is a self-hosted key-value database, distributed as thunderstrike. It serves requests over TLS 1.3 and encrypts stored values and write-ahead journal records with AES-256-GCM. A 512 MiB value needs a 4 GiB arena per reactor.

thunderstrike is proprietary software of SHORTSQUEEZE PRIVATE LIMITED, free to download and run. See License below.

⁠Tags

TagPlatformsRuns on
0.1.6, latestlinux/amd64, linux/arm64x86-64-v3 with RDRAND, or ARMv8.2 with LSE, AES and PMULL
0.1.6-v4linux/amd64x86-64-v4 with AVX-512 and RDRAND

The commands below pin docker.io/sbansal793/thunderstrike:0.1.6. Docker selects the build for your architecture. On macOS and Windows the server runs in Docker Desktop's Linux VM.

⁠Quick start

Use a POSIX shell with OpenSSL and Docker Compose v2 or newer. On Windows, run the commands in WSL. Check the Docker host's kernel with docker info --format '{{.KernelVersion}}'. It must be Linux 6.8 or newer. For the default configuration, allocate at least two physical cores and 4 GiB for locked arenas, plus memory for the rest of the server and OS. On Docker Desktop these resources must be available inside the Linux VM.

1. Get the kit. The image writes its compose file, settings, seccomp profile, guide and license into an empty directory:

mkdir thunderstrike && cd thunderstrike
docker run --rm -v "$PWD:/out" docker.io/sbansal793/thunderstrike:0.1.6 kit /out

2. Configure the deployment. Copy the release settings.

cp .env.example .env

Edit .env before continuing. The kit already sets THUNDERSTRIKE_IMAGE to the release tag. Set THUNDERSTRIKE_CORES to your physical-core budget and THUNDERSTRIKE_TLS_PORT to the starting port. If clients connect remotely, include their server DNS name in THUNDERSTRIKE_TLS_NAMES and keep localhost for the sample client. Generate the port mapping on the Docker host where the server will run.

docker compose -f compose.yaml run --rm configure

This writes compose.override.yaml. Use plain docker compose for the remaining steps so Compose loads the generated ports.

3. The keystore passphrase. The server will not start without it, and losing it, or the data volume, loses every value. Keep a copy with your backups.

mkdir -p docker/secrets docker/tls
(umask 077 && set -C && openssl rand -base64 32 > docker/secrets/passphrase)

4. TLS. Clients trust a CA, and the server presents a certificate that CA issued. This makes both in docker/tls/: a CA (ca.crt for clients, ca.key to keep secret), and the server's certificate for the names in THUNDERSTRIKE_TLS_NAMES (default localhost). To renew the certificate, delete server.crt and server.key and run it again: the CA stays, so clients change nothing. An Ed25519 CA of your own works too; put it there as ca.crt and ca.key first.

docker compose run --rm tls-init

5. Start it, and wait for healthy:

docker compose up -d thunderstrike
docker compose ps

The container reports healthy once recovery finishes and every reactor is listening. Check docker compose logs thunderstrike for startup errors.

6. Check it. The sample client writes values of 256 B to 16 MiB on 8 connections for 30 seconds, reads every one back, compares them byte for byte, and exits 0 only with no error and no mismatch:

docker compose run --rm sample

The kit's README.md is the full guide: every setting, TLS, cores and ports, durability, large values, backups, upgrades and troubleshooting.

⁠The compose file

This is the kit's base compose.yaml. The copied .env selects docker.io/sbansal793/thunderstrike:0.1.6 for all four services. Run it from the kit directory so Compose can find the seccomp profile and the generated port mapping.

# thunderstrike under Docker Compose. README.md (the guide) explains every
# setting here.
#
# First time:
#   cp .env.example .env                                  # then edit it
#   docker compose -f compose.yaml run --rm configure       # derives reactor ports from CPU topology
#   mkdir -p docker/secrets && openssl rand -base64 32 > docker/secrets/passphrase
#   docker compose run --rm tls-init                      # a CA and the server's certificate in docker/tls/
#   docker compose up -d
#   docker compose run --rm sample                        # a client that writes, reads back, verifies
#
# Every path and size comes from the environment or .env (.env.example lists
# them all). Sizes are plain byte counts.
name: thunderstrike

services:
  thunderstrike:
    image: ${THUNDERSTRIKE_IMAGE:-thunderstrike:latest}
    environment:
      # Inside the container the secrets below are files under /run/secrets;
      # these name them. The host files they come from are set with the
      # THUNDERSTRIKE_HOST_* variables (bottom of this file).
      THUNDERSTRIKE_PASSPHRASE_FILE: /run/secrets/thunderstrike_passphrase
      THUNDERSTRIKE_TLS_CERT: /run/secrets/thunderstrike_tls_cert
      THUNDERSTRIKE_TLS_KEY: /run/secrets/thunderstrike_tls_key
      # Physical-core budget, an even integer at least 2. Actual CPU
      # topology determines reactor/helper pairs. Logical shards stay 1024.
      THUNDERSTRIKE_CORES: ${THUNDERSTRIKE_CORES:-2}
      # One starting port; the remaining reactor ports are derived.
      THUNDERSTRIKE_TLS_PORT: ${THUNDERSTRIKE_TLS_PORT:-7380}
      # configure writes the matching signature and ports into the
      # automatically loaded compose.override.yaml. A stale mapping refuses.
      THUNDERSTRIKE_PORT_LAYOUT: unconfigured
      # Per reactor, locked in memory. Must hold two copies of the largest value
      # one SET writes: 4294967296 (4 GiB) for 512 MiB values.
      # Empty: 4 GiB for one reactor, 2 GiB each for two or more.
      THUNDERSTRIKE_ARENA_BYTES: ${THUNDERSTRIKE_ARENA_BYTES:-}
    secrets:
      - thunderstrike_passphrase
      - thunderstrike_tls_cert
      - thunderstrike_tls_key
    # configure generates the exact host/container mapping from CORES,
    # CPU topology and TLS_PORT; users never calculate a range.
    ports: []
    volumes:
      # The database: shard files and the keystore. A named volume (default)
      # or a host directory: THUNDERSTRIKE_HOST_DATA=/srv/thunderstrike.
      # Back it up together with the passphrase.
      - ${THUNDERSTRIKE_HOST_DATA:-data}:/var/lib/thunderstrike
    ulimits:
      # The arena is locked in memory; the server refuses to start when the
      # limit cannot hold the arena bytes x the derived reactor count.
      memlock: -1
    security_opt:
      # The server does all its disk and network I/O through io_uring, which
      # Docker's default seccomp profile refuses. This profile is Docker's
      # default plus the three io_uring calls.
      - seccomp=docker/seccomp-io_uring.json
    # SIGTERM drains in-flight requests and checkpoints the index; do not let
    # Docker SIGKILL it after the default 10 s.
    stop_grace_period: 2m
    restart: unless-stopped

  # Derive the Docker mapping on the same Docker host as the server.
  # Run again after changing CORES, TLS_PORT or the available CPU topology.
  configure:
    profiles: ["init"]
    image: ${THUNDERSTRIKE_IMAGE:-thunderstrike:latest}
    environment:
      THUNDERSTRIKE_CORES: ${THUNDERSTRIKE_CORES:-2}
      THUNDERSTRIKE_TLS_PORT: ${THUNDERSTRIKE_TLS_PORT:-7380}
    volumes:
      - .:/out
    command: ["configure", "/out/compose.override.yaml"]

  # One-shot TLS setup in THUNDERSTRIKE_HOST_TLS_DIR. Clients trust a CA and
  # the server presents a certificate that CA issued. The first run makes the
  # CA: ca.crt, which clients trust, and ca.key, which signs and stays here.
  # Then it issues server.crt and server.key for THUNDERSTRIKE_TLS_NAMES
  # (separated by spaces or commas); clients connect by one of the names. It
  # does nothing while server.crt or server.key exists: delete both and run
  # it again to renew, and the same CA issues the new one. An Ed25519 CA of
  # your own works too: put it here as ca.crt and ca.key first.
  tls-init:
    profiles: ["init"]
    image: ${THUNDERSTRIKE_IMAGE:-thunderstrike:latest}
    environment:
      THUNDERSTRIKE_TLS_NAMES: ${THUNDERSTRIKE_TLS_NAMES:-localhost}
    volumes:
      - ${THUNDERSTRIKE_HOST_TLS_DIR:-./docker/tls}:/out
    command: ["tls-init", "/out"]

  # A sample client: thunderstrike-soak writes values of five sizes on 8
  # connections for 30 s, reads every one back and compares it byte for
  # byte. It exits 0 only with no mismatch and no error. It trusts ca.crt
  # and verifies the server's name as "localhost", so keep localhost in
  # THUNDERSTRIKE_TLS_NAMES to run it.
  sample:
    profiles: ["sample"]
    image: ${THUNDERSTRIKE_IMAGE:-thunderstrike:latest}
    depends_on:
      thunderstrike:
        condition: service_healthy
    volumes:
      - ${THUNDERSTRIKE_HOST_TLS_DIR:-./docker/tls}/ca.crt:/certs/ca.crt:ro
    command:
      - thunderstrike-soak
      - -host
      - thunderstrike
      - -tls-port
      - "${THUNDERSTRIKE_TLS_PORT:-7380}"
      # The shard count and the cores from the server's DISCOVER table.
      - -layout
      - server
      - -ca
      - /certs/ca.crt
      - -conns
      - "8"
      - -pipeline
      - "4"
      - -live
      - "40"
      - -sizes
      - "256:30,4k:30,64k:20,2m:15,16m:5"
      - -duration
      - 30s

volumes:
  data:

secrets:
  thunderstrike_passphrase:
    file: ${THUNDERSTRIKE_HOST_PASSPHRASE:-./docker/secrets/passphrase}
  thunderstrike_tls_cert:
    file: ${THUNDERSTRIKE_HOST_TLS_DIR:-./docker/tls}/server.crt
  thunderstrike_tls_key:
    file: ${THUNDERSTRIKE_HOST_TLS_DIR:-./docker/tls}/server.key

⁠Settings

Set these in .env. Enter sizes in bytes, for example 4294967296 for 4 GiB.

VariableDefaultPurpose
THUNDERSTRIKE_IMAGEdocker.io/sbansal793/thunderstrike:0.1.6 in the kit's .env.exampleImage to use for the server, configure job, TLS setup and sample.
THUNDERSTRIKE_CORES2Physical-core budget, even and from 2 through 1,024. Must fit the available CPU set/capacity. CPU topology determines reactor/helper pairs.
THUNDERSTRIKE_TLS_PORT7380One starting port. Configure generates the remaining reactor ports and Docker mapping.
THUNDERSTRIKE_ARENA_BYTESautomaticLocked memory per reactor: 4 GiB with one reactor, 2 GiB each otherwise. Use 4294967296 for 512 MiB values.
THUNDERSTRIKE_TLS_NAMESlocalhostThe DNS names tls-init issues the certificate for. Clients connect by one of them.
THUNDERSTRIKE_HOST_DATAdataThe named volume thunderstrike_data, or a host path to bind-mount instead.
THUNDERSTRIKE_HOST_PASSPHRASE./docker/secrets/passphraseHost file holding the keystore passphrase.
THUNDERSTRIKE_HOST_TLS_DIR./docker/tlsHost directory for the CA and server certificate and keys.

The server grows the value files as data arrives and releases unused space. When upgrading an older configuration, remove THUNDERSTRIKE_BLOB_PREALLOC_BYTES. The current kit handles allocation automatically.

Logical shards are fixed internally at exactly 1,024. Users set the physical-core budget and one starting port. A stored count other than 1,024 is refused; migrate the data rather than editing its count record.

Each reactor group uses two hardware threads (logical CPUs): one for the foreground reactor and one shared by background workers. On a CPU with two usable hardware threads per physical core, 8 physical cores make 8 reactors. With one hardware thread per core, they make 4 reactors. Actual SMT siblings are detected even when their CPU IDs are not adjacent. CPU affinity and quotas are respected; an allocation exceeding them refuses.

Physical cores (CORES)Usable hardware threads per coreDerived reactorsLogical shards per reactorGenerated ports from 7380
2111,0247380
2225127380-7381
8142567380-7383
8281287380-7387

For R derived reactors, each owns floor(1024 / R) logical shards; the first 1024 % R reactors get one extra. Mixed or restricted CPU sets use complete sibling pairs first and then pair remaining single hardware threads. An unpaired thread is left unused and reported. Reactor counts may be odd even though the physical-core budget is even.

Software threads are separate from hardware threads: each reactor group normally starts one reactor, seven maintenance workers and eight journal workers, with additional sync fan-out and kernel workers as needed.

Before changing the core budget or starting port, stop the server with docker compose stop thunderstrike. Edit .env, run docker compose -f compose.yaml run --rm configure, then run docker compose up -d thunderstrike. Regenerate the mapping if the available CPUs change. After a crash, recover with the previous reactor count and stop cleanly before changing it.

⁠Durability

The server flushes each write's journal record to storage before acknowledging it. Recovery replays the journal after a crash or power loss. This requires storage that honors flushes. An orderly docker compose stop thunderstrike drains requests and checkpoints the database.

⁠Connecting clients

Official client libraries, all over the same compiled core: one address in, the client asks the server for its layout and connects to every reactor's port itself. Source, docs and releases: github.com/TheManhattanProject/thunderstrike-client⁠

LanguageInstall
Pythonpip install thunderstrike (PyPI⁠)
Node.jsnpm install @shortsqueeze/thunderstrike (npm⁠)
Gogo get github.com/TheManhattanProject/thunderstrike-client/[email protected]
Rustcargo add thunderstrike (crates.io⁠)
.NETdotnet add package Thunderstrike (NuGet⁠)
Javaio.github.maverick-ai:thunderstrike-client:0.1.3 with JDK 22+ (Maven Central⁠)
PHPEnable FFI, run composer require themanhattanproject/thunderstrike-client, then run vendor/bin/thunderstrike-install. Packagist⁠
C / C++header and libraries from the releases⁠

Client libraries have their own release numbers. The 0.1.3 clients support Linux x86-64 and ARM64, Windows x86-64, and macOS on Intel and Apple Silicon.

Clients trust docker/tls/ca.crt and connect by a name the server's certificate carries (localhost unless you set THUNDERSTRIKE_TLS_NAMES). After the quick start above, from the same directory:

from thunderstrike import Thunderstrike

db = Thunderstrike("127.0.0.1:7380",
                   tls_server_name="localhost",
                   tls_ca_pem=open("docker/tls/ca.crt").read())
db.set(b"user:1", b"ada")
print(db.get(b"user:1"))   # b"ada", or None on a miss

Every language's version of this is in the client README⁠. A client connects to every core's port on the same host it was given, so publish each port on the same number on both sides.

The application supplies one bootstrap address. With the defaults, localhost:7380 is enough for a local client to fetch DISCOVER: 1,024 logical shards and the derived reactor ports. With two reactors, shards 0-511 are on 7380 and 512-1023 on 7381. With one, all are on 7380. The client computes CRC32C(key) % 1024, finds that shard's entry in the returned table, and sends the request on a connection to its reactor's port. The application does not select ports for individual requests. Logical shards have no individual listening ports. The server persists the layout epoch and advances it when reactor ownership or ports change, so clients can identify a new routing map.

⁠Without Compose

Extract the kit, edit .env and create the passphrase as above. These commands use the default host paths. Use the same CPU allocation for the ports command and the server.

docker volume create thunderstrike_data
docker run --rm --env-file .env -v "$PWD/docker/tls:/out" docker.io/sbansal793/thunderstrike:0.1.6 tls-init /out
published_ports=$(docker run --rm --env-file .env docker.io/sbansal793/thunderstrike:0.1.6 ports)
docker run -d --name thunderstrike \
  --env-file .env \
  --ulimit memlock=-1 \
  --security-opt seccomp=docker/seccomp-io_uring.json \
  --stop-timeout 120 \
  -p "$published_ports" \
  -v thunderstrike_data:/var/lib/thunderstrike \
  -v "$PWD/docker/secrets/passphrase:/run/secrets/passphrase:ro" \
  -v "$PWD/docker/tls/server.crt:/run/tls/server.crt:ro" \
  -v "$PWD/docker/tls/server.key:/run/tls/server.key:ro" \
  -e THUNDERSTRIKE_PASSPHRASE_FILE=/run/secrets/passphrase \
  -e THUNDERSTRIKE_TLS_CERT=/run/tls/server.crt \
  -e THUNDERSTRIKE_TLS_KEY=/run/tls/server.key \
  docker.io/sbansal793/thunderstrike:0.1.6

The seccomp profile is required: the server cannot run without io_uring, which Docker's default profile refuses. --ulimit memlock=-1 is required because the arena is locked in memory.

⁠Data and backups

The database and keystore live at /var/lib/thunderstrike. The following backup uses the Compose container's actual data mount, including a custom named volume or bind mount.

docker compose stop thunderstrike
docker run --rm --volumes-from "$(docker compose ps -aq thunderstrike):ro" \
  -v "$PWD:/backup" debian:bookworm-slim \
  tar -C /var/lib/thunderstrike -czf /backup/thunderstrike-backup.tgz .

Store the original keystore passphrase securely with the backup. Keep copies of the TLS directory and .env for restoring the deployment. For a routine backup, resume service with docker compose start thunderstrike.

⁠Upgrading an existing deployment

  1. Stop the old server cleanly and take the backup above. Leave it stopped while upgrading.
  2. Extract the new kit into an empty directory. Run cp .env.example .env there so THUNDERSTRIKE_IMAGE points to docker.io/sbansal793/thunderstrike:0.1.6. Carry over the old settings, original passphrase and TLS files. Use the same Compose project name for a named volume, or the same absolute host path for a bind mount.
  3. From the new kit directory, run docker compose -f compose.yaml run --rm configure, then docker compose up -d thunderstrike. Wait for healthy.

When opening a database with an older plaintext journal, the server replays it and writes encrypted journal records going forward. After a crash, let this version recover and stop it cleanly before attempting a downgrade. An older server can skip pending writes in a sealed journal.

⁠Troubleshooting

You seeWhat to do
io_uring probe failed: NotSupportedRun it with the kit's seccomp profile.
RLIMIT_MEMLOCK is 8192 KiB and the arena needs ...Use the kit's memlock: -1 or pass --ulimit memlock=-1. Check that the Docker daemon allows this limit.
Published ports are missing or staleStop cleanly, regenerate compose.override.yaml with the configure command, then run docker compose up -d thunderstrike.
Requested physical cores exceed the allocationReduce THUNDERSTRIKE_CORES to an even number that fits the Docker host or VM, then rerun configure.
Exit status 137Check whether Docker killed the server for exceeding its memory limit. Allow room for the locked arenas and the rest of the process.
no keystore passphraseThe passphrase file is missing or empty.
keystore open failed: Kek(AuthFailed)The passphrase is wrong for this volume.
TLS is mandatoryRun docker compose run --rm tls-init.
Linux kernel 6.8 or newer is requiredUpgrade the host kernel, or Docker Desktop's Linux VM on macOS and Windows.
TLS cert ... is signed by itselfThe certificate is self-signed, as an older tls-init made them. Delete server.crt and server.key, run tls-init, and give clients ca.crt.
Exit status 132 (SIGILL)The -v4 tag on a CPU without AVX-512. Use the main tag.

⁠License

Copyright (c) 2026 SHORTSQUEEZE PRIVATE LIMITED. All rights reserved.

thunderstrike is proprietary software, licensed under the THUNDERSTRIKE END USER LICENSE AGREEMENT. You may download and run this image free of charge, for any lawful purpose, including in production and as the database behind your own applications and services. You may modify the kit's configuration files for your deployment. The agreement restricts modification of the software, reverse engineering, resale, redistribution and offering the software as a hosted database service in its own right. The software comes with no warranty, and the agreement is governed by the laws of India. By downloading or using the image you accept the agreement: read it in full in the kit's LICENSE, or print it:

docker run --rm docker.io/sbansal793/thunderstrike:0.1.6 license

The image includes third-party components under their own licenses. Their notices are in the image, in /usr/local/share/thunderstrike/third-party/ and /usr/share/doc/.

Tag summary
Recent tags
Content type
Image
Digest
sha256:387817926…
Size
11.8 MB
Last updated
10 days ago
docker pull sbansal793/thunderstrike:latest