0

To start off I'm familiar with what microservices are, how they communicate with each other, the general flow etc.

Now, I'm used on working with standard 3 Layer application for my backends( API - BL - DAL ) and was wondering what the architecture of 1 microservice was, as I can't really find something about that, or if there is even a general way of gutting out 1 service.

I'm always tempted to write my microservice in the same general way, 1 microservice having an API as the entry point, a BL for the logic, and a DAL for the DB operations, but I've got a weird feeling with this as building a "micro-ish monolith".

So my question is as follow: Is there a general way of designing an MS, or is the 3 layer architecture good for the general microservice?

PS: I'm talking about general "business" microservices.

  • 2
    The answer is no. Microservices is an architectural style that operates in a very high level of abstraction. It has nothing to do with the specific code design. These are implementation details and they depend on the requirements. There could be services with 3 or more layers and there could be services with only one. It depends also on the job of the service within the architecture. For example, gateways don't require DAL or BL. They could (nothing prevent you from providing these layers), but they usually don't. – Laiv Feb 28 '18 at 10:39
  • @Laiv About the gateway part, that's why I mentionned the "general business services", by that I mean no gateways, no auth services, no event stores, no msg queue services, ... Sorry, I should've cleared that out, I was talking purely about business services. – TanguyB Feb 28 '18 at 10:44
  • 1
    Well, auth services are part of the business. Aren't they? :-) . Regarding gateways, stores and brokers. You are right. Anyways, the answer remains the same no, there's not. – Laiv Feb 28 '18 at 10:48
  • The rule you are asking for is "adequacy". If you consider any of the mentioned layers to be "overkill" just don't implement it. – Laiv Feb 28 '18 at 10:50
  • Yeah my main reason for asking this question was to make a kind of template for microservices that I could just pop out for the business services, but I guess that's too much of the greater good. – TanguyB Feb 28 '18 at 10:52
1

Long story short. No, there's not a general way to design microservices. Microservices is an architectural style which operates a very high level of abstraction. This answer is extensible to any other sort fo architecture. For example, there could be monoliths that don't require 3-layers designs.

What you are looking for is named adequacy. If you consider any of the mentioned layers to be "overkill" just don't implement it. Whether is overkill or not is something to look at the requirements and the needs of each specific component of the architecture. Thankfully, Microservices are meant to provide us freedom in the design and development of these components since they don't share SDLC.

Yeah my main reason for asking this question was to make a kind of template for microservices that I could just pop out for the business services, but I guess that's too much of the greater good

That could be a good idea. Ultimately, Microservices architectures are populated with many services. It doesn't mean they are going to be radically different from each other. Templates can state the minimums required to be a good citizen of the system. Just take into account that there could be different technological stacks and probably you should provide templates for each of them.

The Required Standard

When you’re working through your practices and thinking about the trade-offs you need to make, one of the core balances to find is how much variability to allow in your system. One of the key ways to identify what should be constant from service to service is to define what a well-behaved, good service looks like. What is a “good citizen” service in your system? What capabilities does it need to have to ensure that your system is manageable and that one bad service doesn’t bring down the whole system? And, as with people, what a good citizen is in one context does not reflect what it looks like somewhere else. Nonetheless, there are some common characteristics of well-behaved services that I think are fairly important to observe. These are the few key areas where allowing too much divergence can result in a pretty torrid time. As Ben Christensen from Netflix puts it, when we think about the bigger picture, “it needs to be a cohesive system made of many small parts with autonomous lifecycles but all coming together.” So we need to find the balance between optimizing for autonomy of the individual microservice without losing sight of the bigger picture. Defining clear attributes that each service should have is one way of being clear as to where that balance sits.

Chapter 2. The evolutionary Architect

Building Microservices - ISBN-13: 978-1491950357

by Sam Newman

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.