In my recent interview, I got the following question:
There are multiple instances of a microservice, each connects to the same relational database (let's say postgres). How can you ensure data consistency and concurrency, if you cannot rely on the database to do it for you?
Generally I'd say that there is no problem with multiple instances using the same database, as the db can handle concurrent connections, even when the services try to update the same table, or same rows. But what I don't understand is what can we do if the database, for some reason, cannot handle concurrency?