Lewati ke konten utama

BAB 54. DEPLOYMENT ARCHITECTURE

Tujuan

Deployment dirancang agar mudah dimulai dari satu sekolah namun siap berkembang menjadi multi-school nasional tanpa perubahan arsitektur mendasar.


Lingkungan Deployment

EnvironmentFungsiAkses
LocalDevelopment dan debuggingDeveloper
StagingTesting sebelum productionTim QA + Stakeholder
ProductionOperasional nyataPengguna akhir

Arsitektur Production

flowchart TD
MOB["📱 Flutter App"] --> CDN["🌐 CDN"]
ADMIN["🖥️ Web Admin"] --> NGINX["⚙️ Nginx\n(Reverse Proxy)"]
CDN --> NGINX

NGINX --> APP["🟥 Laravel App\n(PHP-FPM)"]

APP --> REDIS[("🔴 Redis\n(Cache + Queue)")]
APP --> QUEUE["⏳ Queue Worker\n(Laravel Horizon)"]
APP --> REVERB["⚡ Laravel Reverb\n(WebSocket)"]
APP --> MYSQL[("💾 MySQL\n(Primary)")]

QUEUE --> MYSQL
QUEUE --> FCM["🔥 Firebase FCM"]

style NGINX fill:#059669,color:#fff
style APP fill:#dc2626,color:#fff
style REDIS fill:#dc2626,color:#fff

Komponen Deployment

KomponenTeknologiFungsi
Reverse ProxyNginxLoad balancing, SSL termination
App ServerPHP-FPM 8.4Menjalankan Laravel
Cache & QueueRedis 7Cache + job queue broker
DatabaseMySQL 8.0Penyimpanan data utama
Queue WorkerLaravel HorizonBackground job processing
WebSocketLaravel ReverbRealtime chat
Push NotificationFirebase FCMNotifikasi mobile
File StorageS3-compatibleUpload foto, attachment

Skalabilitas Bertahap

Tahap 1 — Satu Sekolah (Awal)

1 VM (4 vCPU, 8GB RAM)
├── Nginx
├── Laravel (PHP-FPM)
├── MySQL
├── Redis
├── Queue Worker (1 instance)
└── Reverb WebSocket

Tahap 2 — Multi Sekolah (Berkembang)

Load Balancer
├── App Server 1 (Laravel)
├── App Server 2 (Laravel)
├── App Server 3 (Laravel)
├── MySQL Primary + Read Replica
├── Redis Cluster
└── Queue Worker (Multiple)

Tahap 3 — Nasional (Scale)

CDN (Global)
Kubernetes Cluster
├── Microservice: Auth
├── Microservice: Matching
├── Microservice: Meeting
└── Microservice: Notification
MySQL Sharding + Redis Cluster

Konfigurasi Nginx

server {
listen 443 ssl http2;
server_name api.temubelajar.id;

ssl_certificate /etc/ssl/temubelajar.crt;
ssl_certificate_key /etc/ssl/temubelajar.key;

root /var/www/temubelajar/public;
index index.php;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}

# Rate limiting
limit_req_zone $binary_remote_addr zone=api:10m rate=60r/m;
location /api/ {
limit_req zone=api burst=20 nodelay;
}
}