Skip to main content

Prerequisites

Before installing Slung, ensure you have the following tools installed:

Zig

Zig compiler version 0.15.2 or higher

Nix

Nix package manager with flakes enabled

Hardware Requirements

  • RAM: Minimum 1 GB
  • CPU: At least 1 free core
  • Storage: Space for data (approximately 8.7 MB per 1M events)
For production workloads, 4 GB+ RAM and multiple CPU cores are recommended.

Build from Source

1

Clone the repository

Clone the Slung repository from GitHub:
git clone https://github.com/slunghq/slung
cd slung
2

Enter the Nix development shell

The Nix flake provides all required dependencies:
nix develop
This creates a development environment with:
  • Zig 0.15.2 from the zig-overlay
  • pkg-config for library linking
  • entr and watchexec for file watching (optional)
You should see a message showing the Zig version and available commands.
3

Build with release optimizations

Build Slung in ReleaseFast mode for maximum performance:
nix develop -c zig build --release=fast
Or if you’re already in the Nix shell:
zig build --release=fast
The compiled binary will be located at ./zig-out/bin/slung.
4

Copy the binary

For convenience, copy the binary to the project root:
cp ./zig-out/bin/slung .
5

Run Slung

Start the server:
./slung
You should see:
Slung server listening on http://0.0.0.0:2077

Build Options

Slung’s build system supports multiple targets and optimization levels.

Optimization Modes

zig build
Use --release=fast for production deployments to achieve the best performance (1.2M+ WPS).

Available Build Targets

The build.zig file defines several build targets:
Build and run the main Slung server:
zig build run
Dependencies:
  • zio: Async I/O runtime
  • dusty: HTTP and WebSocket handling
  • zware: WebAssembly runtime

Development Workflow

The Nix development shell includes helper scripts for development.

Available Commands

Once in the development shell:
zig build run

File Watching

The development shell automatically creates scripts for file watching:
./zig-watch
Watches all *.zig files in the src directory and automatically rebuilds and runs when files change.
These scripts use entr to watch for file changes. Press Ctrl+C to stop watching.

Project Structure

Understanding the codebase structure:
slung/
├── src/
│   ├── main.zig          # Server entry point and WebSocket handling
│   ├── query.zig         # Query DSL parser and executor
│   ├── tsm/
│   │   ├── tsm.zig      # TSM tree implementation
│   │   ├── gorilla.zig  # Gorilla compression
│   │   ├── entry.zig    # Disk entry format
│   │   └── cache.zig    # In-memory cache
│   ├── ds/
│   │   ├── skiplist.zig # Skip list data structure
│   │   ├── bloom.zig    # Bloom filter
│   │   └── bitmap.zig   # Bitmap operations
│   └── host/
│       ├── host.zig     # WASM host interface
│       └── execute.zig  # WASM execution
├── sdks/
│   ├── client/
│   │   └── typescript/  # TypeScript client SDK
│   └── workflow/
│       └── rust/        # Rust workflow SDK
├── build.zig            # Build configuration
├── build.zig.zon        # Dependencies
├── flake.nix            # Nix development environment
└── flake.lock           # Locked Nix dependencies

Dependencies

Slung’s dependencies are managed in build.zig.zon:
  • zio: Async I/O runtime for concurrent operations
  • dusty: HTTP server and WebSocket protocol implementation
  • zware: WebAssembly runtime for executing workflows

Troubleshooting

If you see an error about experimental features, enable flakes:
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
Or use the flag directly:
nix --experimental-features 'nix-command flakes' develop
Verify you’re using Zig 0.15.2:
zig version
If the version is incorrect, make sure you’re in the Nix development shell:
nix develop
zig version  # Should show 0.15.2
Ensure all dependencies are available in the Nix shell:
nix develop
zig build clean
zig build --release=fast
If the issue persists, try cleaning the Zig cache:
rm -rf zig-cache zig-out
zig build --release=fast
Make sure the binary is executable:
chmod +x ./zig-out/bin/slung
Or use the copied binary:
chmod +x ./slung
./slung
Check if another process is using port 2077:
lsof -i :2077
Kill the process or use a different port (note: port configuration is currently hardcoded in src/main.zig:388).

Verifying the Installation

Confirm Slung is working correctly:
1

Check the binary

ls -lh ./slung
The binary should be around 2-5 MB depending on optimization level.
2

Start the server

./slung
Look for the startup message:
Slung server listening on http://0.0.0.0:2077
3

Test the health endpoint

In another terminal:
curl http://localhost:2077/health
Should return:
{
  "status": "ok"
}
4

Check WebSocket connectivity

Try connecting with a WebSocket client:
# Using websocat (install with: cargo install websocat)
websocat ws://localhost:2077/
The connection should open successfully.

Next Steps

Now that Slung is installed:

Quickstart Tutorial

Send your first events and run queries

Core Concepts

Learn about Slung’s architecture and data model

Client SDKs

Install and use the TypeScript client SDK

Performance Tuning

Optimize Slung for your workload

Building for Production

Slung is currently in active development and not recommended for production use. The following is provided for future reference.
For production deployments:
  1. Build with ReleaseFast: zig build --release=fast
  2. Use a process manager: systemd, supervisord, or Docker
  3. Configure storage: Ensure sufficient disk space for TSM files
  4. Monitor memory: Set up memory alerts (Slung uses ~575 MiB for 1B events)
  5. Enable logging: Capture logs for debugging and monitoring
Consider running Slung behind a reverse proxy (nginx, Caddy) for TLS termination and load balancing.

Build docs developers (and LLMs) love