I have a case where I need geographically distributed read models. They are supposed to be exact copies of each other but in different countries. They are not accessible from the Internet, only from the internal worldwide network.
I would like the clients to automatically choose the read model that is closest to them.
How would I go about to implement this? How do CDNs work in this sense? Is it done with DNS settings or is i more to it?
I can imagine that I could have some sort of setting for a user that would point out the server to use, but I would rather use some automagic thing at play as the users may travel.
I guess the read models in this case should expose a http endpoint to serve up the data rather than allowing direct access to read model persistence.
As you might have guessed, the solution is just at an idea stage at this point.
There are all kind of options here. You could even potentially use a SQL solution for your read models where the client is only given read permissions over the view models so you don’t have to worry
In terms of picking the “closest” view model, a DNS-based solution would work. There are a bunch of DNS solutions that can be used to accomplish this. Or you could do something client side where it calculated the number of hops between it and the client and then picks that instance.