Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Multi-Tier Application Examples

This directory contains complete multi-tier application examples showcasing platform-java's unified orchestration across VMs, containers, Java applications, and native binaries.

Examples

Classic web application with database VM, application server, and web frontend.

Architecture:

┌─────────────────┐
│  NGINX (Container)  │  ← Web Tier (Reverse Proxy)
└─────────────────┘
         ↓
┌─────────────────┐
│  Spring Boot (Java) │  ← Application Tier (Business Logic)
└─────────────────┘
         ↓
┌─────────────────┐
│  PostgreSQL (VM)    │  ← Data Tier (Database)
└─────────────────┘

Workload Types:

  • Database: PostgreSQL VM (libvirt/KVM)
  • App Server: Spring Boot Java app (in-JVM isolation)
  • Web Server: NGINX container (Docker/Podman)

Key Features:

  • Cross-workload dependencies
  • Automatic startup ordering
  • Unified monitoring
  • Resource quotas per tier

Modern microservices deployment with service mesh, API gateway, and multiple services.

Architecture:

┌─────────────┐
│  API Gateway  │  ← Entry Point (Container)
└─────────────┘
       ↓
  ┌────┴────┬────────────┬──────────┐
  ↓         ↓            ↓          ↓
┌──────┐ ┌──────┐  ┌──────┐  ┌──────┐
│Auth  │ │User  │  │Order │  │Product│
│(Java)│ │(Java)│  │(VM)  │  │(Cont.)│
└──────┘ └──────┘  └──────┘  └──────┘
       ↓         ↓            ↓
    ┌──────────────────────┐
    │  Redis (Container)    │  ← Cache Layer
    └──────────────────────┘

Workload Types:

  • API Gateway: Kong container
  • Auth Service: Java microservice
  • User Service: Java microservice
  • Order Service: Node.js VM
  • Product Service: Python container
  • Cache: Redis container

Key Features:

  • Service discovery
  • Inter-service dependencies
  • Shared message bus
  • Distributed tracing

ETL pipeline with data ingestion, processing, and analytics.

Architecture:

┌───────────┐
│  Ingestion │  ← Data Sources (Native Binary)
└───────────┘
      ↓
┌───────────┐
│  Processing │  ← Spark Job (VM)
└───────────┘
      ↓
┌───────────┐
│  Storage    │  ← TimescaleDB (Container)
└───────────┘
      ↓
┌───────────┐
│  Analytics  │  ← Java Analytics App
└───────────┘

Workload Types:

  • Ingestion: Kafka native binary
  • Processing: Apache Spark on VM
  • Storage: TimescaleDB container
  • Analytics: Java application

Key Features:

  • Pipeline orchestration
  • Data flow dependencies
  • Resource-intensive workloads
  • Scheduled execution

Application spanning on-premises VirtOS and cloud providers.

Architecture:

On-Premises (VirtOS)          Cloud (AWS/Azure/GCP)
┌─────────────────┐          ┌─────────────────┐
│  Legacy DB (VM) │ ←──────→ │  API Service    │
└─────────────────┘          │  (Cloud Function)│
                              └─────────────────┘
┌─────────────────┐          ┌─────────────────┐
│  Web App (Java) │ ←──────→ │  S3 Storage     │
└─────────────────┘          └─────────────────┘

Workload Types:

  • On-Premises: VirtOS running platform-java
    • Legacy database: VM with existing Oracle/SQL Server
    • Web application: Java Spring Boot
  • Cloud: Managed services
    • API endpoints
    • Object storage
    • Message queues

Key Features:

  • Hybrid deployment
  • VirtOS federation
  • Secure connectivity
  • Cost optimization

Quick Start

Deploy Example 1: Three-Tier Web App

cd three-tier-webapp

# Deploy all tiers (platform-java handles dependency order)
platform-java deploy database-tier.yaml
platform-java deploy app-tier.yaml
platform-java deploy web-tier.yaml

# Start the stack (platform-java starts in dependency order)
platform-java start postgres-db    # Database starts first
platform-java start spring-app     # App waits for database
platform-java start nginx-web      # Web waits for app

# Check status
platform-java status

# View metrics for all tiers
platform-java metrics postgres-db
platform-java metrics spring-app
platform-java metrics nginx-web

# Access the application
curl http://localhost:8080

Deploy Example 2: Microservices

cd microservices

# Deploy all services at once
for yaml in *.yaml; do
  platform-java deploy $yaml
done

# Start all services (platform-java handles dependencies)
platform-java start-all

# View service mesh
platform-java status

# Test API
curl http://localhost:8000/api/v1/products

Example Structure

Each example includes:

YAML Descriptors

  • One descriptor per workload
  • Clearly defined dependencies
  • Resource quotas
  • Health checks

Documentation

  • Architecture diagram
  • Deployment instructions
  • Testing procedures
  • Troubleshooting guide

Scripts

  • deploy.sh - Deploy the entire stack
  • start.sh - Start all workloads in order
  • stop.sh - Stop all workloads
  • test.sh - Run integration tests
  • cleanup.sh - Remove all workloads

Dependencies Between Workload Types

platform-java allows dependencies across all workload types:

# Example: Java app depends on VM database and container cache
applicationId: my-java-app
mainClass: com.example.MyApp
dependencies:
  - postgres-vm        # VM (KVM/QEMU via libvirt)
  - redis-container    # Container (Docker/Podman)
  - auth-service      # Another Java app

Startup Order:

  1. postgres-vm (VM starts first)
  2. redis-container (Container starts second)
  3. auth-service (Java app starts third)
  4. my-java-app (Starts last, after all dependencies ready)

Resource Quotas

Each tier can have different resource limits:

# Database VM - High resources
resources:
  cpu: 8
  memory: 32768  # 32GB

# App Server - Medium resources
resources:
  cpu: 4
  memory: 8192   # 8GB

# Web Server - Low resources
resources:
  cpu: 2
  memory: 2048   # 2GB

Monitoring

All tiers export metrics to Prometheus:

# Aggregate metrics across all tiers
curl http://localhost:9090/metrics | grep platform-java

# Metrics include:
# - platform-java_vm_cpu_time_seconds{vm="postgres-db"}
# - platform-java_container_cpu_usage{container="nginx-web"}
# - platform-java_app_heap_mb{app="spring-app"}

Cross-Workload Communication

Via Message Bus

# Enable messaging in all workloads
properties:
  platform-java.messaging.enabled: "true"

# Publish events from any workload type
# - VMs can publish to Java apps
# - Containers can subscribe to VM events
# - Java apps can coordinate with native binaries

Via Service Registry

# Register services from any workload
properties:
  platform-java.service.register: "true"
  platform-java.service.name: "user-service"
  platform-java.service.port: "8080"

# Discover services from any other workload
# - Java apps can find VMs
# - Containers can discover Java services
# - VMs can lookup other VMs

Testing

Each example includes integration tests:

# Run tests for an example
cd three-tier-webapp
./test.sh

# Tests verify:
# - All workloads start successfully
# - Dependencies are respected
# - Cross-workload communication works
# - Health checks pass
# - Application functionality

Troubleshooting

Check Dependency Order

platform-java startup-order

View Workload Logs

platform-java logs <workload-id>

Check Resource Usage

platform-java metrics <workload-id>

Verify Dependencies

platform-java dependencies <workload-id>

Further Reading

Contributing

Have an interesting multi-tier example? Contributions welcome!

  1. Create example directory
  2. Add descriptors and documentation
  3. Include deployment and test scripts
  4. Submit pull request

Examples should demonstrate:

  • Multiple workload types
  • Real-world architecture
  • Production-ready configuration
  • Clear documentation