Deploying with PlanetScale
Serverless MySQL with branching, horizontal sharding, and global replication.
PlatformsIntermediate
Why
PlanetScale is built on Vitess (used by YouTube) with non-blocking schema changes, database branching for preview, and unlimited connections via connection pooling at the proxy. Platform-as-a-Service adoption grew 24% in 2024 as teams shift from VM management to git-push deploys. the cloud infrastructure market reached $330B in 2024, growing 22% year-over-year (Synergy Research), and PaaS layers capture the majority of new workloads.
When
Use PlanetScale for MySQL apps needing zero-downtime migrations, branching, and horizontal scale. Avoid for apps needing foreign keys (not supported).
How
1. Create — pscale database create mydb
2. Branch — pscale branch create dev main (like git for DB)
3. Connect — pscale connect mydb main --port 3309
4. Migrate — non-blocking, no table locks
5. Deploy request — pscale deploy-request create dev main
6. Promote — schema changes apply to production
7. Shell — pscale shell mydb main
Example
# Create database and branch
pscale database create mydb --region us-east-1
pscale branch create preview main
# Connect locally
pscale connect mydb preview --port 3309
# Now mysql -h 127.0.0.1 -P 3309 works
# Deploy schema changes
pscale deploy-request create preview main
pscale deploy-request list mydb main
pscale deploy-request deploy mydb main 1
# Connection string (no password needed with service token)
mysql://user:pass@host:3306/mydb?ssl={"rejectUnauthorized":true}
Common Problems
- ⚠No foreign keys — PlanetScale doesn't enforce FKs, handle in app logic
- ⚠Deploy request rejected — schema change incompatible, check pscale deploy-request show for reason
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use database branching for preview deploys — each PR gets its own DB branch
- ✓Use pscale deploy-request for all schema changes — reviewed, reversible, non-blocking
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit