Migrations Migrating from Heroku, Render, Hatchbox or Cloud 66? We move your production app within 48 hours →
Database servers

Database servers

Keep data off the app server: database servers, standbys, backups by default, a connection pooler, Postgres upgrades, forks with masking and outside URLs.

By default an app’s databases run on the same server as the app. That’s cheap and fast, but if that server is lost, only your backups survive. A database server is one of your own servers that only holds data.

Add a database server

Servers → + Add a database server. It works like adding a server, with a few differences:

  • It gets no web proxy and no build tools, and apps are never deployed to it.
  • Its datastore ports are open only to the app servers that use it.
  • Its page lists the apps whose data it holds.

Choose where an app’s data lives

When you create an app, Where should the data live? offers three choices:

  • This server: the app’s own server.
  • A database server: preselected for production when your team has one.
  • External: paste the URL of a managed service such as RDS, ElastiCache or Elastic Cloud.

For an existing app, go to Settings → Resources → Move data to a database server. The card lists what will be copied and what starts empty before you press the button. Then:

  1. The app stops.
  2. Postgres and MySQL are dumped and restored on the database server.
  3. Redis, MongoDB, object storage, RabbitMQ definitions and ClickHouse are copied too. An Elasticsearch that only this app uses is copied as well.
  4. The app redeploys.

If any step fails, the app goes back to its old data, which is only read and never changed. Memcached isn’t copied, and neither is an Elasticsearch shared with another app: reindex after the move.

Use an outside service on the Resources tab switches the database, Redis or Elasticsearch to a URL you give. Railyard checks the URL first. An unreachable one changes nothing, and your app isn’t stopped. You can copy the data across, and Bring back under Railyard reverses it.

Protected by default

  • Backups. App databases on a database server get a backup every 24 hours, and each one is checked by restoring it. A schedule you set on the database card is kept.
  • Standby (Scale, Team and Agency). Also create a standby on Add a database server creates a second database server of the same size. Once both are up, it keeps a live copy of Postgres, MySQL and Redis, and an engine you start using later is copied too. Railyard checks every standby every 5 minutes, shows how far behind it is, and alerts you (rules with data maintenance ticked) if it stops following or falls more than 5 minutes behind, and again when it catches up.
  • Automatic failover. If a database server stops answering for 3 minutes and its standby has lost contact with it too, the standby takes over: it serves the data on the usual ports, every app using the database server redeploys against it, and point-in-time recovery turns back on there. You get a notification listing what moved. Turn it off per server under Maintenance → Database replicas.
  • Promote by hand from the primary’s page (Maintenance → Database replicas) or from the standby’s own page. It does the same takeover. Writes the old server took in its last seconds may be lost, so use it when the primary is gone or you accept that.
  • Make it the new standby. When the old server comes back, its page says it was replaced and no app uses its out-of-date data. Make it the new standby copies fresh data from the new primary, so the next failure is covered too.
  • Not replicated: Elasticsearch and a dedicated per-app Redis start empty on the standby after a failover. Apps reindex Elasticsearch automatically after their redeploy.

A database server counts as one of the servers your plan includes, so Launch’s two servers cover an app server and a database server. Standbys come with Scale, Team and Agency.

You can also add a replica of a single engine to any other team server from Maintenance → Database replicas. A promoted replica keeps its own address, separate from the primary; point apps at it yourself.

Connection pooler

There are two switches:

  1. Server → Maintenance → Connection pooler → Turn on. This keeps a large number of app connections efficient against a small number of real Postgres connections. Rails’ prepared statements still work.
  2. App → Resources → Database card → Use the pooler. From the next deploy, DATABASE_URL goes through the pooler and DATABASE_DIRECT_URL keeps the direct address.

The release step (migrations) always uses the direct address, because advisory locks don’t work through transaction pooling. Choosing the pooler for an app also starts it on the server if it isn’t running. You can’t turn a server’s pooler off while an app uses it.

Postgres major-version upgrades (beta)

Server → Maintenance → Postgres version.

  1. Check compatibility. This is a dry run and changes nothing. It checks each database’s extensions against the new version and makes sure there’s about twice the data size in free disk.
  2. Upgrade now, or In the next maintenance window. Railyard backs up every database first, and any failed backup stops the upgrade. Each database is copied into the new version and its tables are counted to confirm the copy. Then the new version takes over the same port, so apps keep their DATABASE_URL. App logins are paused during the copy.
  3. Roll back while the old version is kept (7 days by default). Anything written after the upgrade is not in the old version.

Fork a database

App → Resources → Database card → Fork this database (Postgres).

  • Into: a new database on any server with Railyard-managed Postgres, which gets its own login and password. Or replace a staging or preview environment’s data. Production is never a target.
  • From: a live copy taken now, or the latest backup.
  • Mask: paste SQL, for example UPDATE users SET email = 'user' || id || '@example.test', phone = NULL;. It runs on the copy before anyone can use it. If it fails, the copy is deleted, so there’s never an unmasked fork.

Per-column masking rules in the UI and instant copy-on-write forks aren’t built yet.

Maintenance windows

Set a weekly slot under Team → Maintenance, or per server under Settings → Data maintenance window. Railyard sends notice to rules with data maintenance ticked. Inside the window it runs scheduled Postgres upgrades, security updates on database servers and VACUUM (ANALYZE). With no window set, nothing runs on its own.

A dedicated Redis per app

By default apps share the server’s Redis, each with its own database number. Give this app its own Redis on the Redis card sets a memory limit and what happens when it’s full (an eviction policy such as allkeys-lru). Your keys are copied across. Go back to the shared Redis copies them back.

API

MethodPathPurpose
POST/api/applications/:id/data_moveMove data to a database server (database_server_id)
POST / DELETE/api/applications/:id/external_datastoresUse an outside URL, or bring the data back
GET / POST/api/servers/:id/database_replicasList or add standbys; POST …/:id/promote promotes
POST/api/servers/:id/standby_rejoinMake a replaced server the new primary’s standby
GET / POST / DELETE/api/servers/:id/connection_poolerThe server’s connection pooler
GET / POST/api/servers/:id/postgres_upgradesCheck, schedule, roll back and clean up upgrades
GET / POST / DELETE/api/applications/:id/database_forksForks (source is live or backup, optional mask_sql)
GET / PATCH/api/applications/:id/redisShared or dedicated Redis, memory limit and policy

Backups, restores and consoles are covered in Databases and backups. For the version, backup schedule and connection details of one engine at a time, see Postgres, Redis, MySQL and MongoDB.

Found an issue or have a question?
Theme
Colors