Skip to main content
80 votes

In microservice, is it single database or single database instance for each service?

Assumed you have some services which can use the same kind of DB system and version, if you use different database or db instances is a decision you should not need to make at design time. Instead, ...
Doc Brown's user avatar
  • 220k
32 votes
Accepted

In microservice, is it single database or single database instance for each service?

It really depends on your scalability requirements, and how/if your microservice instances need to cooperate to provide a single result. It helps to know what the trade-offs are: Keeping it all in ...
Berin Loritsch's user avatar
13 votes

In microservice, is it single database or single database instance for each service?

It doesn't matter. The only scenario where it could theoretically matter is if one service needs to migrate to a different versions of the database. But even then, there's no real difference between ...
Michael Borgwardt's user avatar
11 votes
Accepted

Calling service and repository layer from controller

If your repository layer is properly abstracted (eg, the service layer and controller can only access the repository via interfaces), then: Having the controller access the repository directly ...
David Arno's user avatar
  • 39.6k
7 votes
Accepted

Adding a CLI to a Windows service

This is a classic separation of concerns. You have one use-case for a process that runs as a headless Windows service performing tasks. You have a second use case for a CLI tool parsing command line ...
Avner Shahar-Kashtan's user avatar
6 votes

How to make a service running on a random port discoverable?

In "enterprise" systems, service discovery is often handled by the service advertising itself in a well-known location, known as a service registry. After the service has found an open port and ...
Mike Partridge's user avatar
5 votes
Accepted

Does Presentation Logic constrain design of Business layer?

It's a good question. Sometimes the complexities of the real world make it harder to see the big picture, and/or are in conflict with our mental models. I'll have to digress a bit before I get to your ...
Filip Milovanović's user avatar
5 votes
Accepted

Decisions according to environment

It looks like the refactoring you are proposing to change from what you say is bad practice to what you say is good is what Fowler calls replace conditional with polymorphism. Whether or not its an ...
bdsl's user avatar
  • 3,924
5 votes

Adding a CLI to a Windows service

What you're describing sounds an awful lot like most DBMSes. For example, the MySQL Service process, mysqld, runs independently and does all the heavy lifting. It's Command Line Interface, mysql, ...
Phill  W.'s user avatar
  • 13.1k
4 votes

Calling service and repository layer from controller

It's better to be consistent and always call the service layer even as a pass through. Consistency is more important than saving a few lines of uninteresting code. This allows you to add potential ...
Ryathal's user avatar
  • 13.5k
4 votes
Accepted

An aggregate without an aggregate root?

Lets start with a quote form Evans in his DDD reference book: Sometimes services masquerade as model objects, appearing as objects with no meaning beyond doing some operation. Keeping this in ...
Christophe's user avatar
  • 82.2k
4 votes

DDD - Factory or Service?

I suggest you actually attempt to model the actions to which you are alluding above in your application layer. Namely RegisterAccount and Login, because I think it can help bring clarity to your ...
user3347715's user avatar
  • 3,244
4 votes
Accepted

Gracefully handling failures in sequence of requests

There are three aspects of failure handling applying to your case: Informing the service user (important). Giving a failure response is the correct way to go. Normally, your user isn't interested in ...
Ralf Kleberhoff's user avatar
3 votes
Accepted

Should I be worried about having too many services?

With the example code you provided, your MasterServer is essentially the container for all your components (instantiating them through hand written code). You are getting to the point where ...
Berin Loritsch's user avatar
3 votes

In microservice, is it single database or single database instance for each service?

I think it might help to be a bit more theoretical here. One of the motivating ideas behind microservices is shared-nothing, message passing processes. A microservice is like an actor in the Actor ...
Derek Elkins left SE's user avatar
3 votes

Angular 2+ Providers/Service on Parent or Child component?

I would inject it into both. That way the Child Component gets the SettingsProvider in a single place. If the Child component is used in multiple places, it doesn't need to be wired up to the ...
Stanley De Boer's user avatar
3 votes

In microservice, is it single database or single database instance for each service?

An RDS instance is a single box. If you have multiple databases on a single instance then they share the CPU/Memory etc. If your microservice performance is bound by its database performance: then ...
Ewan's user avatar
  • 84.4k
3 votes

If Service Layer is doing nothing, just calling methods in DAO . Can my Service Interface just extend DAO Interfaces?

If Service Layer is doing nothing, just calling methods in DAO. Can my Service Interface just extend DAO Interfaces? No. You don't have a service layer for the sake of having a service layer. It's a ...
Bogdan's user avatar
  • 3,660
3 votes

Separation of concerns and other best practices across Controllers, Services, Providers and Stores in ASP.NET when building a REST web api

First, is this view of the separation of my classes really how others structure their code? Yes, unfortunately. Second, is it legitimate for one Service to instance and leverage a second Service? ...
Robert Bräutigam's user avatar
3 votes
Accepted

What is meant by service?

My question is, is this common to call an interface a service? No, but it's common to refer to IFoo as "the Foo", since the interface tends to represent the real thing, and constantly ...
Flater's user avatar
  • 59.5k
3 votes
Accepted

How to model an action that involves more than one model?

You want to use your third option. In systems with users basically everything is user focused, but putting that functionality in a user model doesn't make sense in most cases. If exercise is a domain ...
Ryathal's user avatar
  • 13.5k
3 votes

Should a single method in a service class perform multiple operations for its controller?

Never forget that each of your layers exists for a specific purpose, and you should sort your logic into those layers according to that purpose. Controllers' purpose is to handle web requests. They ...
Flater's user avatar
  • 59.5k
3 votes
Accepted

Is this a good example of what a service layer is in MVC?

There is a misconception here. The Model-View-Controller pattern does not include a service layer, nor does it care if one exists. I asked a similar question some number of years ago that was focused ...
Greg Burghardt's user avatar
3 votes

BPMN - I think I need to split up a pool (consumer-provider-situation)

Every pool starts off with its own preconditions in mind and acts on a certain level of abstraction. For example, let's look at: [File:FlexDiagrams BPMN display.png - Wikimedia Commons] We did not ...
Kromster's user avatar
  • 607
2 votes

Calling service and repository layer from controller

The dependencies required for the repository classes shouldn't be needed by the controller classes. If you don't mind having the dependencies there, I suppose you could skip the pass-through call and ...
Dan Rayson's user avatar
2 votes
Accepted

How to make a service running on a random port discoverable?

I would advise you to do option #2 and the respect the following list of ports: List of port numbers of numbers to avoid.
Pieter B's user avatar
  • 13.3k
2 votes

Domain Model vs Service in a MVC context

It all sort of rests on where you want to do your coupling and how loose you want it to be. Also, it's not like any of these are absolutes. But if you want to be super DDD about it, thoughtfully ...
lscoughlin's user avatar
2 votes

Does Presentation Logic constrain design of Business layer?

You shouldn't let presentation logic drive the business logic. But in your case I'm not sure you are. You have a requirement to check the existence of recipients before sending. That's a business ...
Ewan's user avatar
  • 84.4k
2 votes
Accepted

Can I put domain services inside domain entities?

Answering your question (about services) A domain service is by definition always outside of a domain entity: SERVICE: An operation offered as an interface that stands alone in the model, with no ...
Christophe's user avatar
  • 82.2k
2 votes

Specific get cases - Repository vs Service

scenarios to get data. eg. get all articles associated to an user. Dragging all articles into memory and then filtering by user is certainly one way to implement. It can work well, especially if you ...
J_H's user avatar
  • 7,901

Only top scored, non community-wiki answers of a minimum length are eligible