Skip to content

Commit

Permalink
'modified: docs/how-to/h-set-up/h-scale.md' (#582)
Browse files Browse the repository at this point in the history
Co-authored-by: discourse-gatekeeper-docs-bot <[email protected]>
  • Loading branch information
github-actions[bot] and discourse-gatekeeper-docs-bot authored Jul 23, 2024
1 parent 110d362 commit ea071d6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docs/how-to/h-set-up/h-scale.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ To deploy PostgreSQL with multiple replicas, specify the number of desired units
juju deploy postgresql-k8s --channel 14/stable -n <number_of_replicas>
```

To retrieve the primary replica, use the action `get-primary` on any of the units running `postgresql-k8s`
### Primary vs. leader unit

The [PostgreSQL primary server](https://www.postgresql.org/docs/current/runtime-config-replication.html#RUNTIME-CONFIG-REPLICATION-PRIMARY) unit may or may not be the same as the [juju leader unit](https://juju.is/docs/juju/leader).

The juju leader unit is the represented in `juju status` by an asterisk (*) next to its name.

To retrieve the juju unit that corresponds to the PostgreSQL primary, use the action `get-primary` on any of the units running ` postgresql`:
```shell
juju run postgresql-k8s/leader get-primary
```

Similarly, the primary replica is displayed as a status message in `juju status`. However, one should note that this hook gets called on regular time intervals and the primary may be outdated if the status hook has not been called recently.

### `update-status` hook
**We highly suggest configuring the status hook to run frequently.** In addition to reporting the primary, secondaries, and other statuses, the status hook performs self-healing in the case of a network cut.
[note]
**We highly suggest configuring the `update-status` hook to run frequently.** In addition to reporting the primary, secondaries, and other statuses, the [status hook](https://juju.is/docs/sdk/update-status-event) performs self-healing in the case of a network cut.

To change the frequency of the `update-status` hook, run
```shell
juju model-config update-status-hook-interval=<time(s/m/h)>
```
Note that this hook executes a read query to PostgreSQL. On a production level server, this should be configured to occur at a frequency that doesn't overload the server with read requests. Similarly, the hook should not be configured at too quick of a frequency, as this can delay other hooks from running.

You can read more about status hooks [here](https://juju.is/docs/sdk/update-status-event).
<!--Note that this hook executes a read query to PostgreSQL. On a production level server, this should be configured to occur at a frequency that doesn't overload the server with read requests. Similarly, the hook should not be configured at too quick of a frequency, as this can delay other hooks from running. -->
[/note]

## Scale replicas on an existing application

Expand Down

0 comments on commit ea071d6

Please sign in to comment.