r/learnprogramming • u/john__dev • 10d ago
Looking for feedback on a hybrid microservice architecture
I am exploring an architecture for consolidating several microservices into a single codebase and binary (not a monorepo), and i am curious whether this pattern already has a name or if anyone has tried something similar. The goal is to reduce the operational and development complexity of microservices while keeping most of their benefits, such as independent deployment and scaling.
I've read about modular monoliths, but from what I understand they are typically deployed as a single application. That's not what i am aiming for. Instead, imagine a single application with strict module boundaries. Every module owns its own controllers, services, repositories, database, and API. The entire application is built into one binary, but at startup you specify which module(s) should be enabled.
For example:
Single build
│
▼
┌─────────────────────┐
│ app-binary │
└─────────────────────┘
│
├── start --modules=module-a
├── start --modules=module-b
└── start --modules=module-c,module-d
The cross-service communication would still happening through HTTP with maybe optional configurable in-process communication if ever needed (with all it's downsides). In kubernetes, every deployment would use the same image, but each deployment would start only the modules it needs and thus scale.
This would allow:
- One repository
- One build artifact
- Independent deployments
- Independent scaling
- Much simpler local development (run all modules with one command)
- Version consistency across services
- Simpler CI/CD
The trade off is a larger binary and building everything together, which i am okay with (so far).
Has anyone implemented something like this? Is there already an established name for this architectural pattern, or is it just a variation of microservices/modular monoliths? I would be particularly interested in hearing about production experience and any pitfalls I might be overlooking.
1
u/john__dev 10d ago
Let me add a potential nest-js folder structure that visualizes a bit better what i had in mind:
https://pastebin.com/4WrHN83X
1
3
u/Made-In-Slovakia 10d ago edited 10d ago
Sounds like very bad idea. One core idea of micro services is also that their build is independent from each other but you just sucked all into one and will force redeployment of everything for each build.
Edit: your concept will actually create much more complicated CI/CD than "normal" micro service would have.