Say, I had created a product (a mobile application) which serves a lot of clients. Initially, I did not think about data compliance issues and stored all their data on one server. Now, these clients want data compliance in such a way that their data is stored on different servers. What is the best way to segregate this data and write it to different servers with minimal changes in the application so that I am compliant with my clients and also do not incur a lot of cost?
Can proxies/load balancers be used here?
We can assume that we are getting Client ID in every CRUD operation based on which we can write some rule on the proxy to divert the traffic to a database server designated for that Client. This would mean that before performing a CRUD operation on the database, the proxy would have to parse the incoming statement and route it accordingly.
Essentially, if I have 3 clients with ID 1, 2 and 3. I want the database operations to get routed to Database A for Client 1, Database B for Client 2 and Database C for Client 3.
I think something of this sort can be done with HAProxy, nginx, ProxySQL etc. but not too sure whether that would work or not.
Is this a viable option at scale or otherwise? If not, what are the other options where changes in the application are minimal.
EDIT: Schemas of Database A, Database B and Database C are exactly the same.