asp.net-web-apiarchitecturemicroservicesmulti-layer

Microservices vs multi-layered architecture


My project has one backend service (Web API) and one frontend SPA application. Backend service has presentation, application services, domain and infrastructure layers located in different .net assemblies. Domain layer has business domain objects, infrastructure – communication with external data and other stuff, application services – set of services used by presentation layer, presentation – Web API controllers. I think it’s very common layered architecture.

Our new architect announced we are going to move backend to microservices architecture braking down our layers and dividing domain, application service and infrastructure layers to a few services and convert presentation layer to backend for frontend layer (as here described). In feature, we are going to have mobile application. Sql Server database is going to leave as is for now.

I don’t have experience with microservice architecture, so my questions are: Is multi-layered architecture out of fashion already? What benefits and problems can bring such architecture design for my application?


Solution

  • Microservice and layered architecture are a little bit different things. Microservice architecture it’s about how your application is constructed, what components (services) it has and how these services communicate with each other, how they are developed, deployed and so on.

    Multi-layered architecture it’s about logical dividing application into layers where every layer has its own logical function (presentation, domain and so on). Very often multi-layered architecture is related to monolithic architecture and service design.

    According to your description, you aren’t going to break down your layers, your architect wants to split logic into different services. These two architecture styles can be used together. For instance, you can have 3 services and every service can have presentation, domain and service layers. If your current layers in one service are heavy enough it makes sense to split them out making development and testing easier. Backend for frontend style has also its benefits especially if you want to add a mobile app.

    About this

    Is multi-layered architecture out of fashion already?

    No, they are used both but with microservices as a rule layers should be much thinner than in monolithic application.

    What benefits and problems can bring such architecture design for my application?

    I recommend you look at comparison between microservice and monolithic architecture styles and this post. To divide or not you should consider the size and complexity of your project, the size of your team. Dividing has to bring benefits to the whole application making development easier. The Monolithic application has its own benefits and up to some size of the project, it can be a good decision. Of course, it’s a nightmare working with a huge monolithic application as well as with one hundred very small (nano) services.