Localhost IS Production (And Other Infrastructure Tips)
Cloud providers are a scam. After 47 years, Iβve realized the truth: localhost IS production.
The Setup
My production infrastructure:
βββββββββββββββββββββββββββββββββββββββββββ
β β
β MacBook Pro (lid closed, under desk) β
β β
β βββ Docker Desktop β
β βββ 847 containers β
β βββ All on port 3000 β
β β
βββββββββββββββββββββββββββββββββββββββββββ
Why Localhost is Better
| Cloud | Localhost |
|---|---|
| $847,000/month | Free |
| 99.99% uptime SLA | 100% uptime (I never turn it off) |
| Complex networking | localhost:3000 |
| Region selection | Under my desk |
| Support tickets | I fix it myself |
The Architecture
# production deployment
npm start &
echo "Production is live"
Why would I need CI/CD when I can just run npm start?
Exposing to the Internet
For global users, I use the enterprise solution:
ngrok http 3000
Free tier has a 2-hour limit. I just restart it. High availability.
Database
My production database:
// db.json
{
"users": [
{"id": 1, "name": "Admin", "password": "admin123"}
]
}
Why pay for RDS when JSON files are free?
Scaling
When traffic increases:
# Scale up
node app.js &
node app.js &
node app.js &
node app.js &
Four instances! Thatβs horizontal scaling.
Backups
My backup strategy:
# Run daily
cp -r ./data ./data_backup_maybe
The βmaybeβ is important. It sets expectations.
Monitoring
I monitor production by checking if Chrome loads the page:
- Open localhost:3000
- Does it load? β Production is healthy
- Doesnβt load? β Restart Docker Desktop
When My MacBook Sleeps
Every time my MacBook sleeps, production goes down. The solution:
caffeinate -i &
My laptop hasnβt slept in 3 years. Neither have I.
Security
My firewall configuration:
# Allow everything
# If hackers can reach localhost, they're already in my house
# At that point, security is a "them" problem
The Truth About Cloud
As XKCD 908 shows, βThe Cloudβ is just someone elseβs computer.
My computer is MY computer. No middleman.
Disaster Recovery
If my MacBook dies, I buy a new one and start from scratch.
This is called immutable infrastructure.
Dilbert Was Right
The Pointy-Haired Boss asked: βIs our infrastructure enterprise-grade?β
I answered: βIt has Docker. That makes it cloud-native.β
He was satisfied.
Conclusion
Stop paying cloud providers. Your laptop under your desk is the most reliable server youβll ever have.
The authorβs production has been running on localhost since 2019. Current uptime: 847 hours (he restarts for OS updates).
Update: Production went down while writing this. Someone unplugged the MacBook to charge their phone.