As the title states, I'm wondering if my current architecture is currently too granular. Additionally, I'm curious if I should be pursuing a microservice architecture in the first place.
For context, I'm building a multi-tenant document generation system and I currently have the following entities:
Tenant
Template
Document
In terms of entity relationships, there's a one-to-many relationship between Tenant
and Template
, as well as a one-to-many relationship between Tenant
and Document
.
As it stands, I essentially have a microservice (REST API) per-entity (which I'm now realizing can be a problem itself).
One problem I'm facing is how to communicate between the services, and more specifically, how that impacts the domain/context of all of these services. As I understand it, synchronous communication between services in an anti-pattern, which becomes a problem in my application.
In practice, when a user creates a Document
(via REST API), I call out to the Tenant
and Template
services (via their REST APIs) primarily for validation purposes (i.e. "Does a Tenant with the specified ID exist? Does a Template with the specified ID exist?").
To solve this, I could replicate the data in an eventually consistent manner such that the Document
service doesn't have a "hard dependency" on the other services, but this leads back to my initial question of whether the microservice architecture makes sense in the first place because all of these entities are closely related.
If I were to take this route, I'd effectively have three (3) data stores (DBs) for Tenant
information, albeit two of those will be heavily stripped-down (an ID
column and whatever information the specific service requires) from the data store used in the Tenant
service. On the downside, this requires some extra effort to coordinate. On the upside, if new properties are added to the Tenant
entity, the other services don't need to change unless they need to use these new properties.
For some extra context, there are other use cases other then the ones I mentioned before. For example, I plan on adding a web application to create/modify Templates in the future. If I kept the current architecture (microservices), I can scale the Template microservice up as the traffic (inevitably) increases.