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
Enter the Nix development shell
The Nix flake provides all required dependencies: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)
Build with release optimizations
Build Slung in ReleaseFast mode for maximum performance:Or if you’re already in the Nix shell:The compiled binary will be located at
./zig-out/bin/slung.Build Options
Slung’s build system supports multiple targets and optimization levels.Optimization Modes
Available Build Targets
Thebuild.zig file defines several build targets:
- Main Server
- Tests
- Benchmarks
Build and run the main Slung server: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:File Watching
The development shell automatically creates scripts for file watching:- Auto-rebuild on changes
- Auto-test on changes
*.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:Dependencies
Slung’s dependencies are managed inbuild.zig.zon:
- Runtime Dependencies
- Development Dependencies
- zio: Async I/O runtime for concurrent operations
- dusty: HTTP server and WebSocket protocol implementation
- zware: WebAssembly runtime for executing workflows
Troubleshooting
Nix flakes not enabled
Nix flakes not enabled
If you see an error about experimental features, enable flakes:Or use the flag directly:
Wrong Zig version
Wrong Zig version
Verify you’re using Zig 0.15.2:If the version is incorrect, make sure you’re in the Nix development shell:
Build fails with linker errors
Build fails with linker errors
Ensure all dependencies are available in the Nix shell:If the issue persists, try cleaning the Zig cache:
Permission denied when running binary
Permission denied when running binary
Make sure the binary is executable:Or use the copied binary:
Port 2077 already in use
Port 2077 already in use
Check if another process is using port 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: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
For production deployments:- Build with ReleaseFast:
zig build --release=fast - Use a process manager: systemd, supervisord, or Docker
- Configure storage: Ensure sufficient disk space for TSM files
- Monitor memory: Set up memory alerts (Slung uses ~575 MiB for 1B events)
- Enable logging: Capture logs for debugging and monitoring