Search code examples
architecturemicroservices

What is the best way of splitting application logic into microservices


we considered to move monolith application to microservices, we are in stage of researching as it's our first experience with microservices.

Currently we consider to have 3 types of microservices:

  1. Api gateways - using rpc to communicate with domain services
  2. Domain services - services encapsulating different part of logic, communicating with gateways by api, and async events to communicate with each other. Each has own database
  3. Infrastructure services - like email, sms, etc.

And so far I have a few question about how to correctly split domain logic, some best practices and useful resources appreciated. Also I'll provide some logic example and few different ways how i see it can be divided.

Application logic: We have two gateways api for end user frontend admin api.

Application is kind of social network where each user has own profile, can search for other people's by different criteria (geo locations, hobbies, total compability percentage) add to friends, realtime chatting, re-calculate compability to other person. The main feature of the application is algorithms of calculating compabilities between people's, it taking into account date and location of birth and some other criteria collected while user registration and changing user account type. And depend on user account type (which can be bought or set by admin) he has different level of compability calculations.

So we have: users, profiles, users search, geo, friends, payment, account types and permissions (kind of acl), compabilities calculation, chat.

Im not sure if each of listed in above paragraph should be considered as independent microservice, or for example I can group users, profile, account type/permissions and friends into one microservice, and users search and geo into another.


Solution

  • General objectives when developing a microservices architecture:

    • You should be able to deliver and deploy the services independently of each other.
    • A development team should be able to implement a service independently of the other services.

    Now there is certainly not one single "correct" way to achieve this, so here are some resources and best practices that I have found useful:

    With the information from your question and without knowing more details, I feel that you could reasonably group some of your entities into one microservice, but this is really a decision that should be taken by the domain experts.