Fly.io Machines
Fly.io Machines Tech Conference Edge Computing Global Deployment Firecracker MicroVM Auto-scaling Anycast Scale to Zero Live Streaming WebSocket Real-time
| Platform | Edge | Scale to Zero | Boot Time | เหมาะกับ |
|---|---|---|---|---|
| Fly.io | 30+ Regions | ใช่ | 300ms | Full-stack Edge |
| Cloudflare Workers | 300+ PoPs | ใช่ | 0ms | Edge Functions |
| AWS Lambda | 25+ Regions | ใช่ | 100-500ms | Event-driven |
| Railway | 1 Region | ใช่ | 1-5s | Simple Deploy |
| Vercel | Edge Functions | ใช่ | 0ms | Frontend + API |
Fly.io Setup
# === Fly.io Deployment ===
# Install CLI
# curl -L https://fly.io/install.sh | sh
# fly auth login
# Create App
# fly launch --name tech-conf-2026
# fly deploy
# Dockerfile
# FROM node:20-alpine
# WORKDIR /app
# COPY package*.json ./
# RUN npm ci --production
# COPY . .
# EXPOSE 3000
# CMD ["node", "server.js"]
# fly.toml — Configuration
# app = "tech-conf-2026"
# primary_region = "sin" # Singapore
#
# [build]
# dockerfile = "Dockerfile"
#
# [http_service]
# internal_port = 3000
# force_https = true
# auto_stop_machines = true
# auto_start_machines = true
# min_machines_running = 1
#
# [[vm]]
# cpu_kind = "shared"
# cpus = 2
# memory_mb = 512
#
# [processes]
# app = "node server.js"
# worker = "node worker.js"
# Multi-region Deployment
# fly regions add sin nrt lax ams
# fly scale count 2 --region sin
# fly scale count 1 --region nrt
# fly scale count 1 --region lax
# fly scale count 1 --region ams
# Fly Postgres — Multi-region Database
# fly postgres create --name conf-db --region sin
# fly postgres attach conf-db
# fly postgres connect -a conf-db
from dataclasses import dataclass
@dataclass
class FlyApp:
name: str
regions: int
machines: int
cpu: str
memory_mb: int
status: str
requests_hr: int
apps = [
FlyApp("conf-web", 4, 6, "shared-2x", 512, "Running", 15000),
FlyApp("conf-api", 4, 8, "shared-2x", 1024, "Running", 25000),
FlyApp("conf-ws", 3, 4, "shared-2x", 512, "Running", 8000),
FlyApp("conf-stream", 2, 3, "performance-2x", 2048, "Running", 5000),
FlyApp("conf-db", 2, 3, "performance-4x", 4096, "Running", 0),
]
print("=== Fly.io Apps ===")
for a in apps:
print(f" [{a.status}] {a.name}")
print(f" Regions: {a.regions} | Machines: {a.machines}")
print(f" CPU: {a.cpu} | RAM: {a.memory_mb}MB | Req/hr: {a.requests_hr:,}")
Conference Platform
# === Tech Conference Architecture ===
# Components:
# 1. Conference Website — Next.js on Fly.io
# 2. API Server — FastAPI/Express on Fly.io
# 3. WebSocket Server — Real-time Chat & Q&A
# 4. Streaming — HLS/DASH Video Delivery
# 5. Database — Fly Postgres Multi-region
# 6. Cache — Fly Redis (Upstash)
# 7. Storage — S3-compatible (Tigris on Fly)
# Auto-scaling for Keynote
# fly autoscale set min=2 max=20
# # Or via Machines API:
# curl -X POST "https://api.machines.dev/v1/apps/conf-api/machines" \
# -H "Authorization: Bearer $FLY_API_TOKEN" \
# -d '{
# "config": {
# "image": "registry.fly.io/conf-api:latest",
# "guest": {"cpus": 2, "memory_mb": 1024},
# "auto_destroy": true
# },
# "region": "sin"
# }'
# WebSocket — Real-time Q&A
# const WebSocket = require('ws');
# const wss = new WebSocket.Server({ port: 8080 });
#
# wss.on('connection', (ws) => {
# ws.on('message', (data) => {
# const msg = JSON.parse(data);
# if (msg.type === 'question') {
# // Broadcast to all clients in same session
# wss.clients.forEach(client => {
# if (client.readyState === WebSocket.OPEN) {
# client.send(JSON.stringify({
# type: 'question',
# user: msg.user,
# text: msg.text,
# timestamp: Date.now()
# }));
# }
# });
# }
# });
# });
@dataclass
class ConferenceMetric:
metric: str
value: str
target: str
status: str
metrics = [
ConferenceMetric("Registered Attendees", "5,200", "5,000", "Exceeded"),
ConferenceMetric("Live Viewers (Peak)", "3,800", "3,000", "Exceeded"),
ConferenceMetric("API Latency (p99)", "45ms", "< 100ms", "OK"),
ConferenceMetric("WebSocket Connections", "2,100", "< 5,000", "OK"),
ConferenceMetric("Stream Bitrate", "1080p 6Mbps", "720p+", "OK"),
ConferenceMetric("CDN Cache Hit", "95%", "> 90%", "OK"),
ConferenceMetric("Error Rate", "0.02%", "< 0.1%", "OK"),
ConferenceMetric("Monthly Cost", "$280", "< $500", "Under Budget"),
]
print("\nConference Dashboard:")
for m in metrics:
print(f" [{m.status}] {m.metric}: {m.value} (target: {m.target})")
Cost และ Optimization
# === Cost Optimization ===
# Fly.io Pricing (approximate)
# shared-cpu-1x, 256MB: $1.94/mo (running 24/7)
# shared-cpu-2x, 512MB: $3.88/mo
# performance-2x, 2GB: $31.00/mo
# Scale to Zero: pay only when running
# Conference Cost Breakdown
cost_items = {
"Web App (4 regions, 6 machines)": "$23/mo",
"API Server (4 regions, 8 machines)": "$62/mo",
"WebSocket (3 regions, 4 machines)": "$16/mo",
"Streaming (2 regions, 3 machines)": "$93/mo",
"Postgres (2 regions, HA)": "$50/mo",
"Bandwidth (500GB)": "$25/mo",
"Persistent Volumes": "$15/mo",
"Total": "$284/month",
"During Conference (scaled up)": "~$50/day extra",
}
print("Cost Breakdown:")
for item, cost in cost_items.items():
print(f" {item}: {cost}")
# Scale to Zero Strategy
# Before conference: min_machines = 1
# During keynote: auto-scale to 20
# After conference: scale to zero
# Cost saving: ~70% vs always-on
optimization_tips = [
"Scale to Zero: ใช้ auto_stop เมื่อไม่มี Traffic",
"Shared CPU: ใช้ Shared CPU สำหรับ Web และ API",
"Performance: ใช้ Performance CPU สำหรับ Streaming เท่านั้น",
"Region: Deploy เฉพาะ Region ที่มีผู้เข้าร่วม",
"CDN: ใช้ Fly CDN Cache Static Assets",
"Pre-warm: Scale up ก่อน Keynote 15 นาที",
"Monitor: ใช้ fly logs และ fly status ติดตาม Real-time",
]
print(f"\n\nOptimization Tips:")
for i, t in enumerate(optimization_tips, 1):
print(f" {i}. {t}")
เคล็ดลับ
- Scale to Zero: auto_stop_machines ประหยัดเงินมาก
- Multi-region: Deploy ใกล้ผู้ใช้ Latency ต่ำ
- Postgres: ใช้ Fly Postgres Multi-region HA
- Pre-warm: Scale up ก่อนงาน Event ป้องกัน Cold Start
- CLI: fly deploy ง่ายสุด ใช้ได้ทุก Language
Fly.io คืออะไร
Platform Deploy ใกล้ผู้ใช้ Firecracker MicroVM 30+ Region Docker Auto-scaling Anycast Persistent Volume Free Tier CLI ง่าย
Fly Machines คืออะไร
MicroVM 300ms Boot เปิดปิดทันที Scale to Zero จ่ายเฉพาะรัน Auto-start Event-driven Conference App ประหยัด
ใช้ Fly.io จัด Tech Conference อย่างไร
Website Multi-region Streaming WebSocket Chat API Schedule Postgres Database CDN Static Auto-scale Keynote Traffic
Fly.io เทียบกับ Cloud อื่นอย่างไร
Fly.io Edge 30+ Region Boot 300ms Scale to Zero AWS Lambda Cold Start Cloudflare Workers จำกัด Vercel Frontend Railway Simple Full-stack Global
สรุป
Fly.io Machines Tech Conference Edge Computing Global Deployment Firecracker MicroVM Auto-scaling Scale to Zero WebSocket Streaming Multi-region Postgres CDN Production
