Skip to main content
Share Your Experience: Take the 2024 Developer Survey
33 votes

If a microservice architecture needs a separate database per microservice then it's too costly & unmanageable. Why do we even need it?

Why do we even need it? You don't. Creating a separate database for each service helps to enforce domain boundaries, but it's only one approach. There's nothing stopping you from having all your ...
Dan Wilson's user avatar
  • 3,103
16 votes

If a microservice architecture needs a separate database per microservice then it's too costly & unmanageable. Why do we even need it?

Why do we even need it? The enormous benefit of microservices—and more largely, SOA—is the high level of abstraction of the internals—not only the implementation, but also the technologies being used....
Arseni Mourzenko's user avatar
13 votes

Should I use a layer between service and repository for a clean architecture - Spring

Front end <--> API Service -> Service -> Repository -> DB Right. This's, essentially, the design by layers proposed by Spring Framework. So you are in the "Spring's right way"...
Laiv's user avatar
  • 14.7k
11 votes

If a microservice architecture needs a separate database per microservice then it's too costly & unmanageable. Why do we even need it?

As Dan Wilson answers, you don't really need it. Microservices are the new hot thing, and like all new hot things, people use them in a lot of places even when they don't provide much value. ...
Telastyn's user avatar
  • 109k
10 votes
Accepted

Is there a thing as "too many threads"

