title: "Navius Deployment Guide" description: "A comprehensive guide to deploying Navius applications in production environments, covering AWS deployment, Docker containerization, security considerations, and monitoring setup" category: guides tags:
- deployment
- aws
- docker
- kubernetes
- monitoring
- security
- ci-cd
- infrastructure related:
- aws-deployment.md
- docker-deployment.md
- kubernetes-deployment.md
- ../../05_reference/configuration/environment-variables.md
- ../features/authentication.md last_updated: April 1, 2025 version: 1.0
Navius Deployment Guide
This guide provides comprehensive instructions for deploying Navius applications to various environments, focusing on production-grade deployments with security, scalability, and reliability.
Deployment Options
Navius applications can be deployed in multiple ways, depending on your infrastructure preferences:
Docker Containers
Navius excels in containerized environments, offering minimal resource usage and fast startup times.
Docker Deployment Example
# Build the Docker image
docker build -t navius:latest .
# Run the container
docker run -d \
-p 8080:8080 \
-e CONFIG_PATH=/etc/navius/config \
-e RUST_LOG=info \
-v /host/path/to/config:/etc/navius/config \
--name navius-api \
navius:latest
Kubernetes
Navius applications are ideal for Kubernetes due to their small footprint and rapid startup time.
Kubernetes Deployment Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: navius-api
labels:
app: navius-api
spec:
replicas: 3
selector:
matchLabels:
app: navius-api
template:
metadata:
labels:
app: navius-api
spec:
containers:
- name: api
image: your-registry/navius:latest
ports:
- containerPort: 8080
env:
- name: RUST_LOG
value: "info"
- name: CONFIG_PATH
value: "/etc/navius/config"
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: "0.5"
memory: "512Mi"
requests:
cpu: "0.1"
memory: "128Mi"
Service Definition
apiVersion: v1
kind: Service
metadata:
name: navius-api
spec:
selector:
app: navius-api
ports:
- port: 80
targetPort: 8080
type: ClusterIP
AWS Deployment
Navius is optimized for deploying on AWS infrastructure, with built-in integrations for many AWS services.
AWS Deployment with CloudFormation
# AWS CloudFormation template example (simplified)
Resources:
NaviusApiInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t3.micro
ImageId: ami-0abcdef1234567890
UserData:
Fn::Base64: !Sub |
#!/bin/bash
amazon-linux-extras install docker
systemctl start docker
docker run -d -p 80:8080 your-registry/navius:latest
Serverless Deployment (AWS Lambda)
Navius supports serverless deployment via AWS Lambda, offering extremely fast cold-start times compared to JVM-based alternatives:
# Deploy using Serverless Framework
serverless deploy
Bare Metal Deployment
For maximum performance, Navius can be deployed directly to bare metal servers:
Manual Deployment Process
# SSH to your server
ssh user@your-server
# Create directories
sudo mkdir -p /opt/navius/config
# Copy binary and configuration
scp target/release/navius user@server:/opt/navius/
Systemd Service Configuration
# /etc/systemd/system/navius.service
[Unit]
Description=Navius API Server
After=network.target
[Service]
User=navius
WorkingDirectory=/opt/navius
ExecStart=/opt/navius/navius
Restart=on-failure
Environment=RUST_LOG=info
[Install]
WantedBy=multi-user.target
Production Configuration
Environment Variables
For production deployments, configure these essential environment variables:
# Core settings
RUN_ENV=production
RUST_LOG=info
PORT=3000
# Database settings
DATABASE_URL=postgres://user:password@host:port/db
DATABASE_MAX_CONNECTIONS=20
DATABASE_CONNECT_TIMEOUT_SECONDS=5
# Cache settings
REDIS_URL=redis://user:password@host:port
CACHE_TTL_SECONDS=3600
# Security settings
JWT_SECRET=your-secure-jwt-secret
CORS_ALLOWED_ORIGINS=https://yourdomain.com
Recommended Infrastructure
For production deployments, we recommend:
- Database: AWS RDS PostgreSQL or Aurora
- Cache: AWS ElastiCache Redis
- Storage: AWS S3
- CDN: AWS CloudFront
- Load Balancer: AWS Application Load Balancer with TLS termination
Performance Tuning
Navius is designed for high performance, but these optimizations can help in production:
Thread Pool Sizing
Configure thread pools according to your CPU resources:
TOKIO_WORKER_THREADS=number_of_cores * 2
Connection Pool Tuning
Optimize database connection pools:
DATABASE_MAX_CONNECTIONS=25
DATABASE_MIN_IDLE=5
DATABASE_IDLE_TIMEOUT_SECONDS=300
Memory Limits
Configure the JVM (if running under the JVM):
RUST_MAX_MEMORY=512m
Monitoring & Observability
Navius provides built-in observability features:
Prometheus Metrics
Metrics are available at the /metrics
endpoint. Configure Prometheus to scrape this endpoint.
Health Checks
Health checks are available at:
/health
- Basic health check/actuator/health
- Detailed component health
Logging
Navius uses structured logging with tracing. Configure log aggregation with:
- AWS CloudWatch Logs
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Datadog
- New Relic
Example log configuration:
RUST_LOG=info,navius=debug
LOG_FORMAT=json
Scaling Strategies
Navius applications can scale both vertically and horizontally:
Vertical Scaling
Navius is extremely efficient with resources. For many applications, a modest instance size is sufficient:
- AWS: t3.small or t3.medium
- GCP: e2-standard-2
- Azure: Standard_B2s
Horizontal Scaling
For high-traffic applications, horizontal scaling is recommended:
- Deploy multiple instances behind a load balancer
- Configure sticky sessions if using server-side sessions
- Ensure all state is stored in shared resources (database, Redis)
Security Best Practices
TLS Configuration
Always use TLS in production. Configure your load balancer or reverse proxy with:
- TLS 1.2/1.3 only
- Strong cipher suites
- HTTP/2 support
- HSTS headers
Firewall Rules
Restrict access to your instances:
- Allow only necessary ports
- Implement network segmentation
- Use security groups (AWS) or equivalent
Regular Updates
Keep your Navius application updated:
cargo update
cargo build --release
CI/CD Pipeline Integration
Navius works well with modern CI/CD pipelines:
GitHub Actions
name: Deploy to Production
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test
- name: Build Docker image
run: docker build -t yourdockerhub/navius:${{ github.sha }} .
- name: Push Docker image
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push yourdockerhub/navius:${{ github.sha }}
- name: Deploy to ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: task-definition.json
service: navius-service
cluster: navius-cluster
image: yourdockerhub/navius:${{ github.sha }}
GitLab CI
stages:
- build
- test
- deploy
build:
stage: build
image: rust:latest
script:
- cargo build --release
artifacts:
paths:
- target/release/navius
test:
stage: test
image: rust:latest
script:
- cargo test
deploy:
stage: deploy
image: docker:latest
services:
- docker:dind
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- kubectl set image deployment/navius navius=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
only:
- main
Database Migrations
For database migrations, Navius integrates with SQLx migrations:
# Create a new migration
cargo sqlx migrate add create_users_table
# Run migrations (automatic during application startup)
cargo sqlx migrate run
In production, migrations can be run:
- Automatically on application startup
- Via a dedicated migration job before deployment
- Manually in controlled environments
Troubleshooting Common Issues
High Memory Usage
Symptom: Memory usage grows over time
Solution: Check for resource leaks, particularly in custom code that holds onto resources
Slow Startup
Symptom: Application takes a long time to start
Solution: Enable the --release
flag, use the minimal Docker image, or precompile Rust code
Database Connection Issues
Symptom: Application fails to connect to the database
Solution: Verify connection strings, network connectivity, and firewall rules
Conclusion
Navius's efficient resource usage, fast startup time, and resilient design make it an excellent choice for production deployments of any scale. By following the recommendations in this guide, you can ensure your application performs optimally in production environments.
Related Documents
- Installation Guide - How to install the application
- Development Workflow - Development best practices