High Availability¶
Connect HA is several identical Connect nodes sharing one PostgreSQL database and one data directory, behind a load balancer.1 The nodes are not aware of each other; the load balancer does all routing. HA (load-balanced clusters) requires the Enhanced license tier or higher.2
graph TB
Internet(["Users"]) --> LB(["Load balancer<br/>connect-public.example.com<br/>TLS termination, sticky sessions"])
LB -->|"HTTP"| N1("Connect node 1")
LB -->|"HTTP"| N2("Connect node 2")
N1 --> DB[("PostgreSQL<br/>connect")]
N2 --> DB
N1 --> NFS[("Shared DataDir<br/>NFS / EFS / Azure NetApp Files")]
N2 --> NFS
style N1 fill:#fdf1e3,stroke:#c9822b,stroke-width:2px,color:#1a1a1a
style N2 fill:#fdf1e3,stroke:#c9822b,stroke-width:2px,color:#1a1a1a
style DB fill:#f1eaf6,stroke:#7a4f9a,stroke-width:2px,color:#1a1a1a
Requirements checklist¶
| Requirement | How to verify |
|---|---|
| Same Connect version on every node | dpkg -l rstudio-connect (Debian/Ubuntu) or rpm -q rstudio-connect (RHEL/SUSE)1 |
| Same PostgreSQL database for all nodes | [Postgres] URL identical |
Server.DataDir on shared storage, same path on every node |
df -h <DataDir> on each node1 |
Server.LocalDataDir on local disk on every node |
df -h <LocalDataDir> on each node1 |
Server.LandingDir shared, if used |
same1 |
Same encryption key (lives in the shared DataDir/db) |
ls -l <DataDir>/db/secret.key3 |
Same UID and GID for rstudio-connect and every RunAs account |
id rstudio-connect on each node1 |
| Synchronized clocks | chronyc tracking1 |
| Sticky sessions and websockets at the load balancer | LB config1 |
NFS mounted with lookupcache=pos |
findmnt -no OPTIONS <mount>1 |
| Same R, Python, Quarto versions and system libraries | posit-host on each node |
Posit says identical configuration files are not strictly required. However, in practice, every difference is a bug waiting for the unlucky user who lands on the other node.1 Keep one config file in version control and deploy it to every node.
Detecting config drift¶
diff <(ssh con-ext-01 sudo cat /etc/rstudio-connect/rstudio-connect.gcfg) <(ssh con-ext-02 sudo cat /etc/rstudio-connect/rstudio-connect.gcfg)
Typical drift found in the field:
| Setting | Node 1 | Node 2 | Fix |
|---|---|---|---|
SAML.IdPSigningCertificate |
commented out | set | Set on both so assertions are verified everywhere |
CORS.EnforceWebsocketOrigin |
false |
true |
true on both |
| R versions installed | 4.4.0, 4.5.1 | 4.5.1, 4.5.2 | Same list on both |
Shared storage¶
Connect supports NFS v3 or v4 and Amazon EFS for the shared data directory. Mount with lookupcache=pos so one node sees files the other just created:1
On Azure, Posit's own reference architecture uses Azure NetApp Files rather than Azure Files; follow it for mount and capacity settings.4
Ownership on the data directory must match the original install. A fresh DataDir on a new share:
Subdirectories (apps, bundles, db, packrat, python-environments, R, reports, and others) are created by Connect with their own owners.5 When migrating, copy them with rsync -a as root so ownership and modes are preserved; see Migration.
Upgrading HA nodes¶
- Stop Connect on every node
- Upgrade one node and start it; it migrates the database schema
- Upgrade and start the remaining nodes
A node left running on the old version detects the newer schema within about 30 seconds and shuts itself down, but do not rely on that.1
Metrics across nodes¶
Each node reports its own metrics. Use Prometheus to aggregate them, rather than reading one node's dashboard and assuming it reflects the cluster.6