Threads do have significant costs - VERY roughly - imagine 100K bytes per thread (they each need a stack for one thing), and they each place a slight burdon on operating system components (e.g. ...
Lewis Pringle's user avatar
8 votes
Accepted

Service Design Pattern

Sorry for the C# syntax, I'm not a PHP dev. But the core of the answer is language-agnostic, and I hope the syntax is readable enough for you to understand the focus of the examples. You've actually ...
Flater's user avatar
  • 51.7k
7 votes

Is it good practice to put service business logic based on audit trail?

It depends (but I guess for most real-world situations the answer is no, you risk to run into trouble). A general-purpose audit trail may collect data which, depending on the details, might be ...
Doc Brown's user avatar
  • 209k
7 votes

What difference and relation are between fault tolerance and (high) availability?

The basic concepts are orthogonal, however, they are related. One has to do with the availability of your application, and the other has to do with the correctness of your application. Remember, ...
Berin Loritsch's user avatar
6 votes
Accepted

Does my code violate DRY principle?

I know that these are two different methods but they are doing the same task No they aren't. One is linking a person to a company. The other links a company to a person. They may use the same ...
David Arno's user avatar
  • 39.3k
5 votes

Design Unstoppable Service

If the users of those "client PCs" have full administrative rights over their computer, then there is no technological way to prevent them from disabling or removing your service. And if there were, ...
Bart van Ingen Schenau's user avatar
4 votes

Migration from Anemic Models to Rich Models

In this setup, all Entity properties have Public getters and setters, there is no encapsulation, no OOP, no code re-usability. When I need to update this entity in another Service (or any other method ...
VoiceOfUnreason's user avatar
3 votes
Accepted

Is it good practice to put service business logic based on audit trail?

No. The problem is the audit trail should never change once written. So lets say I have some business logic "Show the buy button if the customer has not bought previously" And when the customer ...
Ewan's user avatar
  • 76.4k
3 votes

Does my code violate DRY principle?

If you didn't have the relationship type you could refactor this to LinkCompaniesToPersons)( IEnumerable<string> companyIds, IEnumerable<string> personIds ); and save ...
Ewan's user avatar
  • 76.4k
3 votes
Accepted

DDD infrastructure layer: implement service+persistence or just persistence

It sounds to me as though you are getting your self twisted around the dependency inversion principle. I'd suggest giving Greg Young's 2009 essay on Generic Repositories a long read. The TL;DR is ...
VoiceOfUnreason's user avatar
3 votes

How to reduce dependency in communication between servers

TL;DR Your applications should depend upon interfaces which describe message patterns and should not depend upon implementation details pertaining to RabbitMQ or any other message transport technology....
Ben Cottrell's user avatar
  • 11.8k
3 votes

Should I use a layer between service and repository for a clean architecture - Spring

The best way to prove that a design is flexible is to flex it. You want a place in your code that is responsible for persistence but is not tied to the idea of using a repository. Fine. It's not ...
candied_orange's user avatar
3 votes

How should a service communicate with an activity in real-time?

You can also use Pending Intent,Event Bus or Messenger for real time communication from service with activity. Check out my blog post at below link which covers all these approaches with example- ...
Android Developer's user avatar
3 votes

How should the service layer be done?

1/ Decoupling Like this if things changes in the DAO layer/database schema I just have to touch the service layer and the UI stays untouched. Allright, why? I still have to change stuff in 1 layer to ...
Flater's user avatar
  • 51.7k
3 votes
Accepted

Repository Pattern whith complementary objects (agregates)

It is normal (but not not mandatory) that aggregates span multiple tables in your database. If UserOptional entities are subordinate to User entities -- if they don't get re-assigned from one user to ...
VoiceOfUnreason's user avatar
3 votes

Migration from Anemic Models to Rich Models

You are on the right track! To help us understand a clean architecture, let us first breakdown the "flow" of your service layer and engage in a brief summary of where your current application has ...
user3347715's user avatar
  • 3,144
3 votes

CQRS sequential numbering of business documents

The TL;DR is: yes, there are technical challenges in preventing collisions, but it's really something you should ask your business department. Best practice from a business perspective isn't a ...
Jens Finkhaeuser's user avatar
3 votes

Should services in a service layer be thread safe?

Right now, all calls to this service happen in the same thread and there's no plans to add more, so it's fine. This statement says it all. Right now the class satisfies the needs for which it was ...
Greg Burghardt's user avatar
3 votes

What are the best practices in public API vs internal only API being on the same service

You want an API gateway. This gives you a tool that can expose APIs to the public using any url you want and have the functionality where it already existed. The gateway is responsible for auth of ...
Ryathal's user avatar
  • 13.4k
2 votes

Handling and reporting errors consistently

Handling errors consistently Errors can take the form of a thrown exception, a proper Error object, a plain object, an optional argument to a callback, a Promise, a special return value, a simple ...
Johntron's user avatar
  • 1,008
2 votes

Service dependencies during local development

I think Docker and Compose are definitely the way to go. We have projects that require different services (frontend, backend, Postgres, Redis, Elasticsearch, etc.) that compose a whole system. Before ...
anthonator's user avatar
2 votes
Accepted

Hosting what normally would be a windows service inside a web server

What you describe is simply a Microservice architecture. By making your long running task a web service on its own, separated from the main application, problem #2 is solved - and that is not a "...
Doc Brown's user avatar
  • 209k
2 votes

Is it valid to split an API in different microservices?

I would advise against this. One of the core principles of microservices is that a service should own its data. If data is shared, services tend not to be independently deployable due to coupling with ...
Telastyn's user avatar
  • 109k
2 votes
Accepted

For entities that have Parent/Child relations, is it better to have a single Service for the parent and children or separate them?

If the children are useful on their own (if the parent is optional or can be ignored for some operations), then they should get their own service. If the separation is only to provide a collection ...
Telastyn's user avatar
  • 109k
2 votes
Accepted

Best way to implement Windows service in C#

2 ways, with a few considerations: Deploy as a Windows Service For this, for simplicity sake, I'd recommend something like http://topshelf-project.com/ which will simplify the deployment process for ...
JᴀʏMᴇᴇ's user avatar
2 votes

Is it okay to transport a DTO inside of a DTO?

DTOs are used to transfer data between parties. As the definition suggests your objects are valid as long as they are designed for data transfer. That means they must carry no logic (or methods in ...
Ali Doustkani's user avatar

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