Kantoor. Cluster
(Kantoor v1.0.0)
Several replicas of Kantoor behind a load balancer, each one a plain copy of the others: none is special, and any of them can serve any connection.
What must be exact lives in Postgres (login lockouts and rate limits, the mail
index, DAV sync tokens, staged attachments). What only has to be fast is carried
between the replicas by Phoenix.PubSub over Erlang distribution: a message
ingested on one replica wakes the IMAP IDLE sessions and open pages on the others
at once. Distribution is only a speed-up. Every waiting party also re-checks the
database on a timer, so a replica that has not joined yet, a netsplit or a lost
message costs seconds, never an update (Kantoor.CatchUp).
Replicas find each other through the database they already share, with the
libcluster_postgres strategy: each announces its node name on a Postgres
channel and dials the others it hears. The announcement needs a direct
connection to Postgres (LISTEN does not survive a transaction-mode pooler), so
it has its own setting.
Settings
KANTOOR_CLUSTER=trueturns it on (defaultfalse: one replica, no distribution).KANTOOR_CLUSTER_DATABASE_URLis the directpostgres://URL used for discovery. Without itKANTOOR_DIRECT_DATABASE_URLis used, and without thatDATABASE_URL, except withKANTOOR_DATABASE_POOLERon (DATABASE_URLthen goes through the pooler): discovery stays off and the log says so. The replicas stay correct through the database (Kantoor.CatchUp); only the speed-up of distribution is missing.RELEASE_COOKIE(required when clustering) is the shared secret of distribution;RELEASE_NODEdefaults tokantoor@<pod IP>(KANTOOR_NODE_HOSToverrides the address);KANTOOR_DIST_PORT(default9100) is the one port distribution listens on. Seerel/overlays/bin/serverand the guide "Running several replicas".
If discovery cannot reach the database it logs and keeps retrying; Kantoor runs unclustered on the database catch-up meanwhile.
Summary
Functions
Supervisor children for the application tree.
Whether clustering is switched on.
The libcluster topologies for this node, [] when clustering is off or misconfigured.
Functions
@spec children() :: [Supervisor.child_spec() | {module(), term()}]
Supervisor children for the application tree.
@spec enabled?() :: boolean()
Whether clustering is switched on.
@spec topologies() :: keyword()
The libcluster topologies for this node, [] when clustering is off or misconfigured.