# High Availability
You can run a cluster of Typesense nodes for high availability. Typesense uses the Raft consensus algorithm to manage the cluster and recover from node failures.
Since Raft requires a quorum for consensus, you need to run a minimum of 3 nodes to tolerate a 1-node failure. Running a 5-node cluster will tolerate failures of up to 2 nodes, but at the expense of slightly higher write latencies. Therefore, we recommend running a 3-node Typesense cluster.
In Typesense Cloud (opens new window), we manage High Availability for you, when you flip the setting ON when launching the cluster. So the rest of this section only applies if you are self-hosting Typesense.
# Configuring a Typesense cluster
To start a Typesense node as part of a cluster, create a new file on each node that's part of the cluster with the following format, and use the
--nodes server configuration to point to the file.
Each node definition in the file should be in the following format, separated by commas:
These values should match the corresponding Server Configuration Parameters used when starting the Typesense process on each node.
Here's an example of a
--nodes file for a 3-node cluster:
In the example above
peering_address(the IP address used for cluster operations) is
peering_port(the port used for cluster operations) is
api_port(the actual port to which clients connect to) is
Here's the corresponding command to start the Typesense process on each node:
--peering-addressshould be a Private IP address, since it is only meant for internal cluster operations and contains unencrypted Raft data that is exchanged between nodes.
--api-addresscan be a public or private IP address. This is the IP address that your end users/clients will connect to interact with the Typesense API.
We strongly recommend setting
--api-portto 443 (HTTPS) in a production setting, and configuring SSL certs using the
If you are using Docker, make sure that you've configured the Docker network in such a way that the Typesense process within the Docker container can communicate with the other Typesense processes using their IP addresses. Read more about Docker Networking (opens new window).
# Client configuration
Typesense clients allow you to specify one or more nodes during client initialization.
Client libraries will load balance reads and writes across all nodes and will automatically strive to recover from transient failures through built-in retries.
Here's a sample 3-node client configuration: