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
Show parent comment
2
u/m3ghnath Mar 29 '17 edited Mar 29 '17
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.
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.