The previous chapter talked about the model of the overall architecture.

API gateway +BFF data assembly + service layer

So how is the service layer divided?

By what

For example, customer department, logistics department, finance department. But there are few such divisions.

There is also a division by business:

Different services solve different business problems.

For example, manuscript group, video group, cartoon group, comment group, barrage group.

Generally a stable service can be handed over to the bottom of the maintenance of the people, the main force will continue to develop the next service.

Points more fine

The benefits of fineness:

  • (1) Services can be deployed independently
  • (2) It is convenient to expand and reduce capacity, which improves resource utilization
  • (3) The thinner the disassembly, the relative coupling will decrease
  • (4) The more detailed, the fault tolerance will be relatively better, a service problem does not affect other services
  • (5) Better scalability

Disadvantages of detail:

  • (1) The finer the disassembly, the more complex the system
  • (2) Dependencies between systems are also more complex
  • (3) Increased operation and maintenance complexity
  • (4) Monitoring is more complex
  • (5) It is more difficult to locate problems when problems occur

Microgranularity is also related to the separation of libraries.

My advice:

Step by step to

In fact, the architecture is really long, long will be divided.

  • When you feel there is no business coupling between the two pieces of code, you can separate them.
  • When you think that a single data call multiple services, merge.

For example:

  • Account service, starting as a service, only nickname, avatar, gender, etc.
  • Later added VIP, equipment system, backpack and so on.
  • So we split it all up into services, because there’s no coupling.
  • Later, I found that to get one user’s data, I needed to call seven or eight sub-services, which was very troublesome and the code merge was very uncomfortable.

How to do?

Architecture is layer upon layer.

Add an account BFF layer, which is used to assemble data, and call it if you need all the information about the account.

External convergence, internal separation.

conclusion

The architecture is gradually evolved, and the architecture and evolution should be selected according to the business and actual environment.

Keep iterating, keep refactoring.

Related reading:

  • I heard you don’t know Conway’s law?
  • 【 Microservice theory 】 Practical application of CQRS
  • 【 Micro-service Theory 】 How should micro-service be divided
  • How does a small company implement micro services
  • Communication between services: an introduction to gRPC
  • API + BFF no longer worries about compatibility and adaptation
  • An overview of microservices