r/SpringBoot • • Jul 16 '24

Monolithic vs Microservices

We have written an article on Monolithic vs Microservices:

  • Overview & Distinguishing Features

  • Merits of Monolithic and Microservice Architecture

  • Challenges in Implementing Microservices

  • Transition Strategies

  • Use Cases and more.

https://www.unlogged.io/post/monolithic-vs-microservices

30 Upvotes

19 comments sorted by

View all comments

36

u/devondragon1 Jul 16 '24

Unpopular opinion I'm sure, but I strongly disagree with a great deal of your article. There are thousands of similar articles, so I am not calling you out specifically, but I see the same talking points brought up in the Monolith vs Microservice discussion over and over, and many of them don't actually hold weight in my experience.

I don't have time for a point by point rebuttal, but I'll cherry pick a few things that caught my eye:

"Monolithic architecture is often the go-to choice for small startups, personal projects, or companies that don't deal with a huge user base."

Other than possibly Netflix/Meta/etc... pretty much EVERY Fortune 1000 business, dealing with huge user bases, uses Monoliths. Some have moved towards Microservices for some aspects of their software ecosystem recently, but A) have run successfully at scale using monoliths for decades, and B) almost always still have substantial monoliths in the stack even if they are migrating some things to Microservices.

" Imagine if a glitch in one feature causes the whole app to crash, leaving users unable to access anything. This dependency on a single codebase makes the system vulnerable to widespread failures, impacting reliability and user experience."

If that same undetected until production glitch is in your login microserivce, or your inventory lookup service, or your..... it has the same impact. Also, in my experience at least, reliability and availability are typically worse in a highly complex Microservices architecture due to having so many moving pieces, complexity in monitoring, complexity in testing, and a hundred other factors, as compared to well built monoliths. Annectodal to be sure, but I think there's strong systemic arguments to be made here...

The scaling issue never really made sense to me. A super common talking point. And it has more relevance when the composable parts of the overall system have bottlenecks on different types of resources (memory vs CPU vs network, etc...) then the argument of scaling them independently, on different types of resources, makes more sense. But most of the time it's CPU that's the limiting factor. With RAM being second on the list.

Using your example, if we assume that Hotel Booking uses 9x the CPU of the other components put together (either due to differing user activity or due to computational complexity of hotel booking), that actually doesn't really impact scaling at all. Let's assume you have a user traffic load that requires 1 server of some arbitrary spec (8 vCPU, 32 GB RAM, whatever). With 90% for hotel and 10% for everything else. Now if you need to support 10x that load, you have 10 servers, each with 90% hotel and 10% everything else (I'm ignoring headroom as it's going to be generally the same across everything anyhow). Versus if you split things up you'd have 9 dedicated hotel servers and 1 everything else server. It's the same 10 servers. The overall compute load and compute resources needed are the same, regardless of the distribution.

You also get advantages of reduced memory footprint if there are any shared libraries or components, and you don't have the performance impact of all the https network calls between services that in a monolith are simple local references within a JVM (for example). That also makes testing easier, and reduces the number of places you need to accommodate failure handling. Etc.. etc... etc...

And if you go with serverless or smaller compute options when you split into Microservices, assuming your workload isn't tiny, you end up paying MORE money for the same compute resources. The smaller the actual physical hardware is divided up, the more you pay per unit of compute, unless you aren't using it all the time (small vs large user loads).

I could go on for hours:).As you can tell this is a subject near and dear to me.

12

u/WaferIndependent7601 Jul 16 '24

I think most people only know microservices and bad monoliths. A bad monolith is no fun to code and hard to handle. If you rewrite all in microservices, it will be way better. At least for some time.

I had a job interview for 2 different companies where they were talking about their microservices and how good they are. About 100 for 4 teams. When I asked „how do you upgrade them? What spring version are you using?“. One company could only tell me that the latest version is spring boot 2.x whatever. „And what is currently online“. No answer to that. On the other company the senior architect was about to update all apps. He was in it for about a month and was not done. Yes, updating one microservice is easier because you have less dependencies so less code changes. But you have to do it 100 times. Can you automate it so good?

Same for monitoring etc.

Microservices are a bad thing. Splitting a bigger service into some parts where it makes sense: that’s the way to go. But never go micro from the beginning

2

u/IAmADev_NoReallyIAm Jul 16 '24

It's just like anything else ... use with caution and moderation. I've worked with some pretty good, well designed monoliths. And I've worked with some truly horrible ones. And a few between. Same with "micro"services... that's where I am now... somewhere between a microservice and a monolith, which is semi ironic becauswe we're trying to replace an aging monolith. Started off as microservices... but now it's complicated enough where calling it that doesn't seem right. But it's not like the monolith either. MicroMonolith?

1

u/sq_visigoth Jul 16 '24

Mediocrelith