Hi all - I am currently running a single node Typesense machine on Fly, but would like to update this to a cluster. My current workaround for a single node (since Typsense only supports IPv4) is from this Fly.io thread using socat
and supervisor
to route IPv6 from Fly to Typsense IPv4.
However with multiple nodes, I feel like this gets a bit complicated. In the Typesense GitHub someone posted their ability to get a cluster working using 6Tunnel
and “tricking” each node to communicate locally(?) and then use 6Tunnel to route to other nodes. You can find the post here
But in summary I’d need to run:
# Listen on IPv6 ports 8108 and make available via the defined api port for the node. For External Traffic
6tunnel -6 -l :: 8108 localhost $api_port
# Listen on IPv6 ports $api_port and make available via the defined api port for the node. For Cross-Node Traffic
6tunnel -6 -l <private v6 ip> $api_port localhost $api_port
6tunnel -6 -l <private v6 ip> $peering_port localhost $peering_port
# API and Peering tunnels for other nodes
6tunnel -4 -l localhost <node 2 api port> <node 2 private v6 ip>
6tunnel -4 -l localhost <node 2 peering port> <node 2 private v6 ip>
6tunnel -4 -l localhost <node 3 api port> <node 3 private v6 ip>
6tunnel -4 -l localhost <node 3 peering port> <node 3 private v6 ip>
I honestly don’t know which IPs from Fly I should be adding to this section and I’m hoping just referencing the internal url that Fly provides here accomplishes the same thing, here’s what I currently have but doesn’t seem to communicate correctly (currently hardcoded in Go, where I ripped most of it from the nats-cluster
example you guys created). This would be an example of an LAX node that would like to communicate with another node in SJC:
exec.Command("6tunnel", "-6", "-l", "::", "8108", "localhost", "8062").Run()
exec.Command("6tunnel", "-6", "-l", "lax.foundry-typesense-cluster.internal", "8062", "localhost", "8062").Run()
exec.Command("6tunnel", "-6", "-l", "lax.foundry-typesense-cluster.internal", "8107", "localhost", "8107").Run()
exec.Command("6tunnel", "-4", "-l", "localhost", "8063", "sjc.foundry-typesense-cluster.internal").Run()
exec.Command("6tunnel", "-4", "-l", "localhost", "8107", "sjc.foundry-typesense-cluster.internal").Run()
svisor.AddProcess(
"typesense-server",
"typesense-server --data-dir=/data --api-key=xxx --api-port=8062 --peering-port 8107 --nodes=/etc/typesense-nodes --reset-peers-on-error",
supervisor.WithRestart(0, 1*time.Second),
)
There’s also an additional peering-address
flag you can add which needs a private IPv4 address of the specific node and I have no clue how to get something like that considering the Fly internally uses IPv6? When I don’t add the flag it binds to a 172 address.
Each machine needs a typesense-nodes
file so that Raft
knows all ips/ports of the cluster too, which I’ve set as (first would be for LAX, the other would be a SJC node):
localhost:8107:8062,localhost:8107:8063
I thought I should be using localhost since the 6tunnel
would be routing communication of the unique ports (8062 and 8063) to the respective node.
The complete HA documentation can be found here
This is sort of a hybrid Fly.io / Typesense question, so I hope I provided enough background and would really appreciate any insight or suggestions. Thank you!!