Overview
Multiple instances are not required in most cases. See the Overview for details on standard horizontal scaling setups.
- One replication container.
- Multiple API containers, scaling horizontally.
- One bucket storage database.
Mapping users to PowerSync endpoints
Since each PowerSync instance maintains its own copy of the bucket data, the exact list of operations and associated checksum will be different between them. This means the same client must connect to the same endpoint every time, otherwise they will have to re-sync all their data every time they switch. Multiple PowerSync instances cannot be load-balanced behind the same subdomain. To ensure the same user always connects to the same endpoint, we recommend:- Do an API lookup from the client application to get the PowerSync endpoint, don’t hardcode it in the application.
- Either store the endpoint associated with each user, or compute it automatically using a hash function on the user id e.g.
hash(user_id) % n
wheren
is your number of instances.