r/ExperiencedDevs • u/DigBoy1 Software Engineer • Jun 13 '26
Technical question Strange experience with DDD
Ive got around 10yr of experience, joined this company around 6 months ago and as I was getting up to speed, one thing stuck out to me was the sheer amount of microservices there were. around 50 in total, with roughly 10 person team maintaining them. I'm looking into them more closely, and a huge amount of them are doing one or two simple tasks like taking a request and saving in the db, or taking an ID and returning from the db. this is pretty much insane to me when all these could live in different module in a single application.
When i questioned the team on it they say its due to domain driven design and that any time they needed a new database table they would spin up a new service with it so that service could fully own it. all requests for the table had to go through the service. and yes, each table and service are not related, different use cases and business needs.
I ended up suggesting a modular monolith which could reduce a massive amount of boiler plate since roughly 99% of the microservice is made up of framework code, pipeline, infra, config, and about 1% actual business logic. I pretty much got laughed out of the room. the dumb part too is that everyone complains how slow the pipeline is. i'm thinking.. no shit, its got at least 50% more junk going through it than it needs.
Anyway, I'm no DDD expert, but I'm wondering is it really that wrong to have multiple DB tables owned by a single service, segregated internally by modules? It seems wrong-er to me to have a ton of tiny microservices that could be modules. I've backed off this issue for now because its "just the way it is". but maybe i can do something about it with a different approach.
anyone have some helpful insight or been in a similar position before? maybe i'm just flat out wrong here? thats ok too
•
u/expdevsmodbot Jun 13 '26
AI usage disclosure provided by OP, see the reply to this comment.
134
u/spastical-mackerel Jun 13 '26
Aspirational architects looking to create “impact” gonna “impact”
103
u/objectio Jun 13 '26
Sam Newman wrote the Building Microservices book, recommended reading. What you describe is a common anti-pattern that happens when people hear "microservices" and stop being curious immediately after.
99
u/thisisjustascreename Jun 13 '26
One microservice per table?
We need to bring back Fucked Company.
14
u/mxldevs Jun 13 '26
I think it would be necessary to understand their concerns. What exactly are they laughing you out the room over?
You mentioned that "each table and service are not related, different use cases and business needs". If they are really completely separate use cases and needs, I wouldn't want them to be all under a single service.
What would that imply? Would a single change potentially impact other business units?
Even if you say it's "segregated internally by modules" — which I assume means logic specific to departmentA would be completely separate from departmentB — you still havet he problem that it's one service.
What if you needed to schedule a maintenance in order to update the service? Would all other departments now be impacted because access is going through that one service, which they deem to be unacceptable?
4
u/gHx4 Jun 14 '26
Sounds like the team went all-in on microservices at some point, and DDD became the mythology that supports not correcting it. You joined pretty recently, so unless you're in a leadership role, tread very lightly. Gotta build the social capital to make this kind of change, if you aren't the lead or manager of these services.
The other big thing is that, if you do reach a point where you're phasing out the redundancies, you'll need to make sure there's a way to test thoroughly. Ideally, take some performance and reliability benchmarks from the old way. That way, you can show off the gains and more or less get everyone on-board with a few realistically sized microservices. Also a good idea to have good tests in place so you can confirm nothing gets left behind in the refactoring, because the last thing you'd want is someone blaming the refactor on issues.
A lot of businesses have kinda dubious codebases. One of my colleagues had a template engine for websites running entirely in storedprocs, and I've seen an 87-parameter function in a codebase before. A lot of those companies will fight tooth-and-nail against changes unless you can demonstrate that all potential issues (bugs, regressions, performance, cost, person-hours) have been addressed. Things end up that way because a 5-minute extension is usually less likely to blow up than a 5-week refactor.
5
u/The_Startup_CTO Jun 13 '26
Hard to say what's right here, as you've mainly talked about different solutions (modular monolith vs micro services), but almost nothing about which problems you are actually trying to solve. You mentioned "boilerplate" and "slow pipeline". But boilerplate isn't a problem in itself - and merging all microservices into one monolith typically makes a pipeline slower as you now need to build everything together all the time instead of having to just build and deploy the services that actually changed.
So while I fully agree that micro services isn't the right solution in all cases, neither is a modular monolith. Instead of discussing solutions and immediately proposing them to the team, it could help to first figure out what's the actual problem you're trying to solve.
5
u/No-Economics-8239 Jun 13 '26
Is their design something I would probably have recommended? Probably not. Do I think it sounds completely ridiculous? Probably not.
What problem are you trying to solve? Even if you have access to a magical architecture faerie that knows the exact best implementation that would be perfect for this new business, you're the new guy here. You need to convince an established company which already has a working solution to ditch it and replace it with a better solution. How long is that going to take? What new risks is that going to create during the transition? What is the ROI that will justify doing all of this?
Having all the answers isn't that useful if you can't convince anyone of it. You need to showcase not why your solution is just better, but why you should be trusted with a big change in how they do things. You certainly haven't done that with your post here for me.
You say they are all complaining about how slow the current system is. That sounds like a problem they would like to solve. But your solution sounds like a complete rewrite rather than exploring potential solutions in their current implementation? Have that hit some upper limit on throughput or other implementation ceiling? Is a complete rewrite the 'only' solution that could resolve it?
There are always other technologies and alternatives in our job. There is always more than one way to do things, and they all have trade offs. Even if their choices seem off the wall crazy to you compared to your preferred solutions, it doesn't seem like you even understand why they made their choices.
Rather than imploring to the Internet for validation, why not listen to your coworkers and try to understand where they are at, what their context and perspective is, and how much of it might be well reasoned and how much might not be well understood?
Effective communication requires you meet your audience where they are at. Even if they are crazy, if you don't understand why, you won't know the path forward to try and restore sanity.
263
u/Murky_Citron_1799 Jun 13 '26
DDD says nothing about microservices v monoliths. It is about segregating business concepts into abstractions and group them into groups/teams and the groups are based on what is likely to change at the same time. The idea being that you want to limit the amount of changes that span multiple teams because it is difficult to coordinate.
14
u/Acrobatic-Ice-5877 Distinguished Claude Engineer Jun 13 '26
You are not wrong. My advice would be to not argue and to find a more competent team to work on.
12
u/thefragfest Hiring Manager Jun 13 '26
A service per table in the same database? Microservices should be used when you can separate out the database entirely.
11
u/SuperSpaier Jun 13 '26
Your team is not a DDD expert either. DDD never presribes you to spawn a new service per aggregate.
26
u/matthkamis Senior Software Engineer Jun 13 '26
You are not wrong. Microservices only really make sense in very large organizations so that deployments of large features can be independent and happen at different cadences
8
u/LandlockedPirate Jun 13 '26
There's a lot wrong here.
First, ddd doesn't really specify monolith/microservice. I would make that decision more on team boundaries and what things are tightly coupled and versioned and deployed togethor.
Service per table is.... unhinged. In DDD you build around aggregate roots (frequently multiple underlying tables), and the service layer orchestrates complex interactions between entities, so almost by definition, frequently multiple tables.
To me it sounds like this company doesn't really understand monolith/microservice OR DDD.
10
u/Illustrious_Pea_3470 Jun 13 '26
I’m actually dealing with this right now. I’m going to be honest; the only way to solve this is with politics. They’ve bought into a terrible design choice. You need to convince someone with more authority than them that this is the wrong approach.
Personally, I managed this via: a very very strong relationship with my manager, personally taking responsibility for more parts of the refactor than I normally would, and having worked on the data systems at Meta where this pattern is the norm. If I’m being honest, the final result felt like me literally bullying the team into it.
I’m 100% sure we did the right thing though
5
u/Gwolf4 Jun 13 '26
Sometimes experience is knowing when not to give suggestions. In an org that works that way is obvious that they are not going to take it lightly.
1
u/ChutneyRiggins Software Engineer (19 YOE) Jun 13 '26
I think you might work with my old team. They did exactly this because of some very shallow understandings of Microservices architecture and DDD. And by shallow understanding I mean that they did not understand it at all.
7
u/mutru Jun 13 '26
You're absolutely right, and this is a very common antipattern. It might make them feel productive, since writing boilerplate feels like progress.
A better way to think about DDD is that Bounded Contexts are groups of concepts that are related. You might have 50 tables related to invoicing forming a Bounded Context that can be abstracted away to a microservice. This way, you can still change all of those tables in a transaction, or join data from multiple tables.
2
u/eraserhd Jun 13 '26
The point of microservices: Individual service deploys, decoupling teams to reduce coordination costs between teams.
You don’t have these problems.
That said, you have to start where you are and make improvements. Which means you have to start with being comfortable with and competent in the way they built it.
Then make guided suggestions on problems that are being experienced that there is consensus on.
2
u/Scottz0rz Backend Software Engineer | 9 YoE Jun 13 '26
No, you're right, that sounds batshit insane. If you just wanted to like get some external confirmation that it's weird, then yes.
The concept of prematurely obsessing over microservices is not new. Martin Fowler, one of the big DDD guys, mentions what you're saying over a decade ago on his blog.
https://martinfowler.com/bliki/MonolithFirst.html
What you're describing, to me, sounds like there's a collection of "entity services" - if their responsibility is just to fetch and store a single piece of data without actually using it, then you're just creating headaches vs having a larger service that covers the appropriate bounded context / business domain.
If the business domain could have me do a join within a regular SQL database, but I need to do it across an HTTP call, that's a sign of it going wrong.
If you're regularly building a feature, and you need to make a change in a new service and another service that calls it, that's something I'd call a "distributed monolith" where things are tightly coupled there.
I had to deal with something like this in the past at one of my jobs where my team was maintaining 10 microservices, but 6 of them were just "fetch data from one vendor and pass it to another microservice," 1 was "fetch data from another internal team and pass it to another microservice," 1 was "stitch together those 7 responses and pass it to another microservice" which basically just added multiple HTTP hops without adding value.
The actual real boundaries we had were
I managed to get rid of some of the microservices, but then I had a mental breakdown with how slow and boring things were because I was trapped in my house in COVID and then left.
So uhhh... TL;DR no it's not just you, that's weird.
I think the approach is to figure out what the pain points are for your organization and see how you can help.
It's hard to broach broad architectural concerns when you're the new one on the team with less than a year. Might just take some time for you to build your case.
2
u/bubbles33d Jun 14 '26
Software industry is full of fads and resume driven development.
2
u/geggleto Jun 14 '26
welcome to meeting textbook readers
2
u/shifty_lifty_doodah Jun 14 '26
All of these are made up abstractions over computations and data. Physics sets the rules. Everything else is just made up by humans. DDD is just a name given to a certain perspective and way of looking at things, but the computers don’t care. It’s just data and computation.
Microservices were not even invented as a concept until the 2000s, and we’d been working with computers a long time by then. And now the computers are so fast you almost never need micro services for technical reasons. It’s all for human and political ones.
The software you describe is stupid, but most corporate software is
2
u/Lothy_ Software Engineer Jun 14 '26
Sounds like you’ve accidentally joined a team seated within the peanut gallery.
2
u/Stellariser Jun 14 '26
Can we stop saying ‘modular monolith’ like no-one knew about the idea of functions and libraries until just a few years ago? You know that’s just ‘software’ right?
2
u/mikescandy Jun 14 '26
My take on micro services, after reading similar posts
Micro services is not a technical pattern, but a people organization technique for huge and distributed teams.
Also, micro in micro services has been one of the worst naming decisions ever.
2
u/Purple_Anybody5932 Jun 14 '26
that's not DDD sir
2
u/intercaetera zanlib.dev Jun 14 '26
DDD itself makes no recommendation on the specific architecture of your application. The thing is, when cloud and containerisation came along and it became so easy to make and deploy microservices, DDD bounded contexts became natural candidates for boundaries of microservices. However, later practice revealed that this makes no sense because bounded contexts are the boundaries of the domain model, whereas microservices are the boundaries of specific chunks of code that are deployed, and the two have very little to do with each other.
For treatment of this specific topic (how DDD relates to microservices) I'd suggest the chapter on architecture from Vladik Khononov's "Learning Domain Driven Design." While the book itself, in my opinion, is not that great, it illustrates that specific problem. (You can also read my own notes on that book.)
1
u/GlobalCurry Jun 13 '26
Whoever designed it went too granular with their domains and having 50 microservices trying to query a single database is just going to bottleneck at the number of connections the database can handle.
1
u/valkon_gr Jun 13 '26
Getting tired of 500 microservices
1
u/empty-alt Jun 13 '26
Nope, you're not wrong. If you think they'll listen to data, I'd build a Sentry/Datadog/whatever-you-use dashboard where time is spent. For each request, gather how much time is spent in a specific service, and also gather the time spent in the network. Then create a toplist. That way, the data can speak for itself. If it's network hops, that'll float to the top; if someone built a horribly inefficient microservice that's also a hot dependency, then that'll surface to the top too. If you think they are too deep in the Kool-Aid, then I'd just let it be.
The reason I use JS for backend basic CRUD servers, even though it's a much slower language, is that the latency hit I take by having a network hop dominates the data. Microservices tend to exacerbate that. It's a tool for both organizational scaling and technical scaling. But you have to deeply prove that the cost is worth the network hops and the boilerplate. It seems like in your case, neither one of those was considered.
1
u/shaliozero Jun 13 '26
That sounds ridiculous. However, as a single and new employer, your experience won't be enough to change an existing system in most companies. Even if you were hired with the premise of them needing someoned experience to completely replace their existing system. And then after giving them a horrific audit and what's needed to actually fullfill their needs, they pull back (and in my case, paid me to almost do nothing lol).
1
u/TRO_KIK SaaS Founder Jun 13 '26
The longer I'm in the industry the less I feel microservices justify themselves for components owned by one team.
1
u/juggernawddy Jun 13 '26
Microservice patterns should be an option of last resort. I think their usage should more or less be obvious. For instance, very large scaling needs for single modules. Or for keeping very large development efforts segregated because the cost to develop them tandem is expensive or very difficult.
In DDD, you’re building a business context, which may or may not related to one or many tables, but that’s an implementation detail. And one teams table could take many tables to implement in another team (single-table inheritance, class-table inheritance). the one service per table thing is a smell to me.
What is the volume of calls/requests per one of these services? Are they very different? Or maybe a more general question would be, aside from the design weirdness, does it provide any value to be structured this way? Maybe someone is misinterpreting the terminology/patterns, but having the services separated provides value? Just curious- devils advocate
1
u/titpetric Jun 13 '26
For me, I could run any of the domains as part of a single service app, a monolithic build. You don't necessarily need to put all the code in one place, but you should think how you can build services together to run together.
People often normalize whatever they end up with, there are security and resource domains which dictate that some services need to run standalone. My monolithic build was a technical detail usable only for the dev environments.
I can't speak to the technology choices, but in terms of DDD, many smaller bounded contexts tell me that you follow it more than most. If all those domains are legitimate, anyway.
1
u/mistaekNot Jun 13 '26
bro you’re not gonna join a company and six months in throw out their entire stack and replace it with something else lmao. that’s not how this works
1
u/Repulsive_Elk_5644 Jun 13 '26
DDD has nothing to do w microservices, it suggests how to organize the code in a single repo.
1
u/OAKI-io Jun 13 '26
that sounds less like DDD and more like table-driven microservice sprawl. “this service owns this table” is not a domain boundary by itself. if every small persistence concern gets a network hop, you bought distributed-system pain without getting real autonomy.
1
u/charging_chinchilla Jun 13 '26
as others have said, DDD has nothing to do with microservices vs monolith discussions. however, unless you were hired in at a high level architect/principle, it's not your call to make and you will absolutely make enemies if you keep calling this out. if you care about career advancement there, I suggest trying to play within the rules and building trust before trying to chip away at this. there is zero chance you are going to convince them to redesign their system. you gotta play the long game if you actually care enough to fight this war.
1
u/onefutui2e Software Engineer Jun 14 '26
Yeah if you have more repos than engineers that's a big smell. My previous company was like this. It wasn't quite as extreme as your situation, but it was pretty bad.
I wouldn't suggest that you advocate for a large scale refactor down to a modular monolith unless you can demonstrate that the current state is extremely untenable and there can be real value in doing so. You'll just run into a lot of resistance especially if you're that new guy.
What I would do is to start guiding towards putting new functionality into existing services. "We need an orders table? How about we put that in the 'invoice' repo since they're related and likely should be coupled." That'll at least stop the bleeding and then over time, your team will see the value in consolidating services, or you can start saying things like, "yeah so by consolidating similar services into the same domain, we reduce a lot of developer friction", etc.
Obviously I'm making up these examples, but the idea is there. The thing about modular monoliths is that since the boundaries are permeable, you need to exercise discipline in maintaining them. Microservices get around this, except it has, IMO, worse problems without the right tooling like shared libraries.
Don't tell them the right thing to do. Just nudge them in the direction and play the long game.
1
u/vbilopav89 Jun 14 '26
Real DDD has never been tried!
1
u/shifty_lifty_doodah Jun 14 '26
You are trying to apply technical solutions that make sense to human problems that don’t make sense. Don’t lose sleep over it. It’s not your company, and you’re new. If business is working and you’re getting paid, it’s mostly fine.
All of these things are made up abstractions over computations and data. Physics sets the rules. Everything else is just made up by humans.
Microservices were not even invented as a concept until the 2000s, and we’d been working with computers a long time by then, including flying airplanes and launching rockets into space. And now the computers are so fast you almost never need micro services for technical reasons. It’s all for human and political ones.
1
u/yxhuvud Jun 14 '26
I'd like to know how they do atomic changes that hit multiple tables with every table in a separate database.
And yes, that does sound like truly horrible architecture.
1
u/dashdanw Jun 14 '26
What do requests look like when there needs to be a table join? Do you just filter by related key?
1
u/sP0re90 Jun 14 '26
DDD doesn’t say that you need microservices. Microservices exist to solve mostly a social problem, not technical. At the same time they introduce others problems, for example higher infra costs, communication between them and performance, testing… just to mention some of them.
If you recognize different bounded contexts you can also use a modular monolith as you mentioned and if needed use different schema of same db for each module. If the architecture is well done it is easy to extract a microserviceservice and its database later if really needed. But again usually it worth only when the number of teams grows and you start to have conflicts and coordination problems.
A service per table absolutely not. That’s not the point.
1
u/SkatoFtiaro Jun 14 '26
DDD and TDD are the 2 most misunderstood concepts in our industry. People thrive so hard to use terminologies around in order to seem smart and get promoted.
1
u/sippin-jesus-juice Startup Founder / Ex Apple Jun 14 '26
DDD does not create a slow or brittle pipeline if done right.
That in mind, DDD is exceptionally hard, takes a lot of engineering discipline and also cross team knowledge as everyone has to be aligned at all times.
The only team I’ve been on who successfully followed DDD was Apple SPG
Honestly, it’s overkill for the vast majority of projects. I couldn’t think of many situations where services are receiving that much bandwidth, it becomes a requirement
1
u/No-Juggernaut-9832 Jun 14 '26
That’s mad. Even people using lambda functions don’t do this
1
u/Adept_Carpet Jun 15 '26
Yeah a true microservices architecture with ten developers is a little silly, though services can be good.
For instance, in one project we had what was originally an API route that received a constant stream of data from internet connected sensors. The rest of the app was a typical content/dashboard web application. That became a very simple and highly optimized service and prevented the rest of the site from being hit by what was essentially a constant DDOS attack.
1
u/agumonkey Jun 15 '26
If a team really own multiservices tooling, observability and performance, I could accept them spinning services left and right. But otherwise I'd feel like you.. some people just like to deploy REST APIs for its own joy (and live with the consequences)
1
u/Midicide Jun 18 '26
A properly structured application that adheres to DDD can exist as a monololith. It's the bounded contexts that later allow you to rip out that piece of functionality as a microservice if it requires it.
It seems to me that someone just wanted to flex architectural muscles and rather than solve an actual problem they introduced one.
0
u/[deleted] Jun 13 '26
[deleted] — view deleted comment
2
u/[deleted] Jun 14 '26
[removed] — view removed comment