I am trying to dive into Microservice architecture to start coding some of small pieces of logic for my company.
I know one of microservices concerns is about the database handling (each microservice must have its separated db schmema). So I am looking for pieces of advice or experiences about to move out from an old to new microservice version.
So lets say I have a REST API endpoint ms/v1/whatEver
which is running today on prod. After a week we decide to go live with the next version of it. So that we create a ms/v2/whatEver
which has some new columns and data types in the entities envolved in this service. Thus in order to not force all clients to migrate immediately we want to keep both versions up and running till users move in progressively to v2
.
A couple of scenarios come up in to my mind if we have both version up and running (which actually is my main doubt and the reason of this post):
Should they read/write in the same DB instance, hence
v1
implementation must be adapted to match with the new schema structure ofv2
?Should they read/write in a separate DB instance. So in any manner both DBs have to be synchronised till the day we decide to turn off
v1
to guarantee we do not miss any data (eventual consistency)? So my question here is how to accomplish that (throughout framework, queue messaging, or something..)Or, code forwarding every
v1
request (inside of it) tov2
which is going to be the owner of the already migrated new schema (unique DB instance)?
I have been reading a couple of books like Migrating to Microservices Databases - Red Hat but they are written in concept terms but nothing specific with technologies or best things to do whit this. So that my post.
I really appreciate your opinions. Thanks