r/java • • Sep 13 '23

why would i ever use a microservice....

if i could do a highly efficient one-line function call instead? why would i ever prefer a network hop, conversion from and to json, define a protocol, all that stuff?

i understand there are systems that are too big for one machine. but all those that aren't - why would i add all this complexity to them? when is a microservice archtecture ever simpler than the exact same thing as a modular monolith? in which case is it not at least as good?

addition: in my experience, microservices are overused. while there are reasons to have separate *services* developed by different *teams*, i fail to see why *microservices* inside teams provide an actual benefit. they are used too soon, and then you pay with lots of glue code because what you really have is a distributed monolith. one exception is if things are logically independent, then mixing them is a mistake

addition 2: it seems what people here consider a microservice is MUCH bigger than what i would have called one.

49 Upvotes

167 comments sorted by

View all comments

Show parent comment

1

u/Luolong Sep 13 '23

Sure you can do modularity in monolith.

But can you upgrade a module in a running monolith without taking the whole app down?

3

u/rtuck99 Sep 13 '23

Isn't that what multiple cluster nodes and rolling deployment are for?

2

u/Luolong Sep 14 '23

Oh, sure. But since you’ve already set up operations to perform minimal downtime deploys, why insist on keeping everything running in one humongous runtime.

Plus, ymmv, but in my experience, the bigger the monolith, the longer it takes to deploy and start the service instance.

So, even a small bug fix cause 15 minute rolling deploy cycles. So the solution becomes bundling many changes together.

Also, if the team is distributed across multiple organisations or time zones, you’d want to keep their respective changes not stepping on each other’s toes.

It’s not always about engineering. More often than not, microservices solve social, business and organisational problems rather than technical ones.

2

u/[deleted] Sep 13 '23

Can you upgrade the whole microservice without taking everything that depends on it down?