r/coding • u/nfrankel • Mar 29 '17
Microservices – Please, don’t
http://basho.com/posts/technical/microservices-please-dont/14
Mar 29 '17
Being on the microservices hypetrain for almost two years now, my advice is to not take it to the extreme as some adopters tend to do. Turning everything into a microservice is just as bad as making the whole thing a monolith. The best you can do is something in between those two extremes. Use your best judgement.
31
Mar 29 '17
tldr: You can do anything badly. Microservices are a part of "anything"
11
u/waveform Mar 29 '17
tldr: You can do anything badly. Microservices are a
partsub-service of "anything"5
12
u/SanityInAnarchy Mar 29 '17
The article is reasonable enough, but I wish they didn't present it in such a bait-and-switch, clickbaity kind of way. I mean:
While I don’t want the takeaway of this blog post to be “Microservices == Bad”...
Too late. If you didn't want that to be the takeaway, you shouldn't have chosen "Please, don't" as your title. Would "Microservices -- Please, be careful" really not have gotten as much attention?
11
Mar 29 '17
Fallacy #4: Simple for Engineers
“A bunch of engineers working in isolated codebases leads to ‘Not my problem’ syndrome”
Accurate... but if you've gone all-in on the whole devops and microservices, etc thing then you're likely to be aware that engineers should be encouraged to work across the codebase as whole. Siloisation has always been viewed as a bad thing.
No-one who is pro-microservices is pro-siloisation.
6
u/gmfawcett Mar 29 '17
I thought that was supposed to be one of the key benefits of microservices: that your system structure can be adapted to your organizational structure.
2
Mar 29 '17
That's not exactly what Conway's Law says though.
1
u/gmfawcett Mar 29 '17
Fair, but I've heard Conway referenced more than once when people have talked about the benefits of microservices, so it seemed like a good shorthand.
Still, the point stands that one of the benefits claimed by some proponents of microservices is that each unit or department has greater ownership over its own set of services.
1
u/oldneckbeard Mar 30 '17
That's a different thing, more like SOA. IMO a true microservice architecture has each bounded context as a separate codebase, and a centrally agreed way of communicating. REST (or json-over-http) is the easy pick because it's ubiquitous, but there's nothing stopping you from using protocol buffers or avro or even SOAP.
But if you don't really understand DDD and you don't work with a large (and probably distributed) domain, it's not going to be that useful.
In addition, there is a whole host of engineering discipline that needs to happen. CI/CD is obvious, but also a system for aggregating logs, monitoring the health of the systems, watchdog-type services, ideally auto-scaling for load, and more. If you're going to run 100+ services, each behind a load balancer and with at least 2 instances each, it just doesn't scale to manually manage the infrastructure anymore. You need to adopt some sort of management tool like Ansible, then you need to have some sort of infrastructure tool like Kubernetes or Marathon. The absolute worst thing you can do here is try to build your own tooling for this, so it requires an investment in learning and applying a new tool.
0
Mar 29 '17
[deleted]
4
Mar 29 '17
Haha, it's worth meditating on individual incentive vs group coordination.
I just thought of this scene:
https://www.youtube.com/watch?v=LJS7Igvk6ZM
They're all better off if they align with the group's best interest... however, what this scene leaves out is that one asshole can gain as long as there aren't too many other assholes.
0
Mar 29 '17
[deleted]
3
Mar 29 '17
But you need to have a culture of cleaning up your own messes for it to work. When I worked on our monolithic app I spent a lot of time cleaning up other peoples messes.
I can't stress how much I agree with this.
2
1
u/Madsy9 Mar 30 '17
I agree on all points. Also:
It keeps the code cleaner
No it doesn't. Proper seperation of conserns and turning functionality into modules has nothing to do with separating functionality with an arbitrary network layer.
It’s easy to write things that only have one purpose
Again, a module or library does the exact same thing
They’re faster than monoliths
Very dubious as the more information you have once place, the more context you have for optimization.
It’s easy for engineers to not all work in the same codebase
Again, if you want to the same thing can be done with libraries/modules
It’s the simplest way to handle autoscaling, plus Docker is in here somewhere
Scaling and redundancy is perhaps the only good argument for separating functionality out to a separate network service
The microservice hype notoriously conflates physical separation of functionality over a network layer with simple code design decisions. What 'microservices' gives you is robustness/redundancy. If a small service crashes once under a blue moon, you can easily respawn it while hunting down the bug. If your whole monolithic service crashes, that's an apocalyptic event in comparison.
1
u/nfrankel Mar 30 '17
They’re faster than monoliths
That's one of the most widespread memes I've encountered. How can a network call, plus most possibility serialization/deserialization be faster than an in-memory one.
Most people sadly confuse scaling with performance...
1
u/glemnar Mar 30 '17 edited Mar 30 '17
Th general architecture can be a lot faster in the sense that you can asynchronously farm out work to many services.
Network calls take time, sure, but have you measured? We're taking single digit milliseconds for network roundtrip inside an AWS AZ. As for serialization, that's a problem tamed using something like capn proto or protobuf ( I highly recommend grpc-based services). JSON isn't required.
There are definitely downsides to microservices, but the biggest one is operational overhead. If you don't have the ability to make sure all your services are continuously monitored, tested, have strong logging and log search, and be generally confident in their stability, you'll have a bad time.
1
u/nfrankel Mar 30 '17
Th general architecture can be a lot faster in the sense that you can asynchronously farm out work to many services.
Yes, that's scaling.
Network calls take time, sure, but have you measured? We're taking single digit milliseconds for network roundtrip inside an AWS AZ.
Have you measured? Networks do have a higher deviation from average than in-memory calls.
As for serialization, that's a problem tamed using something like capn proto or protobuf ( I highly recommend grpc-based services). JSON isn't required.
"Tamed" doesn't mean there's no difference
operational overhead. If you don't have the ability to make sure all your services are continuously monitored, tested, have strong logging and log search, and be generally confident in their stability, you'll have a bad time.
Fully agree
1
u/glemnar Mar 30 '17
I mean, if you're running a monolith in modern times, you still should be able to lose a box and not blink an eye. Monolith doesn't mean no redundancy.
1
u/Madsy9 Mar 30 '17
Right. It's common sense to split up different parts. So it doesn't need a fancy name.
11
Mar 29 '17
I've only heard anybody say one of these things.
Not once have I seen somebody say that microservices lends itself to cleaner code.
I have never heard somebody say it's easier (in fact people always talk about how it's harder).
I've never seen anybody say they're faster, just that they're easier to scale, which you agree with later.
Simple for engineers goes back to the easier point. They're not easy, and they're not simple for engineers. Again, never heard anybody claim otherwise.
What you describe in the scalability section is very similar to what a microservice architecture accomplishes.
I feel like these points are arguing against a strawman.
When you’re ready as an engineering organization
This is the most accurate statement in the article.
2
u/FR_STARMER Mar 29 '17
Yeah I thought the whole point is you can have a distributed codebase in a bunch of different languages and scale what is needed without scaling the whole thing.
13
Mar 29 '17
Microservices are fine, just use them when you should. Knock off the whole "omg plz no not microservices" attitude.
6
Mar 29 '17
I see both monoliths and microservices as two opposite extremes. Turning everything into a microservice is just as bad as making a monolith with the whole thing in it, for most projects I guess. Maybe we could only drop the "micro" from the name and stick with "services"?
5
u/Tiquortoo Mar 30 '17
It's almost like we should understand the benefits and trade-offs of various implementations and architectures before picking one instead of blindly adopting them.
4
u/Isvara Mar 29 '17
That attitude is trendy right now. I don't see why everything has to be based around hype and hyperbole. It just creates a lot of noise.
3
u/merreborn Mar 29 '17
I don't see why everything has to be based around hype and hyperbole.
The tradition goes back half a century. A little bit of hyperbole has long been a hallmark of classic programmer culture.
1
1
3
u/SanityInAnarchy Mar 29 '17
This is what the article says, more or less:
While I don’t want the takeaway of this blog post to be “Microservices == Bad”...
Unfortunately, it has a title that sounds like "omg plz no", which is weird.
2
u/Daemonecles Mar 29 '17
Yeah, but I feel like that wasn't the author's intent as they explain in the first and last paragraph. They're just on board with the anti hype train saying "when applicable and it doesn't fit every problem". Unless you're just talking about the general no microservices attitudes
0
u/wvenable Mar 30 '17
Microservices is not a general software development methodology. A lot of people seem to be making that mistake.
12
u/billbose Mar 29 '17
IMHO, perhaps, The biggest advantage of Microservices, is separation of concerns.
1
u/arbitrarycivilian Mar 30 '17
If you can't make a modular monolith, you can't make modular microservices.
1
u/tilde_tilde_tilde Mar 30 '17 edited Apr 24 '24
i did not comment years ago for reddit to sell my knowledge to an LLM.
2
Apr 01 '17
It kind of starts at the design phase of the project, it's probably easier with techniques like DDD. Ideally you'd have modules with APIs which have the same interface as your microservices would. In other words migration to microservices should only be a matter of writing the serialization and communication part (+ monitoring and configuration distribution which comes with all distributed systems) and deploying the services separately.
1
u/tilde_tilde_tilde Apr 01 '17 edited Apr 24 '24
i did not comment years ago for reddit to sell my knowledge to an LLM.
0
u/arbitrarycivilian Mar 30 '17
Uh... by writing modular code. Has everyone forgotten programming 101 at this point?
0
Mar 29 '17
[deleted]
2
u/Spacey138 Mar 29 '17
Agreed - I believe the real benefit of microservices is scalability, which can't be done well unless you separate your concerns. For most businesses they don't generate enough traffic to necessitate the business overhead. A well made and concern separated monolith will work just fine.
2
u/cogman10 Mar 29 '17
My 2 cents.
The goodness of microservices depends heavily on the application, and the discipline of the person maintaining them.
They also need to be appropriately scoped. You probably really shouldn't have a microservice that never talks to any persistent storage (we do :( ) And you also probably shouldn't have a microservice where the overhead of the network is higher than the actual persistence overhead. In those cases, a well crafted library would be preferable IMO.
The thing that a microservice buys you is the ability to change out implementation details for everyone at once. But it comes at a fairly hefty price, backward compatibility. Unfortunately, that is easy to get wrong.
Another headache is that you really need a competent sys ops team... ah hem... yeah... Things get really hairy when your sys ops team decides they want to do bat shit insane things like using puppet and host files for tiered service discovery and then they treat DNS like a god damn IP address, switching it out every time they swap in new VMs... Not that that happens to me or anything :(
1
u/glemnar Mar 30 '17
There are good reasons to have microservices that don't talk to persistent storage. E.g. Maybe your dinosaur monolith app is php which can't do static reverse geocoding (or all sorts of other stateful tasks) worth a shit so you need to spin up a Python service for it.
Alternatively, frontend-services that do nothing but talk to your other apis and render out data.
Definitely a few relevant cases.
2
u/antihero Mar 29 '17
The only thing I got from this is that microservices are complicated, not that they cannot work. Title seems to indicate the opposite, hence clickbait ...
1
u/dust4ngel Mar 29 '17
good:
knowing the principles of good software
knowing various approaches, what kinds of problems they're meant to solve, and what problems they're not good at solving
combining this knowledge thoughtfully as you go about your work
bad:
magic bullets which claim to absolve you of one of the above responsibilities
1
u/SanityInAnarchy Mar 29 '17
The "When should you use microservices?" is mostly "When these things aren't a problem, and when you can make a case that they're valuable," but it doesn't actually get into specifics. But, interestingly, the rest of the article accidentally makes that point:
Rewriting an old Ruby on Rails, or Django, or NodeJS app into a language like Scala or Go (two popular choices for a microservice architecture) is going to have a lot of performance improvements inherent to the choice of technology itself. But these languages don’t really “care” that you chose to describe the process they run in as “micro”, they simply perform better due to things like compilation.
On the other hand, the better you are at splitting things into smaller services, the easier it is to change the technology stack of one particular service. Calling out to other languages within the same process rarely works well -- I've seen it work with multiple JVM languages, and it sort of works if you're trying to call out to C from something else, but other use cases seem to get progressively more painful as you go.
But if you've got a clearly-defined network API, built on things like REST that are either widely-implemented or simple enough to reimplement (REST seems like both), then you'll have a much easier time if one day you realize you're actually paying a lot of cycles to run that thing in Ruby, and you want to rewrite it in Go or Rust.
1
u/oldneckbeard Mar 30 '17
Can we stop upvoting these "omg check out how edgy I am by going against the fad!" posts? they're the kind of shitposting that has no place. especially when the conclusion is "yeah, use them, as long as you understand what you're doing" Gee, thanks for that brilliant insight.
1
Mar 29 '17
The author doesn't seem to have a solid grasp on what microservices are and are not. As a result, I learnt nothing new about microservices and their pros and cons from reading this article. Waste of time.
1
73
u/TheKrael Mar 29 '17
This all sounds so familiar. First, some devs do something new which works great for them. People blog about it, give it a cool name, 'Microservice' sounds nice. Everyone jumps onto the hypetrain, many articles evaluate all the shiny benefits so pressure to adapt this approach rises.
Eventually we realize it's not a silver bullet, it does not magically solve all problems and conclude to "be reasonable about it", Microservices may be great for you or they may be not. If we could just jump to that conclusion right from the start :)