Home > Mobile >  Microservice have business logic /Service/Domain layer
Microservice have business logic /Service/Domain layer

Time:09-13

I try to develop microservice application. When checking most of the article for microservice, where each microservice have two layers(frontend and Repository layer). usually if develop monolithic application API layer structure like

Rest API Controller(Like API Frontend) <-> Business Logic <-> Repository Layer(Data Access Layer)

When come to microservice each micro service have two layers

Rest API Controller(Like API Frontend) <-> Repository Layer(Data Access Layer)

It's fine for doing simple CRUD application. Suppose come to Complex business logic application. where should I implement complex business logics?

CodePudding user response:

Microservices aren't about how many layers each application has, or indeed about how they are implemented. They're much more about clear, separation of enter image description here

Microservice applications don't share databases, and instead communicate with each other over HTTP for sync or some sort of event technology (Kafka, Message Queues etc) for async.

Each one of those applications might be implemented in a complex way or have complex requirements, it's not what makes them a microservice.

So to your question - your implementation is less of a concern here. You can still have services/repositories if that's a pattern that you like, or CQRS patterns can also work nicely, it doesn't matter so much as the core principles of boundaries, communication and state management.

NB : Microservices therefore come with overhead. You need to be disciplined with contracts for APIs and Messages, you need to make sure you don't reinvent the wheel, teams need to collaborate with each other effectively. They work well at larger scales and certainly promote a deployment model that allows you to utilise as much compute as you can pay for, but there are times when they can slow you down due to dependency management.

  • Related