Tek
Tek

Reputation: 499

Microservice depends on other one to do anything

At the moment I deal with micro-services and ran into a few questions (regarding relations between services), I have a hard time to find a good answer/best practices for. It would be really great if you could give me a hint or an advice how you would handle this.

Because these question are not directed to a specific project, I try to make it as clear as possible with the following example:

Let‘s assume you want to build some kind of Youtube channel observer, that logs different kinds of channel‘s (meta-)data (videos, hourly views/sub count, currently subscribed to), that are imported in a specific time interval.

So there are two major features the app has to offer, which should form a microservice each:

Both services provide an API to communicate with each other.

The manager service is connected to a database which contains the channels that need to be watched, with their basic information (name, contact, ...) and the channels these observed channels are currently subscribed to, whereas the import service has a database containing all the other more time-series oriented information (videos, hourly views/sub count).

To add a channel only the channel url has to specified. All the other information (name, contact, ...) are added by the import service (but can also be modified by the user).

All in all the import service is totally useless without the information of the manager service, but also the manager service can only show the user specified channel information (worst case: only channel url) if no import service is available. In total: they depend heavily on each other.

So much for the general architecture.

The problem I have here is, that the import service depends on the data in the manager service database to such a great degree and also modifies it:

  1. Would it be a good idea to share the manager service database between these two services or should it only be accessible by the provided API?
  2. No matter if database is shared or not: both services need model classes for the channel. Is it fine to share those?
  3. Is this architecture even a good idea at all (if we assume that there are also other services that need the basic channel information)?

Upvotes: 0

Views: 2296

Answers (1)

herm
herm

Reputation: 16315

When two microservices are tightly coupled I would suggest thinking hard about merging them. Why do you want to have microservices anyways? Is it a large project which should grow a lot, possibly with independent teams working on them? Don't do microservices just because they are cool but because of the need. In a relatively small one person project I generally would not suggest using microservices.

I would do some reading on microservices.io about when to use a microservice architecture and where to split.

Upvotes: 2

Related Questions