Cluster Mode
View SourceThis document explains how to enable and use Tornex's cluster mode.
Overview
Cluster mode leverages horde to allow Tornex to run across multiple BEAM nodes while distributing API calls and API ratelimiting across the nodes.
Installation
Add Tornex and horde to your mix.exs:
defp deps do
[
{:tornex, "~> 0.4"},
{:horde, "~> 0.9"}
]
endSetting Up Cluster Mode
- Set the
:localconfiguration key tofalse. - Add the
Tornex.Scheduler.Supervisorsupervision tree to your application's supervision tree as normal. - Use a library such as libcluster to connect nodes to the cluster upon startup. Horde will automatically synchronize cluster membership and handle transferring
Tornex.Scheduler.Bucketto new nodes.
Using Tornex in Cluster Mode
When cluster mode is enabled, Tornex will:
- Distribute workers and processes across all nodes.
- Ensure unique process registration cluster-wide.
- Automatically handle node joins and leaves.
Use Tornex as usual; clustering is transparent. Workers and processes will be supervised and registered on any available node.
Monitoring Cluster State
You can inspect cluster membership and running processes using Horde’s APIs:
Horde.Cluster.members(Tornex.Registry)
Horde.Cluster.members(Tornex.Supervisor)Troubleshooting
- Ensure all nodes share the same cookie.
- Confirm network connectivity between nodes.
- Update the
horde_memberslist or use libcluster for automatic discovery. - Check log output for errors related to Horde or Tornex initialization.