• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
pinsar

pinsar

feistyAmberRhinoceros

Public
Like
feistyAmberRhinoceros
Home
Code
9
backend
5
docs
3
frontend
2
shared
2
LICENSE
README.md
gitignore
H
main.tsx
package.json
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
docs
/
DEPLOYMENT.md
Code
/
docs
/
DEPLOYMENT.md
Search
5/26/2025
DEPLOYMENT.md

Deployment Guide

Overview

This guide covers deploying the Real-Time Data Processing System on various platforms, from local development to production environments.

Prerequisites

  • Deno: Version 1.40.0 or higher
  • Git: For version control
  • Node.js: Optional, for package management tools

Local Development

1. Clone the Repository

git clone https://github.com/yourusername/real-time-data-processing-system.git cd real-time-data-processing-system

2. Install Deno

# macOS/Linux curl -fsSL https://deno.land/install.sh | sh # Windows (PowerShell) irm https://deno.land/install.ps1 | iex

3. Run the Application

# Development mode with auto-reload deno run --allow-all --watch main.tsx # Production mode deno run --allow-all main.tsx

4. Access the Dashboard

Open your browser and navigate to:

http://localhost:8000

Val Town Deployment

1. Create a Val Town Account

Visit Val Town and create an account.

2. Create a New Val

  1. Click "New Val"
  2. Choose "HTTP" trigger type
  3. Copy the contents of main.tsx into the editor

3. Upload Project Files

Create the following file structure in Val Town:

/main.tsx                    # Entry point
/backend/index.ts           # Main server
/backend/ingestion/eventIngestion.ts
/backend/processing/streamProcessor.ts
/backend/storage/database.ts
/backend/monitoring/metricsCollector.ts
/backend/monitoring/healthChecker.ts
/frontend/index.html
/frontend/index.tsx
/shared/types.ts
/shared/utils.ts

4. Deploy

Click "Save" to deploy your val. Val Town will provide a public URL.

Docker Deployment

1. Create Dockerfile

FROM denoland/deno:1.40.0 WORKDIR /app # Copy dependency files COPY . . # Cache dependencies RUN deno cache main.tsx # Expose port EXPOSE 8000 # Run the application CMD ["run", "--allow-all", "main.tsx"]

2. Build and Run

# Build the image docker build -t real-time-processor . # Run the container docker run -p 8000:8000 real-time-processor

3. Docker Compose

Create docker-compose.yml:

version: '3.8' services: app: build: . ports: - "8000:8000" environment: - NODE_ENV=production volumes: - ./data:/app/data restart: unless-stopped nginx: image: nginx:alpine ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./ssl:/etc/nginx/ssl depends_on: - app restart: unless-stopped

Cloud Deployment

AWS Deployment

Using AWS Lambda

  1. Install AWS CLI and configure credentials
  2. Create deployment package:
    zip -r deployment.zip . -x "*.git*" "node_modules/*"
  3. Deploy using AWS CLI:
    aws lambda create-function \ --function-name real-time-processor \ --runtime provided.al2 \ --role arn:aws:iam::account:role/lambda-role \ --handler main.handler \ --zip-file fileb://deployment.zip

Using ECS

  1. Push Docker image to ECR
  2. Create ECS task definition
  3. Deploy to ECS cluster

Google Cloud Platform

Using Cloud Run

# Build and push to Container Registry gcloud builds submit --tag gcr.io/PROJECT_ID/real-time-processor # Deploy to Cloud Run gcloud run deploy real-time-processor \ --image gcr.io/PROJECT_ID/real-time-processor \ --platform managed \ --region us-central1 \ --allow-unauthenticated

Azure Deployment

Using Container Instances

# Create resource group az group create --name real-time-processor --location eastus # Deploy container az container create \ --resource-group real-time-processor \ --name real-time-processor \ --image your-registry/real-time-processor \ --ports 8000 \ --dns-name-label real-time-processor

Kubernetes Deployment

1. Create Kubernetes Manifests

deployment.yaml:

apiVersion: apps/v1 kind: Deployment metadata: name: real-time-processor spec: replicas: 3 selector: matchLabels: app: real-time-processor template: metadata: labels: app: real-time-processor spec: containers: - name: app image: real-time-processor:latest ports: - containerPort: 8000 env: - name: NODE_ENV value: "production" resources: requests: memory: "256Mi" cpu: "250m" limits: memory: "512Mi" cpu: "500m"

