Chapter 6 — Platform-as-a-Service (PaaS)

PaaS abstracts away the server entirely. You push code, the platform handles building, deploying, scaling, SSL, and infrastructure. You focus purely on your application.

What PaaS Manages For You

┌─────────────────────────────────────────────────────────┐ │ What YOU do: │ │ ┌───────────────────────────────────────────────────┐ │ │ │ Write code → git push → Done │ │ │ └───────────────────────────────────────────────────┘ │ ├─────────────────────────────────────────────────────────┤ │ What the PLATFORM does: │ │ • Detects language/framework (buildpacks) │ │ • Installs dependencies │ │ • Builds your app │ │ • Deploys to containers │ │ • Provisions SSL certificate │ │ • Routes traffic (load balancing) │ │ • Manages logs │ │ • Handles OS updates and security patches │ │ • Scales horizontally (if configured) │ └─────────────────────────────────────────────────────────┘

Provider Comparison

PlatformFree TierPaid FromStrengthsLimitations
Railway$5 credit/mo$5/moModern, fast deploys, good DXNewer, smaller community
RenderStatic free, services spin down$7/moHeroku alternative, auto-deployCold starts on free tier
Fly.io3 shared VMs freePay-per-useEdge deployment, Docker-nativeMore complex than others
HerokuNone (removed)$5/moPioneer, huge ecosystemExpensive at scale, aging
Google App EngineLimited freePay-per-useGoogle infrastructure, auto-scaleVendor lock-in
Azure App ServiceLimited free~$13/moEnterprise, .NET nativeComplex pricing

Example: Deploying to Railway

# Your project needs:
# 1. A start command (in package.json, Procfile, or Dockerfile)
# 2. Listen on the PORT environment variable

# package.json
{
  "scripts": {
    "start": "node server.js"
  }
}

# server.js — must use process.env.PORT
const port = process.env.PORT || 3000;
app.listen(port, '0.0.0.0');

# Deploy:
# Option A: Connect GitHub repo in Railway dashboard (auto-deploys on push)
# Option B: Railway CLI
npm install -g @railway/cli
railway login
railway init
railway up

Procfile (Heroku-style Process Declaration)

# Procfile — tells the platform what processes to run
web: node server.js
worker: node worker.js
release: node migrate.js    # Runs before each deploy

When PaaS is the Right Choice

Use PaaS when:
• Small team (1-5 devs) that wants to focus on product, not infrastructure
• Predictable, moderate traffic (not massive spikes)
• Standard web app (HTTP server + database)
• Fast iteration speed matters more than cost optimization
• You don't need custom system-level software

Avoid PaaS when:
• Cost-sensitive at scale (PaaS markup is 3-10x vs raw compute)
• Need custom networking, kernel modules, or system packages
• Compliance requires specific infrastructure control
• Traffic is highly variable (serverless may be cheaper)
• You need persistent local storage or specific hardware

The PaaS Cost Trap

PaaS is cheap to start but expensive to scale. A $7/mo Render service running a Node.js app is great. But when you need 4 instances + a managed database + Redis + background workers, you're suddenly paying $200/mo for what a $40/mo VPS could handle.

The professional pattern: Start on PaaS for speed. When monthly costs exceed what a VPS + your time would cost, migrate to containers on a VPS or IaaS. This is called "graduating" from PaaS.