Service Boundary

Is service an API hosted on a cloud or on-premise server which does CRUD operations on a database? Can service be hosted in the same process if not in an API?

In reality service can be hosted in the same process or outside the process. In other words to say service is not an API. When some one says user service, it is the only source of user and only source of operations on the user. There is nothing outside of user service which will manipulate the user data. It is the single truth for the user data.

Then how does user service looks like from architecture perspective? Like one shown below.

How can a User service look like from Technical Perspective?

In the technical view you can have user service contains several things going on inside it. It can have even more than one database inside, several processes running each doing different things. A batch job could be running within the service boundary. 

Notice that shipping service is recieving user feed via FTP. It is not an API call here unlike Profile and Billing services.

Shipping service can hold the cache of user data, but it will turn stale. It still need to go fetch the data from user service to refresh its cache.

Ending Note

We need to be careful designing the service. Service has a logical boundary, has reason for its existance and is a single authority of its data. There should not be two services accessing the same database. For example, Shipping service accessing the database of User Service.

Here is the link to a talk from Udi Dahan about service and its boudaries. Very insightful.

Leave a comment