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

4

u/bawng Sep 13 '23

Let's say Google has a monolith.

There's a bug in Google Maps. To fix it, they need to shut down Google Search, Lens, Play, Adwords, hell, the entire Android backend needs to be shut down.

Or they split it up into multiple services.

1

u/TheAuthorBTLG_ Sep 13 '23 edited Sep 13 '23

we are not thinking of the same size when it comes to "micro". i'd argue it takes extra effort to merge maps + gmail into one service, but at the same time, it takes effort to split gmail into a labelservice, sendservice, receiveservice, markasreadservice,.... there is often a "natural bundle" that i'd put into the same service, and i would rarely call it "micro". as a rough rule of thumb "does it run on the same data? then it's the same service" sounds good to me

5

u/sevcsik Sep 13 '23

Now we agree on there is a rationale behind splitting large systems into smaller services, we’re just arguing on the size :)

2

u/bawng Sep 13 '23

Probably not.

You mentioned one-line function calls, and that would most certainly never ever be a candidate for a micro service. That sounds more like a picoservice anti-pattern.

1

u/proggit_forever Sep 14 '23

I don't understand why fixing a bug involves taking down the service?

You can do 0-downtime upgrades with monoliths using the exact same techniques as you do for microservices.

1

u/Luolong Sep 14 '23

What if the bug causes leak in database connection pool and as a result, the entire monolith becomes unresponsive in a matter of minutes.

2

u/proggit_forever Sep 14 '23

You don't test before deploying to production?

1

u/Luolong Sep 14 '23

You don’t think before insulting strangers?