LiteFS with Multiple Clusters / Primarys

Would it be possible to run multiple clusters per host for LiteFS, where each host hosts their own primary DB? For example (wrong region names, but it’s just an example), for three regions us-east1, us-west1, and eu-north1 (each with static IPs or a single host, no scaling complexity, no consul, just static leases):

us-east1:
primary_db: us-east1.sqlite3
secondary_dbs: us-west1.sqlite3, eu-north1.sqlite3

us-west1:
primary_db: us-west1.sqlite3
secondary_dbs: us-east1.sqlite3, eu-north1.sqlite3

eu-north1:
primary_db: eu-north1.sqlite3
secondary_dbs: us-east1.sqlite3, us-west1.sqlite3

This is essentially a multi-master setup, and my app could use Sqlite’s “ATTACH” functionality for transparent cross database queries.

Maybe another way to describe the idea is sharding my data by region, with each shard being it’s own primary in that specific region.

Yes, you could run multiple LiteFS instances on each node. You just need to make sure your configs have different ports for things like the http.addr and lease.advertise-url.

I haven’t tested ATTACH with LiteFS so you may have issues with it. I would suspect that ATTACH with read-only transactions might work but I would guess that write transactions would not.

Yeah I’ll make a proof of concept and test it out, as ATTACH creates some temporary tables. Thanks for the feedback!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.