My actions before this question: 1) I have read microservices io 2) I have read about shared-database pattern, per-service database pattern, per-schema, per-table and etc...
The problem. I have a service that does some work for tasks spliting and subtask combining work. Task -> multiple subtasks -> combining . I am using Kafka to control task/subtask flow.
It keeps subtask state in DB. When all subtask are ready it takes all subtask values from redis, combine to result and sent to another service.
If i start one more instance of this service then all two service instances will observe a single db. And they could misunderstand state of subtasks if try to manage situation when: A1 get last subtask A2 get one subtask before last substask They both are trying to check amount of ready subtask They both see all subtask ready or one more subtask is not ready.
I know i could resolve problem using REAPITABLE_READ isolation level.
My question is. How to handle such situation? Is it ok one database for multiple instance of the same service or i need use another architecture pattern?
Aucun commentaire:
Enregistrer un commentaire