We have a monolith C++ application and I consider doing some major refactorings. Since we're not completely ready to go full "microservices only" (maybe in about two years time), I want to structure the new architecture in a way so that the application can be run as both, a monolith with every microservice compiled to one app, or each app split into it's own executable to be scattered across the infrastructure.
What is an idiomatic way to do this considering project structure / cmake targets usw.?
Atm we seperate our concerns into three blocks: API, processing and storage. It would be nice if I could somehow deploy only processing and storage on one node or on a seperatore node. Similarly API and processing should be able to be compiled together and also benefit from a speed increase.
I thought about compiling using some cmake options which conditionally add server/client capabilities to single services. If the app is compiled together, it should allow direct transmission of memory between services for performance reasons. But my fear is that the app will grow to become a so called "distributed monolith", so I want to take every measure against that from the start. Any (anecdotal) experiences that I can learn from are highly appreciated.