r/programming • u/Happycodeine • 17d ago
Microservices can work for low-latency workloads
https://madflojo.medium.com/microservices-can-work-for-low-latency-workloads-if-you-design-for-it-ebb19e97bee1?source=friends_link&sk=c2350b171accdb7d8f575da8a017c5a2
81
Upvotes
26
u/Historical_Public751 16d ago
"I don't know what low latency means but I'll say that microservices fit there".
Suuure buddy.
25
u/ArtisticFox8 17d ago
The interesting part would be how to implmenent it. How can I control which underlying connections will be used? I don't think most high level languages allow that. So they wrote some custom networking stack?
113
u/shoot_your_eye_out 17d ago
Or I can just do the simple thing and write a monolithic architecture that lacks the complexity and drawbacks of microservices entirely. And I can change it later if I need to.
Microservices are not a great idea for most applications. You ain’t gonna need it.
16
u/SkinBoogerHybrid 16d ago
This isn't what I would call a microservices architecture, this is a distributed monolith. As the article points out it has replaced function calls with network calls but is otherwise the same.
When you have the Client calling Service A, which calls Service B, which calls Service C, you are missing one of the fundamental benefits of microservices: independent operation. If Service C goes down, Service B which depends on it goes down, and in turn Service A, which depends on Service B, goes down - you are no better off than if you had a monolith but everything is much slower.
The way to make microservices work is to make them self contained. Don't have any synchronous downstream calls to other services. Have each service keep a copy of all the data it needs to do its job, in its own database which it owns, and use a separate mechanism to keep data up to date across the whole system.
That way your service can scale and operate independently, even if the whole of the rest of the system is down.
8
u/garnet420 17d ago
Ok, maybe you can lower latency to be competitive with a more monolithic architecture, but what's the actual benefit? And don't say "robustness" or "modularity"
2
u/bwainfweeze 16d ago edited 16d ago
Every problem is simple if you underestimate it. This article is a preface to an actual useful article, and I can’t tell from this vague-to-the-point-of-harm article whether the author has the aptitude for it or is a lost cause.
The author talks obliquely about fanout but misses the problem of call depth that real microservices invite. Making a call that makes calls that make calls that eventually hit a database, latency is not the only problem, because you’ve now turned bandwidth into additional latency. Marshaling the questions and unmarshaling the responses takes time, but also we generally don’t begin unmarshaling until the last byte of the payload has been received, and that’s a matter of bandwidth. The translation time then adds CPU throughput to the latency. And that is why protobufs exist, and BSON before them, to try to reduce that overhead enough that you can sustain a wider and taller mess. They don’t fix the problem, they just make the shitshow smaller.
The AZ observation is important, but they have replaced magical thinking with different magical thinking. The two reasons we divide services are impedance mismatches for deployments, and scaling services independently. The moment you do single zone routing, you have to round the number of copies of Service A that are running to a multiple of three. If four copies of the service aren’t quite keeping up with demand, you have to spool up a fifth, which is a 25% increase in hardware costs for that service. That decision is made independently in each AZ. But across the entire region, ten copies might be almost sufficient to the load and spinning up an eleventh might ease the oversubscription enough to prevent alarms. Which is a 10% increase.
And this is already a lot here without getting into the stranded resources That EC2 so often represents because the number of CPUs to memory is quite fixed and so the more segregated the services the more twisted they become to try to either avoid using or heavily use memory in order to make the math work. Kubernetes or Terraform can only do so much and especially when you refuse to cross AZs with traffic.
This all gets much more complex when you have a mix of workloads that vary in complexity by an order of magnitude, because now Queuing Theory runs into more corner cases, which is again more latency.
Also they are ignoring Split Brain issues. Cross AZ doesn’t fix them, but at least doesn’t ignore them.
1
u/WindHawkeye 16d ago
Ah here's the hoard of people writing applications that serve 10 customers to argue against microservices.
1
u/daidoji70 5d ago
Yeah but why though?