I'm trying to architect (breakdown) one application we have at my work in a few microservices. Before starting going down to the rabbit hole, I wanted to ask: when is a good idea to create another model+function instead of creating a microservice?
Creating a microservice involves more work than just a few other functions. Especially if that involves some duplication of data. I saw this question/answer that was really great: How do you handle shared concepts in a microservice architecture?
It helped me a lot to start sketching my macroapplication. But I still cannot solve this one; for example, I have multiple resources which have 1) different types and 2) different attributes for the types. This is a many-to-many relationship.
# ResourceType_Attribute table | ID | type_id | attribute_id | |----|---------|--------------| | 1 | 1 | 1 | | 2 | 2 | 1 | | 3 | 2 | 2 |
And we would have a table for type and attribute in the same microservice. But now I want to create a cost calculator of the resource (a function) or a billing service (another microservice). Is it possible to create a new microservice without a big burden?
If I create a cost calculator I'd have to create a new table within the resource manager:
# Cost calculator table | ID | type_id | attribute_id | unit_cost | |----|---------|--------------|-----------| | 1 | 1 | 1 | 10| | 2 | 2 | 1 | 1| | 3 | 2 | 2 | 4|
Supposedly now that we have a resource of type_id 2 that has a value of 10 for attribute_id 1 and value of 10 for attribute_id 2. That makes the cost calculation: 10*$10 + 10*$4 = $140.
Having a model+function within the resource manager to handle this problem makes it easier to make changes in the unit_cost column. Since I know what is in attribute_id and in type_id.
On the other hand, if I have a whole new microservice for this table, I won't know what prices I'm updating without consulting the attribute and type tables. I will only have their ids and I have to go to the other database to check what is going on where.
Am I understand the concept of this? If not, please help me to clarify this issue. Thanks a lot!