service.yaml:

apiVersion: v1 kind: Service metadata: name: real-time-processor-service spec: selector: app: real-time-processor ports: - port: 80 targetPort: 8000 type: LoadBalancer

2. Deploy to Kubernetes

kubectl apply -f deployment.yaml kubectl apply -f service.yaml

Environment Configuration

Environment Variables

# Server Configuration PORT=8000 NODE_ENV=production # Database Configuration DATABASE_URL=sqlite:./data/events.db DATABASE_POOL_SIZE=10 # Monitoring Configuration METRICS_RETENTION_HOURS=24 HEALTH_CHECK_INTERVAL=30 # Security Configuration RATE_LIMIT_REQUESTS_PER_SECOND=10000 CORS_ORIGIN=* # Performance Configuration PROCESSING_INSTANCES=5 BATCH_SIZE=100 WINDOW_SIZE_MS=10000

Configuration Files

Create config.json:

{ "server": { "port": 8000, "host": "0.0.0.0" }, "database": { "type": "sqlite", "path": "./data/events.db", "poolSize": 10 }, "processing": { "instances": 5, "windowSizeMs": 10000, "batchSize": 100 }, "monitoring": { "metricsRetentionHours": 24, "healthCheckIntervalSeconds": 30 } }

Performance Tuning

Database Optimization

-- Create indexes for better query performance CREATE INDEX idx_events_timestamp ON events(timestamp DESC); CREATE INDEX idx_events_type_timestamp ON events(type, timestamp DESC); CREATE INDEX idx_metrics_timestamp ON metrics(timestamp DESC); -- Configure SQLite for better performance PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA cache_size = 10000; PRAGMA temp_store = memory;

System Optimization

# Increase file descriptor limits ulimit -n 65536 # Optimize network settings echo 'net.core.somaxconn = 65536' >> /etc/sysctl.conf echo 'net.ipv4.tcp_max_syn_backlog = 65536' >> /etc/sysctl.conf # Apply changes sysctl -p

Monitoring and Logging

Health Checks

The system provides several health check endpoints:

# Basic health check curl http://localhost:8000/api/health # Detailed metrics curl http://localhost:8000/api/metrics # System status curl http://localhost:8000/api/system/status

Logging Configuration

// Configure structured logging const logger = { level: process.env.LOG_LEVEL || 'info', format: 'json', transports: [ { type: 'console' }, { type: 'file', filename: 'app.log' } ] };

Monitoring Integration

Prometheus Metrics

Add Prometheus endpoint:

app.get('/metrics', (c) => { // Return Prometheus-formatted metrics return c.text(prometheusMetrics); });

Grafana Dashboard

Import the provided Grafana dashboard configuration from monitoring/grafana-dashboard.json.

Security Considerations

SSL/TLS Configuration

server { listen 443 ssl http2; server_name your-domain.com; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512; location / { proxy_pass http://localhost:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }

Firewall Configuration

# Allow only necessary ports ufw allow 22/tcp # SSH ufw allow 80/tcp # HTTP ufw allow 443/tcp # HTTPS ufw enable

Backup and Recovery

Database Backup

# Create backup script #!/bin/bash DATE=$(date +%Y%m%d_%H%M%S) sqlite3 ./data/events.db ".backup ./backups/events_$DATE.db" # Schedule with cron 0 2 * * * /path/to/backup-script.sh

Disaster Recovery

  1. Regular backups: Automated daily backups
  2. Multi-region deployment: Deploy across multiple regions
  3. Data replication: Real-time data replication
  4. Recovery procedures: Documented recovery steps

Troubleshooting

Common Issues

  1. High Memory Usage

    • Check for memory leaks in processing instances
    • Adjust batch sizes and window configurations
    • Monitor garbage collection
  2. High Latency

    • Check database query performance
    • Monitor network connectivity
    • Review processing instance load
  3. Connection Issues

    • Verify WebSocket configuration
    • Check firewall settings
    • Monitor connection pool usage

Debug Mode

# Run with debug logging DEBUG=* deno run --allow-all main.tsx # Enable performance profiling deno run --allow-all --inspect main.tsx

Log Analysis

# Monitor real-time logs tail -f app.log | grep ERROR # Analyze performance metrics grep "processing_time" app.log | awk '{sum+=$3; count++} END {print "Average:", sum/count}'
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.