Self-Hosting Guide
Deploy SimpleNS to production with flexible infrastructure hosting options.
Initial installation and setup
Refer the Getting Started Guide guide for initial installation and setup.
Overview
SimpleNS uses a split architecture that separates application services from infrastructure services, allowing flexible deployment across single or distributed systems.
| Compose File | Purpose | When to Use |
|---|---|---|
docker-compose.yaml | Application services (API, processors, dashboard) | Always required |
docker-compose.infra.yaml | Infrastructure (MongoDB, Kafka, Redis, Loki, Grafana) | Only if self-hosting infrastructure |
SimpleNS can also be hosted easily on cloud providers using prebuilt Terraform templates: SimpleNS Terraform Templates.
Customizing Infrastructure
The @simplens/onboard cli tool lets you to choose which infrastructure services to deploy with Docker. This gives you flexibility to use managed cloud services for some components while self-hosting others.
Selective Infrastructure Services
During onboarding, you can select which services to deploy:
| Service | Description | Default |
|---|---|---|
| MongoDB | Primary database | Yes |
| Kafka | Message queue for notifications | Yes |
| Kafka UI | Web dashboard for Kafka monitoring | No |
| Redis | Caching and delay queue | Yes |
| Loki | Log aggregation | No |
| Grafana | Observability dashboard | No |
| Nginx | Reverse proxy server needed when BASE_PATH is configured | No |
Using Managed/External Services
For any service you choose not to deploy via Docker, you'll be prompted to provide connection URLs:
| Environment Variable | Description | Example |
|---|---|---|
MONGO_URI | MongoDB connection string | mongodb+srv://user:pass@cluster.mongodb.net/simplens |
BROKERS | Kafka broker addresses | kafka-broker.cloud-provider.com:9092 |
REDIS_URL | Redis connection URL | redis://user:pass@redis.cloud-provider.com:6379 |
LOKI_URL | Loki endpoint (optional) | http://loki.cloud-provider.com:3100 |
Use managed services like MongoDB Atlas, Confluent Cloud, or Redis Cloud for production deployments to reduce operational overhead.
Plugin & Provider Management
Plugins, encrypted provider credentials, and channel routings are stored in MongoDB and hot-reloaded across all services via Redis Pub/Sub.
- Install, upgrade, or uninstall plugins in Dashboard → Plugins (
/plugins) (or via/api/plugins/*). - Configure provider instances with encrypted credentials, priority, and token-bucket rate limits (
maxTokens,refillRate,refillInterval). - Set
defaultandfallbackproviders per channel in Channel Routing. - If upgrading from a legacy
simplens.config.yamlsetup,YamlMigratorautomatically imports it on startup when MongoDB is empty.
Scaling with Kafka Partitions
SimpleNS uses Kafka topic partitions to enable horizontal scaling of consumers:
- Per-Channel Partitions (Dynamic): Configured in Dashboard → Channel Routing (default:
6partitions). SimpleNS creates and expands channel topic partitions dynamically (expandTopicPartitions). - System Topic Partitions (
.env):DELAYED_PARTITION(default1) andNOTIFICATION_STATUS_PARTITION(default1) are set in.env.
The recovery service does not depend on Kafka partitions and is stateless—it scales horizontally using atomic MongoDB claiming (recovery_claimed_by).
Scaling Workers & Processors
# Deploy multiple instances (compose files live in docker-compose/)
docker compose -f docker-compose/docker-compose.master.yaml up -d --scale notification_processor=6
docker compose -f docker-compose/docker-compose.master.yaml up -d --scale worker=3
docker compose -f docker-compose/docker-compose.master.yaml up -d --scale delayed_processor=2Kafka partition counts can be increased dynamically, but cannot be decreased after topics are created.
For detailed configuration of all environment variables, see the Configuration Reference.
Deployment Configurations
SimpleNS is designed to scale from a single Raspberry Pi to a multi-node Kubernetes cluster. How you deploy depends on your expected volume and whether you want to manage stateful databases yourself.
Hardware Requirements
| Environment | Minimum Resources | Recommended Resources |
|---|---|---|
| Development (Devcontainer) | 4 CPU Cores, 6GB RAM | 8 CPU Cores, 8GB RAM |
| Production (All-in-one) | 2 CPU Cores, 2GB RAM | 4 CPU Cores, 4GB RAM |
| Production (App Only) | 1 CPU Core, 1GB RAM | 2 CPU Cores, 2GB RAM + Managed DBs |
Kafka and MongoDB are the most resource-intensive components when self-hosting the full stack.
Choose Your Setup
Best for: Side-projects, staging environments, and low-volume production (<100k events/day).
This setup runs both the Application and Infrastructure locally on a single machine.
# Ensure MONGO, KAFKA, and REDIS point to your local docker networks
MONGO_URI=mongodb://host.docker.internal:27017/simplens?replicaSet=rs0
BROKERS=host.docker.internal:9092
REDIS_URL=redis://host.docker.internal:6379
LOKI_URL=http://host.docker.internal:3100# Step 1: Start Infrastructure (DBs, Queues)
docker compose -f docker-compose/docker-compose.infra.yaml up -d
# Step 2: Start Application Services
docker compose -f docker-compose/docker-compose.master.yaml up -dBest for: Most production workloads. You run the stateless Node.js services, while handing off database maintenance to cloud providers.
# MongoDB Atlas
MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/simplens?retryWrites=true
# Confluent Cloud Kafka / AWS MSK
BROKERS=kafka-broker.cloud-provider.com:9092
# Redis Cloud / AWS ElastiCache
REDIS_URL=redis://user:pass@redis.cloud-provider.com:6379# Only start application services
docker-compose up -dWith this setup, you completely ignore docker-compose.infra.yaml.
Best for: High availability and massive throughput.
You deploy infrastructure on dedicated nodes (or managed services), and spread Application workers across multiple machines behind a load balancer.
- API Nodes: Scale
apicontainer horizontally behind NGINX/ALB. - Processor Nodes: Deploy
notification_processoron separate servers tailored to target specific channels usingPROCESSOR_CHANNEL=email. - Background Nodes: Run
workeranddelayed_processoron background compute.
Ensure you adjust your *_PARTITION environment variables before creation to support the number of parallel processor instances you plan to run.
Application Services
The docker-compose.yaml uses pre-built images from GitHub Container Registry:
| Service | Image | Description |
|---|---|---|
api | ghcr.io/simplenotificationsystem/simplens-core:latest | REST API for notification ingestion |
worker | ghcr.io/simplenotificationsystem/simplens-core:latest | Background worker for outbox processing |
notification_processor | ghcr.io/simplenotificationsystem/simplens-core:latest | Plugin-based notification delivery |
delayed_processor | ghcr.io/simplenotificationsystem/simplens-core:latest | Scheduled notification handling |
recovery | ghcr.io/simplenotificationsystem/simplens-core:latest | Detects and rescues stuck notifications |
dashboard | ghcr.io/simplenotificationsystem/simplens-dashboard:latest | Admin dashboard (Next.js) |
All application services have thier own .plugins directory in their container (not a shared volume) for installed npm packages, while plugin state, encrypted provider credentials, and routing live in MongoDB and synced via Redis Pub/Sub.
Infrastructure Services
The docker-compose.infra.yaml provides self-hosted infrastructure:
| Service | Image | Description |
|---|---|---|
mongo | mongo:7.0 | MongoDB with replica set |
kafka | apache/kafka-native | Kafka with KRaft mode (no Zookeeper) |
kafka-ui | kafbat/kafka-ui:main | Kafka monitoring UI (optional) |
redis | redis:7-alpine | Redis for caching and queues |
loki | grafana/loki:2.9.0 | Log aggregation |
grafana | grafana/grafana:10.2.0 | Log visualization |
Port Reference
| Service | Port | Description |
|---|---|---|
| API | 3000 | REST API for notification ingestion |
| Dashboard | 3002 | Admin web interface |
| MongoDB | 27017 | Database |
| Kafka | 9092 | Message broker |
| Kafka UI | 8080 | Kafka monitoring (optional) |
| Redis | 6379 | Cache and queues |
| Loki | 3100 | Log aggregation |
| Grafana | 3001 | Log visualization |
Plugin & Operational Configuration
SimpleNS stores plugins, encrypted provider credentials, channel routings, storage providers, and operational settings in MongoDB, hot-reloaded across all replicas via Redis Pub/Sub.
- Manage plugins, providers, and routing in Dashboard → Plugins (
/plugins). - Tune worker, retry, attachment, and IP rate-limit settings live in Dashboard → Settings (
/settings). - If upgrading from a legacy
simplens.config.yamlsetup,YamlMigratorautomatically imports it on startup when MongoDB is empty.
Security Considerations
Before Deploying to Production
Complete these security checks before going live.
- ✅ Set a strong
JWT_SECRET(minimum 32 characters) andADMIN_ALERT_ENCRYPTION_KEYin.env - ✅ Complete
/setupin the Dashboard immediately on first launch to create your admin account - ✅ Configure
CORS_ALLOWED_ORIGINSexplicitly (SimpleNS is default-deny for CORS) - ✅ If behind a reverse proxy (Nginx/Traefik), set
TRUST_PROXYto a hop count (e.g.,1) or trusted IP/CIDR—nevertrue - ✅ Enable
NODE_ENV=productionso SSRF protection (safe-outbound-url/safe-http-client) blocks private/internalwebhook_urland alert targets - ✅ Set up SSL/TLS for the API and Dashboard, and configure MongoDB authentication + backups
- ✅ Use Kubernetes
probeServerliveness/readiness probes (and/api/health*) in orchestrated deployments
Troubleshooting
Services can't connect to infrastructure
- INFRA_HOST / URLs: Ensure
MONGO_URI,REDIS_URL, andBROKERSpoint to reachable addresses - Firewall: Check ports
27017,9092,6379,3100are open - Network: Verify containers/machines can reach each other
MongoDB replica set issues
# Reset and reinitialize
docker compose -f docker-compose.infra.yaml down -v
docker compose -f docker-compose.infra.yaml up -d
# Wait 60 seconds for auto-initializationPlugin or settings changes not syncing across replicas
# Verify Redis connectivity and check processor logs
docker compose logs notification_processor api
Docs