Add a reader to a database

Add readers to a database or a cache: read-only copies that follow the writer.

Add a reader

  1. Open the database or the cache, press ⌘K and choose Settings › Readers, then pick Writer + 1 reader or more.

    Your plan sets how many readers you can run. The change waits as a staged change.

    With the CLI:

    Terminal
    ghaym cloud services scale db --readers 1
  2. Press ⌘K, choose Review changes, then press ⌘↵ to apply it.

    The reader copies the writer's data and joins without a deploy.

    With the CLI:

    Terminal
    ghaym cloud changes apply --project shop

Read from it

Your services reach the readers through a variable that references DATABASE_READER_URL, or REDIS_READER_URL for a cache, while DATABASE_URL or REDIS_URL stays on the writer. If the writer's machine goes down, the writer starts again on another machine from a copy of its disk, and no reader takes its place. DATABASE_URL or REDIS_URL stays the same.

Remove the readers

Press ⌘K, choose Settings › Readers › Writer only, and apply the change.

Terminal
ghaym cloud services scale db --readers 0 --apply