- Home
- Rails hosting
- Multiple apps on one server
Guide
How to host multiple Rails apps on one server
The cheapest way to run several Rails apps is one server with one proxy that routes by domain, one Postgres with a database per app, and a Puma process for each app. Here's how to lay it out, how much memory it takes, and when to split apps onto their own servers.
Platforms charge per app, so a handful of side projects, client sites, or internal tools can cost more than the work they do. A single 4–8GB server runs most of those together for the price of the server.
How the server is laid out
One proxy, routing by domain
Caddy or Nginx listens on ports 80 and 443 and forwards each domain to the right app. Each app's Puma listens on its own local port or Unix socket. Caddy gets an SSL certificate for every domain on its own.
One Postgres, a database per app
Run a single Postgres server and give each app its own database and its own database user, so one app can't read another's data. One Postgres uses far less memory than one per app.
Separate processes and environments
Each app gets its own directory, environment variables, Puma process, and job worker, supervised by systemd. A crash or a deploy in one app doesn't touch the others.
Ruby versions side by side
A version manager (rbenv, asdf, or mise) lets one app stay on an older Ruby while
another uses the latest, each reading its own .ruby-version.
How many apps fit on one server
Memory runs out before CPU does. Rough figures for a typical app:
- Puma: 200–400MB for a single process, more with several workers.
- Job worker: another 200–400MB. Solid Queue can run inside Puma to save one process per app.
- Postgres: shared by every app. Budget 500MB–1GB for small databases.
- Redis: one shared instance, if any app uses Sidekiq. Give each app its own database number or key prefix.
That puts 3–5 low-traffic apps on a 4GB server and 8–10 on 8GB. Watch memory after each new app, and move the busiest app to its own server when it starts to crowd the others.
Setting it up yourself
With Caddy, each app is a few lines in the Caddyfile. Puma for each app binds to its own port:
app-one.com {
reverse_proxy 127.0.0.1:3001
}
app-two.com {
reverse_proxy 127.0.0.1:3002
}
Then, for each app:
- Create a Postgres user and database for it, and set its
DATABASE_URL. - Put its code in its own directory, with its own environment file holding
PORT,RAILS_MASTER_KEY, and the rest. - Write systemd units for its Puma and job worker that read that environment file.
- Give it its own deploy script or Capistrano config pointing at that directory.
Kamal can also put several apps on one host. Each app has its own
config/deploy.yml with a different proxy host, and one
kamal-proxy routes between them. Share a single Postgres accessory between apps, or
give each app its own on a different port.
With Hatchbox
Hatchbox charges per server, not per app, so the second through tenth apps on a server cost nothing extra. Create each app from its repository on the same cluster and Hatchbox gives it:
- Its own directory, port, environment variables, and supervised processes.
- Its own Postgres or MySQL database and database user, on the shared database server.
- Its own domains in Caddy, each with an automatic SSL certificate.
- The Ruby version from its own
.ruby-version. - Its own deploys, logs, and cron jobs, independent of the other apps.
When one app outgrows the shared server, create a cluster for it, deploy it there, and copy its database across. The other apps don't change.
Multiple Rails apps on one server: questions
Still stuck? Ask us directly — a real person who runs a lot of Rails apps side by side will answer.
What's the cheapest way to host multiple Rails apps?
Can two Rails apps share one Postgres database server?
Can apps on the same server use different Ruby versions?
.ruby-version file. Hatchbox does this for you on every deploy.
Can Kamal deploy multiple apps to one server?
config/deploy.yml.
How much does Hatchbox cost for multiple apps?
When should an app move to its own server?
Simple, predictable pricing.
We charge per server, not per app. Run one application or twenty on the same box — the bill doesn't change.
$15
- Unlimited applications
- Deploy anywhere
- Zero downtime deployments
- Custom domains & free SSL
- Databases, cron jobs & background workers
- Full SSH access to your servers
- Real, human support
- 7 day free trial
Ready to deploy your Rails app?
Hatchbox has run more than 2 million deploys across 24,000+ applications since 2016. Start a 7 day free trial and put yours on a server you own.