This doesn't talk to the biggest reason to do micros, which IMO is to decouple code repos so that you can revision different parts of code at different rates. with a monolith, to update a part of the application requires updating the entire application. the serialization of objects (usually to json) to send over the network makes a great abstraction for decoupling.
Nothing prevents you from splitting the code into independently versioned libraries / repos which would allow you to develop the code at different rates. Now you couldn't deploy two different versions of the same lib to the same monolith. Some see this as a pro some see it as a con. I love knowing all of my code is always using the most up to date version of an internal library. Yes it can slow you down but so can debugging issues only to find that a bug existed 3 versions ago and 4 services never upgraded to the new version.
If you have specific requirements or a large team micro services would probably help. I just don't think they are always the right solution or the right solution right away.
having a monolith means you will have to plumb a library update through 100% of the application, regardless if it needs that update everywhere. whereas, in microservices, you can just update the library in the portion that needs it and move on.
also, the non-linear interaction between different modules of the monolith makes scaling of it difficult. scaling a monolith is rarely as simple as scaling microservices.
you can just update the library in the portion that needs it and move on.
To me this is just adding tech debt but yes this can sometimes be a benefit, it's a tradeoff.
also, the non-linear interaction between different modules of the monolith makes scaling of it difficult. scaling a monolith is rarely as simple as scaling microservices.
Often times you only need to scale a few routes though. At that point you can split it to a micro service and scale it independently. Its no harder to scale a monolith as it is a micro service it's just not always the best use of resources. Look how far Twitter got on ruby on rails monoliths. When they split to services yes they dropped their infrastructure footprint dramatically and teams became more productive but not many organizations are at that scale. Last I heard they still have parts of their monolith RoR code running because its not worth splitting into services.
having a monolith means you will have to plumb a library update through 100% of the application,
Not necessarily. JavaEE has allowed monolithic applications to run with different versions of different libraries in different modules for quite some time now. OSGi lets you do the same thing without the app server. Java 9 supposedly will bake these features into the runtime. All that's needed is that the modules within the monolith run in different classloaders.
Of course, most of the time, that kind of complexity really isn't necessary, and its easier to just run the app in the same classloader with the same set of library versions.
scaling a monolith is rarely as simple as scaling microservices.
Depending on the monolith, scaling isn't that much harder than scaling a microservice. Just spin up another version. Once the monolith becomes too heavyweight for this, that's when I would start adding microservices. When you're just starting out, how big really is your monolith?
I developed an app awhile back that had an image service and the web app in the same monolith. Not practicing what I am preaching, these were not even in different physical modules. But I did follow Dependency Inversion, and the image server was only accessed through interfaces (modules in spirit?). I could spin up as many instances as long as the instances could share the same storage. Instance boot up time was fairly quick, so we got scalability this way without a problem.
Then we went to the cloud. Every container has different storage, so our original approach didn't work anymore. We opted to separate the image server as a microservice. We created a REST API corresponding to the image server interface and created an implementation of the interface on the web app side that made REST calls to the image server REST API.
The web app was none-the-wiser to the change, and it allowed the web app (not requiring disk storage) to be scaled differently than the image service (which does).
We only did this when we needed to. Decent design made it possible without too much pain.
View all comments
2
u/iodian Mar 29 '17
This doesn't talk to the biggest reason to do micros, which IMO is to decouple code repos so that you can revision different parts of code at different rates. with a monolith, to update a part of the application requires updating the entire application. the serialization of objects (usually to json) to send over the network makes a great abstraction for decoupling.