Deployment Guide
This guide covers deployment strategies, configuration, and operational considerations for Shortas in various environments.
π Deployment Options
Local Development
Development environment setup with all necessary tools and dependencies.
Learn Moreπ Prerequisites
System Requirements
- Rust: Version 1.75+ (stable)
- Docker & Docker Compose: For containerized deployments
- Make: Build automation tool
- curl: For health checks and API testing
π Quick Start Deployment
For a rapid local deployment, use the make
commands from the project root:
# Complete development setup (installs deps, starts infra, builds, tests)
make dev-setup
# Start all services in development mode
make dev-start
# Check if all services are healthy
make health-check
π³ Docker Deployment
Docker is the recommended way to run Shortas in development and staging environments.
Building Docker Images
From the project root, build all service images:
make build-docker
This will create images for click-router
, click-tracker
, click-aggregator
, click-router-api
, and click-aggregator-api
.
Deploying with Docker Compose
The docker-compose.yml
file in the redirect/
directory orchestrates all Shortas services and their dependencies (MongoDB, ClickHouse, Redis, Kafka/Fluvio).
- Navigate to the
redirect
directory:cd redirect
- Start the services:
docker-compose up -d
This command will pull necessary images, create containers, and start all services in detached mode.
- Verify services:
docker-compose ps # Or use the project's health check cd .. # Go back to root make health-check
- Stop services:
cd redirect docker-compose down
βΈοΈ Kubernetes Deployment
For production environments, Kubernetes provides robust orchestration, scaling, and self-healing capabilities. Example manifests are provided in infra/aws/terraform
.
Prerequisites
- A running Kubernetes cluster.
kubectl
configured to connect to your cluster.- Docker images pushed to a registry accessible by your cluster.
Deployment Steps
- Create Namespace:
kubectl apply -f infra/aws/terraform/namespace.yaml
- Create ConfigMaps:
Define application configurations as ConfigMaps.
kubectl apply -f infra/aws/terraform/click-router-configmap.yaml # Repeat for other services (click-tracker, click-aggregator, etc.)
-
Deploy Databases: Deploy MongoDB, ClickHouse, and Redis using their respective Kubernetes manifests or Helm charts. Ensure persistent storage is configured.
-
Deploy Message Queues: Deploy Kafka/Fluvio using their Kubernetes manifests or Helm charts.
- Deploy Shortas Services:
Apply the deployment manifests for each Shortas microservice.
kubectl apply -f infra/aws/terraform/click-router-deployment.yaml kubectl apply -f infra/aws/terraform/click-router-service.yaml kubectl apply -f infra/aws/terraform/click-router-ingress.yaml # Repeat for other services
- Monitor Deployment:
kubectl get pods -n shortas kubectl get services -n shortas kubectl get ingress -n shortas
βοΈ AWS Production Deployment
Shortas can be deployed on AWS using Terraform for infrastructure as code. The infra/aws/terraform
directory contains example Terraform configurations.
Prerequisites
- AWS account configured with necessary permissions.
- Terraform CLI installed.
Deployment Steps
- Initialize Terraform:
cd infra/aws/terraform terraform init
- Review and Plan:
terraform plan
- Apply Terraform:
terraform apply
This will provision AWS resources including:
- EKS Cluster (Kubernetes)
- EC2 instances for services
- RDS for MongoDB (or DynamoDB tables)
- MSK for Kafka (or Fluvio on EC2)
- ElastiCache for Redis
- Load Balancers, Security Groups, etc.
βοΈ Configuration Management
Refer to the Configuration Guide for detailed information on environment variables and TOML configuration files.
ποΈ Database Setup
Ensure your databases are properly set up and accessible by Shortas services.
MongoDB
- Local: Use
docker-compose
or manual installation. - Production: AWS DocumentDB, MongoDB Atlas, or self-hosted cluster.
- MongoDB Setup Details
ClickHouse
- Local: Use
docker-compose
or manual installation. - Production: AWS EC2, ClickHouse Cloud, or self-hosted cluster.
- ClickHouse Setup Details
Redis
- Local: Use
docker-compose
or manual installation. - Production: AWS ElastiCache or self-hosted Redis cluster.
π Analytics Setup
Configure your message queues for click stream processing.
Kafka
- Local: Use
docker-compose
. - Production: AWS MSK or self-hosted Kafka cluster.
- Kafka Setup Details
Fluvio
- Local: Use
docker-compose
orfluvio cluster start
. - Production: Fluvio on EC2 or other cloud instances.
- Fluvio Setup Details
π Security Configuration
Implement robust security measures for your deployments.
TLS/SSL
- Configure SSL certificates for all public-facing services.
- Use Certbot for Letβs Encrypt certificates in production.
- TLS/SSL Setup Details
Firewall Configuration
- Restrict access to necessary ports only.
- Use security groups (AWS) or network policies (Kubernetes).
Authentication & Authorization
- Integrate JWT with Keycloak or other identity providers.
- Implement role-based access control (RBAC).
π Monitoring & Logging
Set up comprehensive monitoring and logging for observability.
Health Checks
- All services expose
/health
and/metrics
endpoints. - Integrate with Prometheus and Grafana.
- Health Checks Details
Logging
- Structured JSON logging.
- Centralized logging with ELK stack or AWS CloudWatch.
- Logging Configuration Details
π Performance Optimization
Tune your environment and application for maximum performance.
System Tuning
- Adjust Linux kernel parameters (
sysctl.conf
). - Increase file descriptor limits (
limits.conf
).
Application Tuning
- Configure thread pools, cache sizes, and database connection pools.
- Performance Optimization Details
π Backup & Recovery
Implement backup strategies for critical data.
Database Backup
- Regular backups for MongoDB (mongodump) and ClickHouse.
- AWS DynamoDB backups.
- Database Backup Details
Application Backup
- Backup configuration files and static data.
π¨ Troubleshooting
Common issues and debugging tips.
- Troubleshooting Guide
- Enable debug logging (
RUST_LOG=debug
).
Need help with deployment? Check the Issue Tracker or our Support section.