Multiple PowerSync Instances
Scaling using multiple instances
Overview
Multiple instances are not required in most cases. See the Overview for details on standard horizontal scaling setups.
When exceeding a couple thousand concurrent connections, the standard PowerSync setup may not scale sufficiently to handle the load. In this case, we recommend you contact us to discuss the options. However, we give a basic overview of using multiple PowerSync instances to scale here.
Each PowerSync “instance” is a single endpoint (URL), that is backed by:
- One replication container.
- Multiple API containers, scaling horizontally.
- One bucket storage database.
This setup is described in the Overview.
To scale further, multiple copies of this setup can be run, using the same source 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.
Was this page helpful?