News for hackers. Stuff that matters.
Re:You Want Modules, Not Microservices by c-fe on Tuesday January 03, 2023 @08:28AM (#34231022)
I am working on a project that uses a microservice architecture to make the individual components scalable and separate the concerns. However one of the unexpected consequences is that we are now doing a lot of network calls between these microservices, and this has actually become the main speed bottleneck for our program, especially since some of these services are not even in the same data center. We are now attempting to solve this with caches and doing batch requests, but all of this created additional overhead that could have all been avoided by not using microservices.

This experience has strongly impacted my view of microservices and for all personal projects I will develop in the future I will stick with a monolith until much later instead of starting with microservices.

Re:You Want Modules, Not Microservices by padjo on Tuesday January 03, 2023 @08:34AM (#34231087)
I don’t mean to be snarky but how is that an “unexpected consequence”? Were the pros and cons just never considered when deciding to use micro services? Additional networks calls are one of the most obvious things to go on the cons list!
Re:You Want Modules, Not Microservices by arkh on Tuesday January 03, 2023 @08:39AM (#34231129)
Someone must have read a blog post about microservice and decided it would look good on their resume.
Re:You Want Modules, Not Microservices by c-fe on Tuesday January 03, 2023 @08:44AM (#34231180)
Unfortunately this is also partly correct - The team was young and people were eager to play around and learn how to work with microservices.
Re:You Want Modules, Not Microservices by donkeyd on Tuesday January 03, 2023 @09:23AM (#34231656)
This is one of the reasons I dislike working in teams that lack 'old people'. Young devs still have a lot of mistakes to make that old devs have already made or seen. The young ones seem to see them as slow and difficult, but they also create stability and control.

In a start-up, having a team of young people will allow you to move fast, pivot and deliver. What you usually end up with though, is a tower built from spaghetti that's serving actual users. I see this again and again and then people get surprised that the software doesn't scale.

Re:You Want Modules, Not Microservices by selcuka on Tuesday January 03, 2023 @10:09AM (#34232302)
Agreed. This is a corollary of the Second-system effect [1]. By the time developers design their third system they have become relatively "old".

[1]: https://en.wikipedia.org/wiki/Second-system_effect

Re:You Want Modules, Not Microservices by donkeyd on Tuesday January 03, 2023 @04:08PM (#34238092)
This is funny, I'm currently working on a second system that replaced the first. It's awful and I think we need to build the third version.
Re:You Want Modules, Not Microservices by lightbendover on Tuesday January 03, 2023 @10:33AM (#34232688)
I'm so conflicted over becoming an older engineer (having recently moved back from a leadership role). On one hand, I have a wealth of knowledge and can see around corners that the youngsters have no chance of doing. OTOH, it is absolutely exhausting explaining in excruciating detail why I am right time-after-time as new mids join who just want to experiment. That and I am absolutely petrified of my alacrity fading with time.
Re:You Want Modules, Not Microservices by mgkimsal on Tuesday January 03, 2023 @12:12PM (#34234307)
I hear ya. If you feel you've lost your perspicacity, fear not; it's always in the last place you look.

But... yeah. A colleague (25+ years) has to deal with this more than I do, but have hit it some over the years, and it happens more the older I get.

Often he or I may be 'right' but only because of existing constraints in a system. Someone with a different view may even be 'correct' in a nuts-and-bolts technical sense. Yes, A is 8% faster than B. But... we have an existing system in B that meets our current needs, and team who know B, have written it, and maintained it for a couple years. Switching tech stacks to something no one knows for an 8% network speed boost is not remotely helpful.

Re:You Want Modules, Not Microservices by denton-scratch on Tuesday January 03, 2023 @12:44PM (#34234869)
My experience of being the old guy in the team (older also than the manager) was that the young whippersnappers[0] drive new tech adoption regardless of the views of the old fart; the manager waves it through to keep the young-un's happy, and the old fart doesn't find out until it's a fait accompli.

My experience was also that the young manager was very suspicious of the old fart. I've never had any problem working for managers younger than me; but some young managers don't know what to make of a team member that knows more than they do.

[0] No insult intended; almost everything I learned after the first 10 years, I learned from people younger than me.

Re:You Want Modules, Not Microservices by JAlexoid on Tuesday January 03, 2023 @07:35PM (#34240221)
The most amazing kicker is that a lot of 5 YoE get senior status, while still making ridiculous mistakes.
Re:You Want Modules, Not Microservices by c-fe on Tuesday January 03, 2023 @08:43AM (#34231167)
You are right, looking back I also ask why it was not considered more indepth before. I was not involved in the decision making process as I recently joined, and to be honest I would have maybe not thought about it either (but will certainly in the future). I think the main reason this became such a big problem is because we underestimated the number of calls that would be made between the services. Service A was initally supposed to call Service B only as a last resort, so the 10 ms or so were fine, but in the end, the answers that Service B gave turned out to be very useful in our process so more and more calls were made and now they are strongly connected, but still separated services, which is ... not ideal.
Re:You Want Modules, Not Microservices by screamingninja on Tuesday January 03, 2023 @09:35AM (#34231810)
Could this be solved by consolidating service A and service B into one unit while maintaining the overall architecture? I know it's just an example but the whole point of microservices is to have the flexibility to rearchitect pieces without having to rewrite the entire project, so potentially poor initial choices can be reworked over time.
Re:You Want Modules, Not Microservices by unboxingelf on Tuesday January 03, 2023 @11:48AM (#34233916)
Just wait until you decide you need some kind of distributed transaction support across multiple microservices… You should aim to spend a considerable amount of time in the design and discovery phases.
Re:You Want Modules, Not Microservices by LeonM on Tuesday January 03, 2023 @08:39AM (#34231128)
> one of the unexpected consequences is that we are now doing a lot of network calls between these microservices

Not trying to be harsh here, but not expecting an increase of network call in a system where each component is tied together with... network calls sounds a bit naive.

> We are now attempting to solve this with caches and doing batch requests

So you have built a complex and bottle-necked application for the sake of scalability, then having to add caching and batching just to make it perform? That sounds like working backwards.

Obviously, I have no clue on the scale of the project you are working on, but it sure sounds like you could have built it as a monolith in half of the time with orders of magnitude more performance.

Scalability is a feature, you can always add it in the future.

Re:You Want Modules, Not Microservices by ahmetnoid on Wednesday January 04, 2023 @03:00AM (#34243221)
Scalability is not a feature. If you "need" to scale but don't then you're not delivering to your target market, not delivering is not a lack of a feature it's a net loss to the organization. If you're Twitter/Instagram/Uber/whatever you cannot tell your users to not post or like or request a ride because "right now we don't have the scalability feature"
Re:You Want Modules, Not Microservices by LeonM on Wednesday January 04, 2023 @03:58AM (#34243505)
I don't completely agree here.

Yes, if you can't scale fast enough as you need to, it can hurt your business. Not being able to keep up with demand is a (luxury) problem that every business faces, not just in tech. They would often be called 'growing pains' in a business, and though they are bad, they rarely contribute to the failure of a company.

Starting a startup/service/platform with microservices before you even understand the bottlenecks/market fit/customers is usually not a good idea. You can come a very, very long way with a monolith before you hit performance and scalability limits. And once you do, you can always start breaking things up into smaller services for scalabity. Obviously you need to make sure you are scaling on time to keep up with demand.

'Nail it, then scale it', and 'premature optimization is the mother of all f-ups' are popular sayings for a reason.

Re:You Want Modules, Not Microservices by ahmetnoid on Wednesday January 04, 2023 @06:03AM (#34244230)
I'm not making a case in favor of starting with microservices for your startup, that'd be insane, to say the least. I'm just disagreeing with "scalability is a feature". A feature is every addition on top of your minimum viable product. If at some point it becomes apparent that the business needs scalability, then scalability becomes your minimum viable product.
Re:You Want Modules, Not Microservices by davej on Tuesday January 03, 2023 @08:41AM (#34231153)
Twitter has a similar issue according to Musk https://twitter.com/elonmusk/status/1592176202873085952
Re:You Want Modules, Not Microservices by yellow_lead on Tuesday January 03, 2023 @09:39AM (#34231860)
The tweet is obviously wrong.

> I was told ~1200 RPCs independently by several engineers at Twitter, which matches # of microservices. The ex-employee is wrong.

> Same app in US takes ~2 secs to refresh (too long), but ~20 secs in India, due to bad batching/verbose comms.

RPCs are on the server side. Why would they app take longer to refresh in India than in the US?

Some more explanation:https://twitter.com/mjg59/status/1592380440346001408

Re:You Want Modules, Not Microservices by bitL on Tuesday January 03, 2023 @09:56AM (#34232112)
They might be using cheaper caching in India and dedicate the more expensive ones to areas of the world they get profit from.
Re:You Want Modules, Not Microservices by JAlexoid on Tuesday January 03, 2023 @07:40PM (#34240276)
An alternative view of this is - Elon isn't a software engineer, so don't listen to him at all.
Re:You Want Modules, Not Microservices by brasic on Tuesday January 03, 2023 @09:28PM (#34241203)
Yep, this is trivial to falsify, Musk jumped to an incorrect conclusion based on some anecdotes that he did not follow: https://twitter.com/Popeska/status/1592179502838435847
Re:You Want Modules, Not Microservices by davej on Tuesday January 03, 2023 @09:52PM (#34241378)
Musk may just be wrong but isn’t it also possible that the RPCs need to communicate with an edge node in India. Perhaps government regulation requires them to store/serve some user data from India if serving Indian customers? Or something like that?
Re:You Want Modules, Not Microservices by oblio on Thursday January 05, 2023 @08:28AM (#34259258)
Musk last wrote code in 1995, most likely.
Re:You Want Modules, Not Microservices by robertlagrant on Tuesday January 03, 2023 @08:38AM (#34231121)
Some of the services not being in the same datacentre seems orthoganal. If that solves a problem you have, wouldn't it still be an issue in a non-microservices design?
Re:You Want Modules, Not Microservices by goodoldneon on Tuesday January 03, 2023 @08:38AM (#34231119)
If the services need to be in separate data centers then how would a monolith be a solution? Monoliths can't span data centers
Re:You Want Modules, Not Microservices by Ensorceled on Tuesday January 03, 2023 @08:46AM (#34231211)
I'm assuming that those services don't actually NEED to be in a separate data centre ...
Re:You Want Modules, Not Microservices by 0xblinq on Tuesday January 03, 2023 @08:32AM (#34231053)
> However one of the unexpected consequences

How the hell... like... who decided to do Microservices in the first place if they didn't know this? This is such a rookie mistake. It's like somebody right out of high school just read on a blog the new way is "microservices" and then went ahead with it.

Re:You Want Modules, Not Microservices by Pamar on Tuesday January 03, 2023 @09:00AM (#34231355)
well, this is a surprisingly common case in my experience, except that the people were not "right out of high school" but "right out of a company funded seminar on microservices".
Re:You Want Modules, Not Microservices by marcosdumay on Tuesday January 03, 2023 @09:43AM (#34231903)
There is a high amount of correlation between people that start with microservices (instead of using them to solve specific problems after they have the problem) and people that lack any awareness about the resources they need.

And both are way more common than they should be.

Re:You Want Modules, Not Microservices by dogleash on Tuesday January 03, 2023 @01:55PM (#34236106)
>How the hell... like... who decided to do Microservices in the first place if they didn't know this?

Microservices can have both design utility and simultaneously been a major fad.

Lurking reddit and HN you can watch development fashions come and go. It's really really profoundly hard to hold a sober conversation on splitting merits from limitations in the middle of the boom.

tl;dr: gartner_hype_cycle.png

Re:You Want Modules, Not Microservices by londons_explore on Tuesday January 03, 2023 @08:44AM (#34231177)
In which case, the next step for your org is a mandate that all microservices be available in all datacenters.

Let each microservice owner figure out how to achieve their latency+reliability SLA's in every location - whether replicating datastores, caching, being stateless, or proxying requests to a master location.

Re:You Want Modules, Not Microservices by wruza on Tuesday January 03, 2023 @08:51AM (#34231267)
Would be interesting to learn how your (or any other) team defines borders of a microservice. Iow, how “micro” they are and in which aspect. I guess without these details it will be hard to reason about it.

At my last job we created a whole fleet of microservices instead of a single modular project/repo. Some of them required non-trivial dependencies. Some executed pretty long-running tasks or jobs for which network latency is insignificant and will remain so by design. Some were few pages long, some consisted of similar-purpose modules with shared parts factored out. But there was no or little processes like “ah, I’ll just ask M8 and it will ask M11 and it will check auth and refer to a database. I.e. no calls as trivial as foo(bar(baz())) but done all over the infra.

Re:You Want Modules, Not Microservices by Pamar on Tuesday January 03, 2023 @09:03AM (#34231388)
Did you have a common, centralized data store or did each and every microservice manage their own instance?

(Because this is at the same time one of the defining elements of this architecture... and the first one to be opted out when you actually start using it "for real").

Re:You Want Modules, Not Microservices by wruza on Tuesday January 03, 2023 @11:04AM (#34233175)
Yes and no. The "central" part of data flowed naturally through services (i.e. passed in requests and webhooks, not in responses). Microservices maintained local state as well, though it was mostly small and disposable due to whole-intra crashonly design. For example, we didn't hesitate to shut something down or hot-fix it, except for bus-factor periods when there's only few of them. They could also go down by themselves or by upstream, and routers avoided them automatically.
Re:You Want Modules, Not Microservices by systems_glitch on Tuesday January 03, 2023 @09:16AM (#34231564)
I agree that monoliths are the way to start many times, especially if you're not actually sure you'll ever need to scale. One reason we do sometimes plan on microservices from the start with projects is separation of security concerns. Easier to lock a public-facing microservice down tight and have what's ostensibly a non public-facing monolith call out to it.

Lots of ways to solve a problem, though.

Re:You Want Modules, Not Microservices by zrail on Tuesday January 03, 2023 @11:08AM (#34233260)
Yeah, I think this is one of the very few places where splitting out something as a microservice makes sense. For example, you (mostly) never want to open/process/examine/glance at user-provided PDFs on a box with any sort of unfiltered network access. Ideally you do what you need to do within a sandbox that has _no_ network access, but that's really hard to do performantly.

The primary reason for this is that PDFs can contain executable code and the common tools used to process them are full of unpatched CVEs.

Re:You Want Modules, Not Microservices by eternalban on Tuesday January 03, 2023 @09:22AM (#34231640)
Here is an analogy that can inform the implications of this (so-called, imo) architecture:

Imagine if you are responsible, at runtime, for linking object files (.o) where each object is a just the compilation of a function.

Now why would anyone think this is a good idea (as a general solution)? Because in software organizations, the “linker’s” job is supposed to be done by the (“unnecessary weight”) software architect.

Microservices primarily serve as a patch for teams incapable of designing modular schemas. Because designing schemas is not entry level work and as we “know” s/e are “not as effective” after they pass 30 years of age. :)

> monolith

Unless monolith now means not-microservice, then be aware that there are a range of possible architectures between a monolith and microservices.

Re:You Want Modules, Not Microservices by strictfp on Tuesday January 03, 2023 @09:24AM (#34231658)
Yes. If you design a distributed system you need to consider the network traffic very carefully, and choose your segmentation in such a way that you minimize traffic and still achieve good scalability.

For this reason, I've been trying to push for building a monolithic app first, then splitting into components, and introducing libs for common functionality. Only when this is all done, you think about the communication patterns and discuss how to scale the app.

Most microservice shops I've been in have instead done the naïve thing; just come up with random functionally separate things and put them in different micro services; "voting service", "login service", "user service" etc. This can come with a very very high price. Not only in terms of network traffic, but also in debuggability, having a high amount of code duplication, and getting locked into the existing architecture, cementing the design and functionality.

Re:You Want Modules, Not Microservices by c-fe on Tuesday January 03, 2023 @09:30AM (#34231735)
Everything you mention (network traffic cost, code duplication (we instead resorted to auto-generate some shared code between services based on a open-api spec), locked into the architecture) applies to our use case...

And it is reassuring to hear that you seem to have success in avoiding these issues with a monolithic architecture, as I thought I was oldschool for starting to prefer monoliths again.

Re:You Want Modules, Not Microservices by vaughan on Tuesday January 03, 2023 @10:19AM (#34232441)
> Only when this is all done, you think about the communication patterns and discuss how to scale the app.

The main thing is that regardless of scaling, the app should always be able to run/debug/test locally in a monolithic thing.

Once people scale they seem to abandon the need to debug locally at their peril.

Scaling should just be a process of identifying hot function calls and when a flag is set, to execute a call as a network rpc instead.

Re:You Want Modules, Not Microservices by mavelikara on Tuesday January 03, 2023 @04:57PM (#34238674)
The execution model of local calls are quite different from remote calls. Because of these differences, many efforts have been made, but "transparent remoting" is still not achieved [1].

[1] https://scholar.harvard.edu/waldo/publications/note-distribu...

Re:You Want Modules, Not Microservices by vaughan on Tuesday January 03, 2023 @06:56PM (#34239883)
Thanks for the interesting read.

I agree with sentiment of the paper in that it can never be fully transparent. When I say "it should just be a process of identifying hot function calls..." this is admittedly a little contrived - there would need to be a more thorough analysis.

The main point seems to be that partial failure is too difficult to handle without explicitly declaring some objects as "remote".

> Merging the models by making local computing follow the model of distributed computing would require major changes in implementation languages (or in how those languages are used) and make local computing far more complex than is otherwise necessary

Given that the paper is from 1994, I'm wondering if there have been language changes that make this more achievable.

What comes to mind is the event loop. The fact that in Node.js, almost every function call is now an asynchronous promise due to the non-blocking paradigm coupled with the convenience of async/await syntax. These event loop runtimes provide a universal way to hook into asynchronous calls.

I would imagine that in 1994, envisioning the code added to the languages of the day needed to handle timeout and asynchronous invocations would have felt overwhelming.

Also thinking about ORMs and databases. It seems TOPLink for SmallTalk was the first, released in 1995 after this paper was. ORMs seem kind of like "transparent remoting", as they usually can run against an in-memory database or db on a local system, or over an TCP connection, which then needs to deal with latency and failure. And for any app talking to a DB with an ORM, means that the failure cases of the ORM must prevade throughout the stack.

Re:You Want Modules, Not Microservices by mavelikara on Tuesday January 03, 2023 @07:40PM (#34240274)
Thanks for the thoughtful reply.

> Given that the paper is from 1994, I'm wondering if there have been language changes that make this more achievable.

As the paper argues, it is not possible to make remote calls look like local ones. But it is trivially possible to make local calls look like remote ones! Use call-by-value parameter passing, and make all call asynchronous. The most successful solution I have heard of is Erlang's immutable-message-passing model.

Re:You Want Modules, Not Microservices by kyrra on Tuesday January 03, 2023 @09:44AM (#34231939)
May I ask why they are not even in the same data center?
Re:You Want Modules, Not Microservices by pjc50 on Tuesday January 03, 2023 @09:59AM (#34232166)
No personal project has any business using microservices, unless it's specifically as a learning toy. Use a monolith. Monoliths can scale more than you can (provided you manage not to limit yourself to the single-thread single-process version of a monolith). Microservices are an organisational tool for when you need to release chunks independently.

I first wrote a program which ran on a web server about 25 years ago. In that time, computers have experienced about ten doublings of Moore's law, i.e. are now over a thousand times faster. Computers are very fast if you let them be.

Re:You Want Modules, Not Microservices by tofuahdude on Tuesday January 03, 2023 @01:17PM (#34235378)
"Unexpected consequences" for a core piece of the technical approach suggests there are architects that are in the wrong role.
Re:You Want Modules, Not Microservices by omginternets on Tuesday January 03, 2023 @02:40PM (#34236859)
Unexpected?!

Either way, one of my biggest pet peeves is the near-ubiquitous use of HTTP & JSON in microservice architectures. There's always going to be overhead in networked servies, but this is a place where binary protocols (especially ones like Cap'n Proto) really shine.

Re:You Want Modules, Not Microservices by codethief on Tuesday January 03, 2023 @04:08PM (#34238093)
> However one of the unexpected consequences is that we are now doing a lot of network calls between these microservices

I wouldn't call that entirely unexpected. :-) It's a rather well-known issue:

  Microservices

  grug wonder why big brain take hardest problem, factoring system correctly, and introduce network call too

  seem very confusing to grug
(from https://grugbrain.dev)
Re:You Want Modules, Not Microservices by lowbloodsugar on Tuesday January 03, 2023 @11:49PM (#34242144)
>We are now attempting to solve this with caches and doing batch requests, but all of this created additional overhead that could have all been avoided by not using microservices.

> especially since some of these services are not even in the same data center.

I think you need to answer why? If you can't put all of the services in one data center, then by definition you can't write a monolith either. If the monolith would happily run in one datacenter, then you should have all instances of your microservices in that one datacenter.

It surprised me that you would conclude that this is a problem with microservices. It's like if a particularly architect always punches you in the groin in every meeting, and you've concluded that architects are bad people, rather than this one architect is a bad person.

Re:You Want Modules, Not Microservices by nova22033 on Wednesday January 04, 2023 @08:16AM (#34245159)
especially since some of these services are not even in the same data center.

Why is the other service in another data center? Does it need to be in another data center? If it does, how will a monolith help?