monoblok docs
Docs menu · Install and run

Start

Install and run

monoblok ships as a single binary for Linux (x64, ARM64 or 32-bit ARM) or macOS on Apple Silicon, and as a multi-arch container image. There is no cluster to form, and the only disk it uses is an optional snapshot file for warm start.

Install#

Binary#

shell
curl -fsSL https://raw.githubusercontent.com/lexvicacom/monoblok/main/scripts/start.sh | bash

The release helper downloads the latest monoblok (macOS/Linux) and extracts it into the current directory. To try it out, run the unpacked binary in place:

shell
./monoblok-*/monoblok --port 14222 --patchbay ./monoblok-*/patchbay.edn

On Raspberry Pi, the helper selects linux-aarch64 for a 64-bit OS and linux-armv6-gnueabihf for a 32-bit OS, including Pi 1 and Pi Zero W. It also detects 32-bit userspace running on a 64-bit kernel. The 32-bit binary targets ARMv6 hard-float Linux with glibc 2.36 or newer, such as Raspberry Pi OS Bookworm or newer.

To install it on Linux, run the bundled installer and start the systemd service:

shell
sudo bash ./monoblok-*/install-systemd.sh
sudo systemctl enable --now monoblok

Release binaries require the system OpenSSL 3 runtime libraries. Install the package for your platform before running monoblok:

PlatformCommand
Ubuntu 24.04 / Debian 13sudo apt-get install libssl3t64
Ubuntu 22.04 / Debian 12sudo apt-get install libssl3
RHEL 9sudo yum install openssl-libs
macOSbrew install openssl@3

On other Linux releases, install your distribution's OpenSSL 3 runtime package. Container images already include these libraries.

The unpacked directory contains the runnable examples. Run the .sh files.

Alternatively, download the latest release from GitHub and extract the archive for your platform. This avoids piping the download script into bash.

Container#

shell
docker run --rm -p 14222:14222 ghcr.io/lexvicacom/monoblok:latest --port 14222

Build from source#

shell
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/monoblok --port 14222 --patchbay patchbay.edn

Requires CMake 3.22+, a compiler with C23 mode (GCC 11+ or current Apple Clang), and system OpenSSL (1.1.1 or 3.x; 4.x is not supported). libuv, nats.c and yyjson are vendored.

Command line#

A patchbay file is the only configuration. Pass it positionally or with --patchbay; .edn, .json, .yml and .yaml are accepted.

shell
monoblok --port 4222 --patchbay patchbay.edn
monoblok examples/sensors.edn
optionmeaning
--patchbay FILEpatchbay path (also accepted as the positional argument)
--host HOST / --port PORTNATS listener, default 127.0.0.1:4222
--http-host HOST / --http-port PORTenable the HTTP/SSE adapter on this port
--tls-cert FILE / --tls-key FILEenable client TLS
--auth-token-env ENVrequire a CONNECT auth_token matching the value of ENV
--auth-user-env ENV / --auth-pass-env ENVrequire a CONNECT user and password (auth)
--no-lvcdisable the $LVC.* last-value cache
--snapshot FILEload and write an LVC and patchbay state snapshot
--snapshot-every Swrite the snapshot every S seconds
--stats-tick-ms MS$STATS.* publish cadence, default 60000
--validateparse and lint the patchbay, then exit
--soundcheckread SUBJECT|payload rows from stdin and print what the rules emit
--soundcheck-labelprefix soundcheck rows with in| or out|
--soundcheck-linger-ms MSkeep clock and window state alive after soundcheck EOF, default 10000; 0 disables
--tracelog parsed client operations to stderr
--io-uring / --no-io-uringopt in to libuv's io_uring paths on Linux (off by default, for seccomp-friendly containers)
--version, -V / --help, -hprint the version or usage

--validate, --soundcheck and --trace are covered in Validate and debug rules.

Deploying#

monoblok has low hardware requirements. A 2-vCPU VM with 256 MB+ of RAM is a good starting point. monoblok runs on one application core; the operating system can still use other cores for networking and file I/O.

The systemd unit plus --snapshot handles restarts: a crash or reboot loses at most one snapshot interval of in-flight conditioning state. If you're bridging upstream, that cluster can be thought of as the system of record (anything already exported is durable there).

systemd#

Linux release tarballs ship a unit file and installer in scripts/:

shell
sudo bash scripts/install-systemd.sh
sudo systemctl enable --now monoblok
journalctl -u monoblok -f

Drops the binary at /usr/local/bin/monoblok, the patchbay at /etc/monoblok/patchbay.edn, snapshots under /var/lib/monoblok/state.mblk (every 10s plus on stop), and creates a monoblok system user.

Restart behaviour depends on snapshots: with --snapshot, the last-value cache and the state inside gates and windows survive a restart.

Design#

One libuv loop handles protocol parsing, subject matching, patchbay evaluation, fan-out, write buffering and LVC state. Import workers hand messages to that loop for evaluation, keeping router and rule state on one thread.

For lower-level details on ownership boundaries, snapshot I/O, libuv behaviour, borrowed slices, and allocation policy, see implementation notes.

Running the tests#

shell
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure
cmake --build build --target smoke

smoke runs the TCP server smoke, patchbay soundcheck, load-smoke, and the larger load-soak profile. load-smoke starts a temporary daemon and verifies exact TCP fan-out plus derived moving-avg, moving-sum, and count! streams.

How fast is it?#

The saved low-end VPS runs reach the low millions of messages per second for basic pub/sub and fan-out workloads. Run scripts/bench-with-nats-server.sh on your own hardware to compare performance for your deployment.

The saved comparisons with nats-server show these trends:

  • nats-server wins on pure publish throughput on big machines. Multi-threaded acceptance and a more battle-hardened parse loop both help when there's no fan-out work to spread the cost over and there are spare cores to spread it across. On small ARM VPSes the gap narrows or disappears: nats-server has less parallelism to exploit, and monoblok has less coordination overhead to pay.
  • The two are roughly comparable at low fan-out (1-10 subscribers per publish).
  • monoblok scales better with subscriber count. Its fan-out model has low per-subscriber coordination overhead. Crossover happens somewhere around 10-30 subscribers; the further past that you go, the bigger monoblok's lead.

These results apply to the measured workloads. Use nats-server for general pub/sub deployments; consider monoblok where patchbay processing or its last-value cache is useful.

The saved benchmark runs record peak rates of 2-18 million messages per second across a 2-core ARM VPS, an 8-core x86_64 VPS, and an Apple Silicon M4 Mac mini for simple publish and fan-out workloads. Capacity depends on hardware, subscriber count and processing rules; benchmark your own workload.

Patchbay overhead scales with matching rules per PUB, not total rules in the file. On Linux the benchmark scripts default to monoblok's opt-in io_uring path to match the saved runs; pass --epoll to benchmark the production-default epoll path.

shell
scripts/bench.sh
scripts/bench-with-nats-server.sh

MIT licensed · © 2026 Alex Reid
Lexvica offers solutions built with monoblok.