I'm reading a lot about microservices but one thing remains a bit unclear to me.
Let's say in my organization, I have 2 abilities:
- Extract street names from one or more blocks of text
- Given a context of a website, understand what pages in it will most likely contain street names (a.k.a "important page") according to some company-wide heuristic
Now, my business requirement is given a website, return a list of extracted addresses and for each address whether it's from an "important page" or not.
Ability 1 is purely technical, while ability 2 is somewhere in between technical and business.
While thinking about the architecture of this solution (and others), I'm not sure about what ability stands for itself and how to deal with the dependencies.
Option 1 - Separate services, no gateway
Clients that want to have the streets extracted from a website and know whether the street came from an "important page" or not will need to do 2 requests. Clients that only want to extract streets from text will do 1 request.
Pros:
- Services don't need to know each other
Cons:
- Some clients need to perform 2 network calls each time
- Changes to the services cause changes to all clients
Option 2 - Separate services with a gateway
Pros:
- Clients always perform only 1 call
- Changes to the services won't cause changes to the clients (for client 2 can be solved by routing it also through the gateway)
Cons:
- Gateway layer becomes the "chaos" layer, as each new business requirement or client will cause a new endpoint
- More network calls in total than other solutions
Option 3 - One technical service, one composite service
Pros:
- Clients always perform only 1 call
Cons:
- Composite service totally depends on the streets service
I know that I don't want to adopt any extreme approach - I don't want to limit microservices to one endpoint only, but on the other end I don't want to have microservices with 100 responsibilities.
Where should I draw the line?
Things important to consider:
- client waits for the response (synchronous)
- ability 2 might get some additional heuristics and some more requirements in the future, while ability 1 will stay the same. That's the main reason I don't think combining the two abilities into one service will be good (the 2 abilities are owned and planned by different teams).
- ability 2 may be used by itself in the future, does that change the decision?
Eager to hear your opinions!