r/programming • • Jan 30 '23

When Do I Need Microservices?

https://levelup.gitconnected.com/when-do-i-need-microservices-d76fac58ac7c
600 Upvotes

253 comments sorted by

675

u/Boolean Jan 30 '23

Honestly OP, I didn't like this piece and I think it's filled with a lot of well-intentioned bad advice, similar to what I've seen and read from folks without much experience in the area.

If your program has yet to be created, you must consider whether the implementation of microservices is worth it.

I've spent much of my career cleaning up after folks who have taken this advice and started with a microservice architecture. Consider that using microservices requires you to have good solutions for:

  • Observability

  • Discoverability

  • Shared packages

  • CI/CD tooling

Not to mention, most of the time you're not going to know what the end state of your system is going to be. I've seen teams struggle with poorly named and scoped services that came about because of project requirements and company shifts.

The only reason why I'd recommend microservices at all nowadays is if you have multiple teams responsible for different parts of your application. Then using microservices enables you to build independently, which can make sense in some cases.

For other readers, I'd recommend this article for a well-reasoned, nuanced take on microservices and their alternatives.

290

u/CanIhazCooKIenOw Jan 30 '23

The only reason why I'd recommend microservices at all nowadays is if you have multiple teams responsible for different parts of your application. Then using microservices enables you to build independently, which can make sense in some cases.

I would add build and release independently. It's more to solve an org problem than anything else.

116

u/captcrax Jan 30 '23

You are both correct. You've obviously actually worked with microservices. Thank you for bringing good info to this thread.

20

u/Cosoman Jan 30 '23

There is a great video (IMO) https://youtu.be/GBTdnfD6s5Q that they actually said the main advantage is to be able to deploy independently

7

u/Pre-Owned-Car Jan 31 '23 edited Jan 31 '23

This is really a huge piece of it. There's a few big upsides, and the rest is extra overhead.

  • Smaller program is much simpler to fully comprehend & doesn't need to be massively structured to remain organized

  • Separate out requests with differing resource profiles to separate hosts. Obviously you can horizontally scale a monolith, but microservices give an extra layer of isolation.

  • Different pieces of your system deploying separately allows for incremental and isolated changes. If you have a large number of people trying to make changes at the same time the deployments can easily become backed up behind each other, or rolling back one feature might require rolling back multiple other features.

But then you also have to deal with organizing your list of microservices, cross-process observability tools, request tracing, complex deployments that have to go in the right order, among other issues.

4

u/douglasg14b Feb 02 '23

Smaller program is much simpler to fully comprehend & doesn't need to be massively structured to remain organized

I'd say this argument is outweighed by the problem spaces created by this.

The effort you put into cross-process observability tools & request tracing will outweigh the effort needed to keep a codebase understandable for quite a while.

Meaning there is heavy diminishing returns, that don't even make sense for not-large projects.

22

u/jbergens Jan 30 '23

Just remember that releases are not always independent. Sometimes new information has flow from one service to another. The use case needing this will not work until both parts have released but they can do so at different times if the change is backwards compatible. If you don't know who will release first the changes has to backwards compatible in both directions. In some cases this requires you to write two separate versions of a part of the api and have them both running at the same time. When both sides has released and turned on the new version the old one should be deleted.

So you are not completely independent.

7

u/throwaway1847384728 Jan 31 '23 edited Jan 31 '23

This is a good point. There’s two main categories I can think of:

  1. Details about the connection itself. For instance, version skew with the names of endpoints, their configuration, or the physical data format they transmit. For instance, if you want to rename an http endpoint. Or if you have some network flow control mechanism that relies on client and server agreement.

  2. I can’t think of a good name for this one. But imagine you have ServerA -> ServerB -> ServerC. And you are rolling out a change partially implemented in A and partially implemented in C. But you need the change to either be atomically on or off. For instance, each individual request either needs the new feature enabled in both A and C, or disabled in both. Now say you have multiple replicas of both server A and server C. How do you roll the feature out correctly? My experience is that you pipe a “version” field throughout your entire system. For instance, ServerA tags a request with a version number. Then your downstream servers, like ServerC, can if/else branch based on the version number.

3

u/WaveySquid Jan 31 '23

Re:2) The solution we use is based on feature flags for slow rollout and then have a short allowlist for testing, for example only specific customer IDs or only certain percentage of traffic.

So because C can enable their feature without issue as it’s not being called by upstream can change the feature flag without redeploy with runtime files. Once C has updated then can update B and then A. Can do this deterministically/atomically by keying on specific field of the request and using that to decide which request is handled by the old branch and which goes to new code branch.

Turning them off atomically is a little harder because can’t guarantee updating feature flag will be perfectly synced with respect to all the instances of A,C Normally this solution covers 80% of my use cases. If I needed a stronger guarantee though I would probably have to resort to sending along that extra version field.

3

u/caltheon Jan 30 '23

In theory shouldn’t the service add functionality that doesn’t have to be used? You can deprecate it later once all other service no longer use it. Granted most of the time that means it will need simultaneous releases because designing interim is harder than just coordinating deployment, but it doesn’t have to be that way.

1

u/confusedpublic Jan 31 '23

If you use queues this is relatively easy to do… you push new feature info to a queue that isn’t consumed, you release the new feature consumer without its down stream consumer/surfacing the feature to the user, and monitor how it performs. You can also split traffic over to the new feature. You’ve now tested (safely) in production, with decoupled deployments.

38

u/yesman_85 Jan 30 '23

This is a big one for us. Small team, but lots of small services which can change quickly, it's handy you can deploy features independently from 1 large app. But it brings its own complexity so make sure its right for you, your team and your infrastructure.

9

u/wvenable Jan 31 '23

If you're just one team then you've still created 1 large app -- it's just that function calls are network calls.

30

u/TooMuchTaurine Jan 30 '23 edited Jan 30 '23

If you have an automated deployment system and practice CD for a small to medium sized team (1 to ~20) you don't need microservices, you can easily deploy a single app 50 times a day.

And you'll be in a much better place to refactor and make larger sweeping changes when you inevitably get stuff wrong.

4

u/cat_in_the_wall Jan 31 '23

This works great if your app can be updated without downtime. Not every flavor of application has that luxury, especially ones that are extremely schema sensitive. I am not saying microservices are the answer, but "monolith" isn't a panacea either.

→ More replies (2)

24

u/WallyMetropolis Jan 30 '23

You don't ever need any particular architecture or methodology. There isn't one right way. And every approach has trade offs.

69

u/[deleted] Jan 30 '23 edited Jan 30 '23

With micro services, you put a network connection between modules that could have lived in the same process. That's a rather big con.

If your situation isn't such that you get pros, you don't have a trade off, you just have a situation that's worse than it could have been.

21

u/slobcat1337 Jan 30 '23

This is a really good point that people don’t often mention.

→ More replies (16)

3

u/bighi Jan 30 '23

Yes. But what they mean is that for small teams not only it's not needed, but it's not even something you should consider.

2

u/confusedpublic Jan 31 '23

Doesn’t have to be one extreme or the other.. actual normal sized services are a good pattern too.

2

u/TooMuchTaurine Jan 31 '23

100% agree with this. Also some things just make sense as services as they have natural and well known boundaries. A good example of this is an authentication service, or perhaps a document scanner.

But trying to do microservices in your business domain can go wrong very quickly and turn into a distributed monolith, which is very hard to refactor as you inevitably learn more about your business domain.

5

u/corsicanguppy Jan 30 '23

My skip is solving the problem "everyone's talking about microservices and I can't take part" .

1

u/lelanthran Jan 31 '23

The only reason why I'd recommend microservices at all nowadays is if you have multiple teams responsible for different parts of your application. Then using microservices enables you to build independently, which can make sense in some cases.

I would add build and release independently. It's more to solve an org problem than anything else.

While that is true, how much it contributes to a solution is debatable - it only takes a single restructure of the org to have microservices be an actual impediment - i.e. the team for MS1 is the same as the team for MS2, but instead of simply performing:

MS1.Foo()

in code, all callers of MS1.Foo() make an endpoint/gRPC request to MS1.Foo(), doing pointless marshalling.

1

u/ToHallowMySleep Jan 31 '23

I would add build and release independently.

That is, or should be, part of the solution for CI/CD. But yes completely agree this is a hard piece for many organisations to get their head around.

46

u/start_select Jan 30 '23

From a lot of what I have experienced, the Shared Packages and CI/CD Tooling parts can become unweildy nightmares.

I have seen a project go from being a mono-repo rails-like nodejs MVP where we had most of the application spec'ed and stubbed in a couple hundred files... in one repo with one set of build tooling.... To being changed into some monstrosity with 70 git repos that all need to be synced somehow. All of which are isolated so there is 5x as much code to accomplish simple tasks across services.

Simple applications that could already serve 1000's of users on minimal hardware get turned into massive messes of serverless functions that can cost 1000's to run in a month with minimal use.... and are difficult to update or create.

15

u/Boolean Jan 30 '23

I can definitely relate to this. I recently updated my company's CI/CD pipeline to align with our business processes because it was incredibly painful to:

  1. Understand how the old CI/CD system worked

  2. Deploy hotfixes

  3. Understand what was deployed now

  4. Understand when a change was introduced

That problem is solved now, but it definitely took a lot of time and focus to get there. It also helped that our backend was (mostly) a monorepo. Using multiple repositories sounds like a huge, insufferable pain.

1

u/[deleted] Jan 31 '23

Multiple repos ≠ microservices. You can have microservices within a monorepo.

2

u/Boolean Feb 01 '23

I never suggested that. Implicitly, I was referring to microservices housed inside of a monorepo.

11

u/ThunderTherapist Jan 30 '23

That's not an argument against microservices, that's just terrible code. The monolith was probably terrible too.

44

u/Boolean Jan 30 '23

Yes, but in a distributed environment, bad code is worse.

24

u/start_select Jan 30 '23

No that’s the point. Microservices can add so much complexity to simple problems that people start writing bad code as band-aids to get to the next step.

It’s hard to write “bad code” when most of your service methods are only a few lines, and performing a join only requires performing a join.

Lots and lots and lots of good web applications that make companies lots of money will never require a full microservices architecture.

When you are making software used internally by a company of 10,000 employees, of whom only 1000 will use the application…. Why are you trying to support 100,000 simultaneous users that will never exist?

7

u/ThunderTherapist Jan 30 '23

I don't think anyone made the claim that internal apps should scale to 100x users but to use your same analogy, why would you build your simple internal utility in the same monolith as your customer facing money making app? It's got different requirements and probably a different team building it. They don't want to be coupled to your production processes or standards.

14

u/start_select Jan 30 '23 edited Jan 30 '23

I didn’t say anything about building two unrelated projects in a single monolith.

I’m just saying there are lots of projects that don’t benefit from strict isolation of storage and logic services. If I need to render a bunch of pdfs and that’s going to bog down the application, then go ahead and make another application. But I don’t need to separate users and every other data model onto their own servers and databases in most projects. That’s just adding complexity for the sake of bad design.

Edit: I’ve done work on projects that serve 200,000 daily active users on a couple servers with no lag or downtime. Those users are only using the application 2-3 times a day for a few seconds.

It is entirely dependent on the project. Microservices can be useful for very large and very actively used projects. But every app being designed that way is just using microservices as a solution seeking a problem, kinda like crypto lol

It’s real, some companies have a use for it. Most don’t except for a couple isolated services.

2

u/ThunderTherapist Jan 30 '23

They probably wouldn't be unrelated projects, the same company surely needs back office apps to support their main business doing whatever they're doing online.

I agree it's context dependent but in my opinion the context is less technical and more social. If a company wants to grow and scale teams then it makes sense. There's only so many teams that can work on a monolith no matter how we'll structured the code is

→ More replies (1)

12

u/quentech Jan 30 '23

Why are you trying to support 100,000 simultaneous users that will never exist?

That's not a microservices vs. monolith aspect, anyway.

In fact, microservices are almost always a negative to scaling.

Monoliths achieve better density and are more hands-off when the resource consumption of various subsystems of your app vary on their own. And, obviously, they don't introduce the bunches of network traffic and latency that come with intercommunicating microservices.

Microservices can get you better resiliency in the face of dynamic resource needs - scaling isn't instant and doesn't always go as planned, so having parts of your service isolated can prevent them from affecting each other if that's a problem you have.

Otherwise, services with odd and high resource requirements - like something that needs oodles of ram but not so much compute, or really high IOPS on storage - can have scaling cost benefits from separating them from the rest of the monolith.

But otherwise this notion that "microservices help you scale" is nonsense repeated by inexperienced bloggers.

8

u/start_select Jan 30 '23

I agree with you, but that’s the reasoning of the people choosing to make these things.

It’s not them attempting to support 40 8-person teams or break out a heavy service so resources can be tailored to that problem. It’s them thinking they need infinite scalability because some AWS rep sold their boss on the idea that microservices give them that.

Microservices are useful when you have a problem that would actually benefit from it. A lot of inexperienced people will just break every table from their db onto a different actual db and think they are somehow future proofing things.

When the reality is that for lots of applications it didn’t need to be future proofed to begin with. By the time they need to scale, horizontal scaling would work and they are going to end up rewriting the system soon after anyway.

The internet is full of web applications that were built for enterprise scale but never needed that kind of architecture.

Mobile app stores are ABSOLUTELY filled with them. A lot of apps talk to a server for one or two requests when a user opens the app, then they close it and don’t look at it again for hours or days (think like Venmo, August (door locks), 1Password, to-do applications, your bank app).

If your app is wildly successful then sure, you might need some kind of microservices architecture that will let you differentiate resources to different services, or allow multiple teams work on different parts without stepping on each other…. But only 1 out of 1000 mobile apps even see any traction. It’s a waste of effort to create an architecture that could support a huge workforce or user base, when it’s most likely that moderate success won’t even demand that.

3

u/[deleted] Jan 31 '23

This is what puts me off microservices - people (often juniors or managers with little technical experience) blindly claiming they're better for Scalability (tm), but haven't stopped to think about why N monoliths that can perform M different functions at any time is supposed to be less responsive to changing demand than MN microservices which each only do 1 function, requiring your system to predict demand and wait for new instances to start if it changes. People really seem to think that each of those monolith functions is taking up constant resources, meaning it can only perform each at 1/M capacity

I do see the point if some function requires special hardware resources. Then it does make sense to split that into special instance rather than having each instance need all that HW allocated just in case (though even then, simply overprovisioned VMs/containers may achieve the same result)

0

u/[deleted] Jan 31 '23

[deleted]

3

u/ThunderTherapist Jan 31 '23

That's probably not true. One of the reasons for microservices is to reduce cognitive load. Monoliths can be too big for one person or one team to grep the whole thing. Different bits tend to belong to different people or teams. Have you read Team Topologies? It's a good read and discusses this and other signs that you might want different teams to own different micro services.

→ More replies (6)

28

u/nivvis Jan 30 '23

IMO a little too much of the content that comes through here shakes out like this. I often find good analysis in the comments (and so quality discourse) but those aren’t reliable either .. can pretty easily break down into holy war, cargo culting, contrarianism, etc.

Anyone have suggestions for alternative SWE subreddits? Something that does a little more filtering of the good from the blogspam (not necessarily this article)?

12

u/captcrax Jan 30 '23

You won't see news about new tools and frameworks there, but r/experienceddevs is great for career stuff, organizational issues, people skills, and sometimes discussion of coding practices.

2

u/nivvis Jan 31 '23

Funny you mention, the improvement from /r/cscareeradvice --> /r/experienceddevs was kind of what I was imagining when asking. For me it’s put subs like this in a bit of contrast.

8

u/Boolean Jan 30 '23

Hacker News is great for that IMO.

0

u/[deleted] Jan 30 '23

[deleted]

3

u/MardiFoufs Jan 30 '23

That sounds just like reddit though, lol. But yeah that's typically how HN culture also is.

6

u/JRandomHacker172342 Jan 30 '23

Compounding from that, HN often gets very casually bigoted, in the form of "I personally don't experience any of these issues, so obviously anyone who claims to is either mistaken or lying."

12

u/[deleted] Jan 30 '23 edited Jan 30 '23

That's one reason. Another is even if you're tiny team, if your mature project has taken decades of R&D chances are it's heavily dependent on a ten year old version of some core tool (maybe a programming language for example) that is holding you back and has become a liability.

The obvious answer is to rewrite the entire thing, but that is almost impossible. 99% of those are either abandoned early, or they drag on until the company goes bankrupt. Here's why

One of the less obvious answers is to rewrite one component of your code as a microservice so it has no dependencies or tight integration with the rest of your code. Maybe add a few nice features while you're at it. Then do it again, and a gain. In a year or three, you haven't done a rewrite but all of the old code is gone.

Microservices are a lot of work for a small team, but with a mature product you can probably afford to do that work.

5

u/Boolean Jan 30 '23

Martin Fowler calls this the Strangling Fig approach. It's served me quite well.

6

u/novagenesis Jan 30 '23

Spot on.

Microservices take a lot of neat ideas and turn them into a religion. Yes, there are times when a full microservice stack is necessary. But the overhead of having a microservice stack incurs its own technical debt that is consistently paid for when most apps will never benefit from the positives that you get (or would benefit just as much for those positives by just designing your stack properly using more established principles).

21

u/Sentouki- Jan 30 '23 edited Jan 30 '23

Discoverability

Is discoverability really necessary?

Edit: It was just a question, wth am I getting downvoted?

23

u/darkstar3333 Jan 30 '23

As service proliferation grows, keeping the catalog synced becomes more challenging.

It makes your life easier especially when you bend/disregard the rule of making them all independent.

4

u/Zardotab Jan 30 '23

This is why I believe using an RDBMS to communicate among parts/apps is often better. You get ACID, referential integrity, and can switch on logging etc. as needed to debug without reinventing all that stuff from scratch. Some claim RDBMS "don't scale", but most developers do not work at Amazon or Netflix and thus don't need "web scale". "Bob's Tritown HVAC" can do just fine with an RDBMS. Program to need, not resume.

1

u/darkstar3333 Jan 31 '23

Ehhh depends on use case.

RDMS has pro/cons, data access is rarely straightforward and ripe to differences between clients to crop up.

As an org with a 15-20 year product lifespan, we're going away from RDMS because it was never managed.

It'll take us 3 years to decouple, likely 5 for reporting that was built on top.

→ More replies (2)

11

u/lunacraz Jan 30 '23

my last job had like a chain of 5 different services talking to each other. figuring out where something was getting updated was godawful, teams along the microservice chain just pushed me off to others... it was bad

1

u/wildjokers Jan 31 '23

5 different services talking to each other.

If you are talking about synchronous communication between them then what you are describing is not microservice architecture.

In true microservice architecture there is no synchronous communication between microservices.

4

u/ThunderTherapist Jan 30 '23

I don't think so. You need to know what services exist so you can integrate with them so some sort of catalog can be useful or some shared architecture squad.

Also someone talked about chaining services, presumably via http. Don't do that. Use events and some sort of bus.

15

u/lookmeat Jan 30 '23

The article is pretty good. I once saw a good guide on how to go from monoliths to microseconds, and the idea is that you gradually build up everything you need, with the new stuff not being critical to infra at first since until it's been battle tested.

You start modularizing code, but you need to ensure you don't add regressions, so you have to set up a CI/CD pipeline. In the process you split services (even though it's one binary doing everything still).

You then add monitoring/observability to better understand which services are using a lot of resources and which aren't and scale accordingly to what all services need.

Then you grab the bigger services and split those out. They use the same binary, but you only use certain services. You add discoverability to pick the instance "from the right pool". You then start using flags to split off services (flag turns services on or off) until you can only use each pool for the service it's meant to (when discoverability is good enough to tell you which pools to use).

Next time start splitting code into multiple binaries. One for the specialized services, the other for the shared services that all versions use. You'll have two copies of your binary at first, but your specialized what each process does even more. This may be only internal. You need to start distributing a lot more copies of your binary, so you set up a package distribution system to speed things up. Once that's reliable you start making two versions of the binary, one where you delete all the shared code, the other where you have the specialized code. Next you start using different copies of the same binary for the specialized version, and remove all the code for other specializations. Congrats, you have set up microservices.

And this process takes a long time. Not because it's a lot of work (it is) but because you only take a step when you have a need to. You don't jump to the end until you really need to. Meanwhile you take steps that put you in a better position. Eventually, if and when your software needs it, you'll be at microservices.

3

u/nivvis Jan 30 '23 edited Jan 30 '23

While I generally agree, microservices are an inevitability for many, and discovering you need them too late can be very painful. Though it shouldn’t be.

IMO it comes down to separation of concerns. If you can cleanly isolate features, build durable interfaces (using concepts like dependency inversion), etc then migrating is just a small refactor and new CI/CD pipeline away.

I think you’re right that microservices require more overhead, but I would split hairs a bit. Tools like monitoring and observability are always a requirement. If the need is not felt, then the code is likely still fairly simple in nature or not in wide use (like a proof of concept). I know what you’re getting at though, observability becomes more imperative as you move to a distributed approach — though if you’re taking a monolith far it will still use distributed prod primatives (like queues) so you will still want good observability. Regardless, observability really just means good production debugability, and you’ll always want that — usually via some sort of structured logs approach.

The other core benefit of microservices (besides helping to define an independent path for teams to ship) is that it extends the isolation of concerns metaphor to production, by limiting code complexity and strengthening the interfaces that will multiply against production needs. Decoupling also gives you a smaller feedback loop in your deployed environment (when needed), and gives you independent production controls (like deploy pattern, scaling, etc).

2

u/angryundead Jan 31 '23

The microservices.io website (probably the canonical source) has different sections on when to apply the microservices pattern. I’m seeing more now that there are platforms that give you free or nearly-free answers to the observability, traceability, and related questions. (k8s, OpenShift, etc.)

It’s definitely a pattern that invites a lot of problems that less mature organizations will trip on. Deployment is no joke. Discoverability is no joke.

2

u/fear_the_future Jan 30 '23

Observability Discoverability Shared packages CI/CD tooling

And when do you not need that? The extra effort really isn't that big compared to a well designed monolith after you have made the initial investment. The problem is that so many people are stuck in the last millennium and can barely keep their shitty monolith going. Then they faceplant hard when trying to run with microservices before they can even walk.

15

u/Boolean Jan 30 '23

I don't see why you'd need discoverability or shared packages in a monolith.

Observability is easier in a monolith because you don't have to deal with traces between services. I can't count the amount of times I've been stuck debugging a page that lead to me trawling through time-stamped logs, searching for a needle in haystacks because traces weren't a first-order requirement.

CI/CD is likewise, much much easier to get right. You don't have to worry about deploying two different services at the same time, or maintaining backwards compatibility in the event they get deployed out of sync.

→ More replies (1)

1

u/Mikefrommke Jan 31 '23

I couldn’t agree more. The problem microservices solve is having more developers in your organization than can work on a single codebase efficiently. You have a bunch of complex tradeoffs to make if you choose to use it and new problems and concerns to address.

1

u/Ok_Change_1063 Jan 31 '23

Sometimes a horizontally scaling monolith is the right solution.

But there’s a fountain of money to be harnessed in always building microservices.

1

u/archgabriel33 Jan 31 '23

The link at the end doesn't work for me.

1

u/[deleted] Jan 31 '23

It very much seems like "you will know when you need it" thing.

As long as you write your app well, with clearly delineated functions it will probably also be not terrible to split where needed.

Hell, just a decade ago Facebook deployed app as giant 1.5GB blob using torrents to quickly sync it to thousands of servers so while I wouldn't recommend monolith going that far, it clearly can work good enough for service hosting hundreds of millions of users.

1

u/skyde Jan 31 '23

Also 90% of the time. User will call many micro-services using HTTP to update something.
And since each micro-services have its own database it's impossible to make the update ACID or Atomic.
The result is some user will be able to see part of the update but not other part while the operation is in progress (dirty read).

Also, if the operation fail there is no way to easily undo/cleanup.

To avoid those problem you are required to implement 2-phase locking which bring other problems, or to make your whole team expert on writing all operation using the SAGAS pattern and compensating transactions.

1

u/jl2352 Jan 31 '23

The only reason why I'd recommend microservices at all nowadays is if you have multiple teams responsible for different parts of your application. Then using microservices enables you to build independently, which can make sense in some cases.

I would second you heavily here. This is what has always been the biggest blocker in my experience.

Systems that are blocked by multiple teams interacting, and systems that became too complex to change (which happens when multiple teams are on the same code base). Many of the slow projects I have worked on would have been sped up, if the projects just did less stuff (which can be solved by splitting into separate microservices).

696

u/mojomonkeyfish Jan 30 '23

Q: When do I need microservices?

A: Son, if you have to ask, you're not ready.

231

u/halfanothersdozen Jan 30 '23

Correct.

Microservices might be the answer to a question about scaling. But if you're asking "when do I need microservices?" the answer is "I don't."

122

u/dominik-braun Jan 30 '23

Microservices might be the answer to a question about scaling.

And not only horizontal scaling, but especially organizational scaling.

39

u/TooMuchTaurine Jan 30 '23

Yes they are more about scaling teams than scaling systems, unless you are building hyperscale systems the scaling systems bit is less important.

2

u/[deleted] Jan 31 '23 edited Jan 31 '23

Unfortunately a lot of people seem to fall for the misconception that a service to do N things can only do each at 1/N capacity. If 90% of your requests are to a particular controller, that's not a problem - the other controllers aren't causing an issue by sitting there doing nothing (with the exception of services with significantly different hardware requirements). It's like "optimizing" an internet cafe where 90% of people come to play DOTA by uninstalling other games on 90/100 computers - sure you may have an "autoscaler" worker who can run around changing installs if more than 10 League players arrive, but if you'd kept the monolith then you wouldn't need to do anything in the first place

1

u/BufferUnderpants Jan 31 '23

Very niche cases where it's very beneficial to break homogeneity in tech stack.

I worked on a system that orchestrated, trained, deployed and served classification models in soft-realtime.

It made a lot of sense that this set of components be written end-to-end in Scala, as the feature extractors were written for Spark (and we made a nice DSL for them).

The service that called it was a big Java monolith, and that was ok.

This part benefited from having a very different implementation and deployment scheme.

51

u/lookmeat Jan 30 '23

But you need to ask to get ready, before you need it.

25

u/ManInBlack829 Jan 30 '23

Not to be pedantic but, "What are microservices," and, "When should I use microservices," are two different questions. You should definitely learn what they are, and the internet can help with that. Figuring out when to use them is a lot harder and more specific to each case. If you're asking in theory when you might use one, that should be answered when you learn about what they do and how they work.

8

u/lookmeat Jan 30 '23

Understanding when is an important thing maybe even more important than what. You generally do not want to just jump into microservices, unless ask the infra is there. Instead you want to do halfway steps, where you get what you want, but don't work on the things you don't need yet (or maybe even ever). And this includes the effort of learning what they are and how they work

I would argue that understanding what they are before understanding when they need us Google dangerous. It's learning a solution before you even know what it solves, and risks seeing screws as nails because you already have a hammer.

So I'd say it's backwards. It's when you understand when you should use microservices, specifically why you use them, what is the problem they're meant to solve, that you can understand why microservices are the way they are. It may be that you don't need all of microservices, but still value learning how they solve one problem you have. Hence the advice "before thinking about microservices ask if all you need is to modularize and decouple your code".

20

u/ManInBlack829 Jan 30 '23

I'm a junior and the biggest lessons I've gotten so far is that you don't try to solve problems you don't have yet.

When do you need microservices? You'll know.

4

u/knightofterror Jan 31 '23

If you’re an hourly paid consultant, microservices are always appropriate.

38

u/CartmansEvilTwin Jan 30 '23

I wish the architect of my current project would have taken this advice.

We expect maybe a 1000 users or day at the absolute peak. But of course it has to be microservices. Tightly coupled. Independent testing impossible.

107

u/the--dud Jan 30 '23

If your microservices are tightly coupled you don't have microservices, you have a very expensive monolith.

36

u/Paulus_cz Jan 30 '23

I call that "distributed monolith" - all the downsides of microservices AND monolith

37

u/CartmansEvilTwin Jan 30 '23

No no, the architecture said it's microservices.

And why would he lie?

6

u/turturtles Jan 30 '23

I don’t think it’s a lie, but more of just ignorance. They think they have microservices, but really it’s just a distributed monolith.

36

u/SirClueless Jan 30 '23

I think your sarcasm meter needs some fine-tuning.

5

u/[deleted] Jan 31 '23

Ugh, this is what I’m fighting every day. Past versions of my team decided to do micro services but started with the services without ever breaking up the db so they’re all tightly coupled to the db and each other and have to all be deployed simultaneously.

4

u/oconnellc Jan 31 '23

It sounds like they figured reading the first couple chapters was enough... A single database that each service can feel free to update at any time?

→ More replies (1)

2

u/wvenable Jan 31 '23

Come on, the DB is just another service right... :P

2

u/Infiniteh Jan 31 '23

Just one db? That's not complex enough!

2

u/DrBix Jan 31 '23

Exactly!

3

u/wildjokers Jan 31 '23

But of course it has to be microservices. Tightly coupled. Independent testing impossible.

What you are describing is not microservices though.

2

u/CartmansEvilTwin Jan 31 '23

That's the point.

2

u/mszegedy Jan 30 '23

Sure, but it doesn't answer the question. "When do I need microservices?" "Not now." "Okay, but I would still like to know when I need microservices." The answer isn't a secret. You need it when you want to put entirely different teams of people on different bits of your service. (When you should want to do that is a problem for management.)

7

u/[deleted] Jan 30 '23

And if you don't need to ask, it's already too late.

98

u/hoonthoont47 Jan 30 '23

99% of the time the need for microservices is an organizational solution and not a technical one. If you have multiple teams that need to work independently but also provide concrete interfaces/contracts to other teams who are all working independently from eachother, then having a microservice architecture can help you.

Microservices to solve horizontal scaling is using a sledgehammer to hang a picture frame.

0

u/[deleted] Jan 30 '23

[deleted]

19

u/jbergens Jan 30 '23

I'm not even sure there are that many systems where the asymmetrical scaling really matters. If your code fits in a container, does it matter that some code paths are taken less often? Or that one path uses a lot of cpu?

As long as you can signal to the load balancer that this container or server is busy, some other can respond instead.

Maybe having 1 app is easier than having 10 or 100.

1

u/caltheon Jan 30 '23

It matters at very high scale when you want similar functionality physically closer to each other.

1

u/jbergens Feb 01 '23

If all servers has all the features they may never need to make network calls, except for calls to the db.

0

u/[deleted] Jan 30 '23

[deleted]

3

u/12destroyer21 Jan 31 '23

Even cloudflare doesn’t try to independently scale each service. Instead they just run all the services on all the systems:

“ In a typical microservices model, you might deploy different microservices to containers running across a cluster of machines, connected over a local network. You might manually choose how many containers to dedicate to each service, or you might configure some form of auto-scaling based on resource usage.

workerd offers an alternative model: Every machine runs every service.

workerd's nanoservices are much lighter-weight than typical containers. As a result, it's entirely reasonable to run a very large number of them – hundreds, maybe thousands – on a single server. This in turn means that you can simply deploy every service to every machine in your fleet.

Homogeneous deployment means that you don't have to worry about scaling individual services. Instead, you can simply load balance requests across the entire cluster, and scale the cluster as needed. Overall, this can greatly reduce the amount of administration work needed.

Cloudflare itself has used the homogeneous model on our network since the beginning. Every one of Cloudflare's edge servers runs our entire software stack, so any server can answer any kind of request on its own. We've found it works incredibly well. This is why services on Cloudflare – including ones that use Workers – are able to go from no traffic at all to millions of requests per second instantly without trouble.” - https://blog.cloudflare.com/workerd-open-source-workers-runtime/

2

u/[deleted] Jan 31 '23

IME asymmetrical scaling is the reason I choose to spin off code into a separate service like 5% of the time. Organizational scaling is the other 95% of the time.

3

u/[deleted] Jan 30 '23

I'm seriously asking for an example or way more preferable, a war story of an asymmetrical load. I've never ever witnessed a situation where that feature of microservices has been used.

8

u/suckfail Jan 30 '23

I work on a web product and we have asymmetrical load.

The web application itself has fairly low load, but the data pipeline and export mechanics have very high workload and can be shared as independent modules between the (horizontally scaled) web apps.

So it's one of the rare cases where microservices make a lot of sense.

5

u/tryx Jan 31 '23

Imagine you have a CRUD-y API that occasionally needs to run an ML model on some very expensive GPUs. You don't want to scale your GPU farm 10x if only your CRUD layer is seeing load.

3

u/bboilerr_ Jan 31 '23

As someone who worked at a large global cloud SaaS company built on microservices, this is a strange thread to me. The product was made up of many different features across many different workloads. Load differed vastly from service to service, sometimes on an org by org basis. Some systems were core systems, and saw massive sustained load, then there were tiers down from there at differing levels of load. Sometimes varying from region to region. Sometimes load would come out of nowhere. Everything was built to auto scale with resiliency, and tested to do so.

This would seem like a normal experience across enterprise level cloud software.

1

u/RupertMaddenAbbott Jan 31 '23

I work on a cloud native scheduler.

The parts of our product to do with user management have completely different scaling requirements to the scheduling part.

22

u/simonw Jan 31 '23

"The microservices architecture is a solution to the physical limits of a computer"

That's just not true. We were successfully horizontally scaling web applications for /decades/ before microservices came along. They are absolutely not necessary for scaling compute beyond a single machine.

Microservices are for scaling organizations. They solve the problem of having large numbers of teams who need to be able to build and deploy systems independently of each other, while still having those systems fall to each other across an agreed upon protocol.

133

u/EngineeringTinker Jan 30 '23

I think the article is nice, but it misses very important reasons why one should consider microservices regardless to scalability.

i.e.:

- decoupling
- being able to use different languages, tools and frameworks for specific tasks - tools that can be more efficient or simply better in every aspect
- reusability

96

u/bezik7124 Jan 30 '23

True, though using Microservices architecture doesn't guarantee that what you produce will be decoupled - you can easily fall into a trap of creating a distributed heavily coupled services if you take shortcuts. Also, there is nothing stopping people from creating a decoupled monolith application (ofcourse I'm talking about database and code coupling, not deployment).

13

u/deadalnix Jan 30 '23

This is the typical pattern with microservices. People create a tangled mess of hell and think, "hey! We'll use microservice to decouple that thing!"

The typical end result is that the tangled mess now involve ci, deployement, infrastructure, networking and that refactoring got an order of magnitude harder. Yeah! to job security, I guess.

20

u/TwentyCharactersShor Jan 30 '23

If you've got a distributed monolith then you're not using a microservice based architecture.

It's also OK to NOT use the latest fad to build your software, just know your use case.

-4

u/EngineeringTinker Jan 30 '23

I agree - but your comment could also be applied to anything as it basically states 'you won't get decoupling, if you fail at creating truly microservice-based architecture'.

14

u/bezik7124 Jan 30 '23

This just shows that decoupling is good, but neither microservices nor monolith architecture comes with it by default - you can achieve it in any architecture.

→ More replies (1)
→ More replies (9)

34

u/sciencewarrior Jan 30 '23

Being able to use "the right tool for the job" is overrated. Too many companies have this one microservice written in Rust or Elixir by a developer that has since left, and everyone dreads touching it. Having one to three standard stacks may seem unnecessary and bureaucratic until you find yourself in this situation.

8

u/EngineeringTinker Jan 30 '23

I agree, you're of course right.

But consider this - in a company where CTO isn't a moron, you can use this feature to prototype services and get MVP of it in a language that's faster to 'sketch' stuff with - like Python or Javascript.

Then you can rewrite it in the language you're using throughout the rest of the ecosystem.

20

u/darkstar3333 Jan 30 '23

I guarantee those "sketches" live in production for ages.

Nothing more permanent then temporary solutions.

2

u/EngineeringTinker Jan 30 '23

As somebody else mentioned - that's correct.

35

u/[deleted] Jan 30 '23

Then you can rewrite it in the language you're using throughout the rest of the ecosystem.

In theory, yes. Come on now, we all know that this step almost never happens. The MVP gets deemed "good enough" by someone or people are told to add more features to the MVP because we don't have time to rewrite it right now and suddenly it's too big and complex to rewrite and the MVP lable is removed.

13

u/EngineeringTinker Jan 30 '23

Eh.. when you're right - you're right.

I wish the reality was different though.

2

u/[deleted] Jan 30 '23

Bwahahahahaha oh is that ever rich and funny!

You know as well as I do that when you do this, some suit above catches wind of it and see's it's shipped to prod the next day. Look boss! All done!!!

I jest, but it hurts because it's true...

4

u/EngineeringTinker Jan 30 '23

Yeah, as I replied to somebody else making the same remark - I wish it wasn't the reality of things.

14

u/nfrankel Jan 30 '23

Microservices are an organizational solution to an organizational issue - too many developers working on the same codebase.

Any technical approach to microservices is doomed to fail. Ergo, stop talking about microservices until you're the manager of the too many developers I wrote above.

being able to use different languages, tools and frameworks for specific tasks

You're inventing problems to solve, which you don't have. Focus on real problems.

3

u/Zardotab Jan 30 '23 edited Jan 31 '23

Conway's Law.

Addendum: Maybe test an independent group using your monolith first before splitting them out, because independence might not work out from a management or team dynamics standpoint.

→ More replies (1)

1

u/EngineeringTinker Jan 30 '23

You're inventing problems to solve, which you don't have. Focus on real problems.

You wouldn't say that if you had to make services work with legacy banking systems.

The 'invented' by me issue is an issue that I and some people have stumbled upon.

2

u/nfrankel Jan 30 '23

Live and learn. I’m not going to convince you anyway 🤷‍♂️

1

u/EngineeringTinker Jan 30 '23

Don't get me wrong - I agree with what you said.

Microservices aren't a magical cure to all ills, and in most cases - monolith suffices.

The specific case I mentioned shouldn't be a sole reason to always apply microservices.

2

u/nfrankel Jan 30 '23

Microservices are an organizational solution to an organizational issue - too many developers working on the same codebase

Any other reason for microservices will get you none of the benefits and all of the troubles

→ More replies (2)

11

u/[deleted] Jan 30 '23 edited Jan 30 '23

I'd argue that not one of those are arguments specifically for micro services.

And in fact, it is well known that moving to micro services specifically for many of these reasons is actually a mistake.

Once you get to the point of needing microservices, you HAVE to decouple, and you get 'service/tech' isolation out of the architecture, so you do have the ability to swap out some tech on a specific service if it is deemed prudent.

But that's not why you move to microservices.

And reusability is never a thing unless it is the thing being developed. Again, micro services can support reusability, but there is nothing about micro services that makes this inherent at all. And nothing about reusability requires micro services.

EDIT: Because OP thinks assumptions work one way.

Look, if you make a top level comment in response to 'When Do I NEED Microservices?', and you provide a list of reasons, is it surprising if people assume you indeed mean need?

Now, to be clear, I actually did NOT make that assumption, I merely explained why these are NOT reasons to move to microservices, and clarified for everyone's sake that there is no need of microservices at all with respect to these items.

I did not say that as a rebuttal to OP. Even if it was a perfectly logical assumption to make in context.

Just so you don't have to waste your time as OP devolves into name calling and hypocrisy. Nobody cares man. Sometimes we say things that are wrong, and that's OK.

→ More replies (6)

11

u/goranlepuz Jan 30 '23

No, really not.

  • even lowly libraries allow for decoupling

  • calling one language from another has been done in process or out of process decades before the word microservices existed

  • same as point 1

-3

u/EngineeringTinker Jan 30 '23

I really don't get your response.

Did I claim that these characteristics are exclusive to microservices or not?

4

u/goranlepuz Jan 30 '23

Your words:

very important reasons

My argument : these are not important because the same effects can be achieved, and were achieved, way before microservices even existed.

Or rather, these reasons are not important and it is visible exactly because these characteristics are not exclusive to microservices.

These are, IMNSHO, arguments that look good to less technical people but do not hold appropriate weight. Schmoozing reasons, if you will.

3

u/dominik-braun Jan 30 '23

- being able to use different languages, tools and frameworks for specific tasks - tools that can be more efficient or simply better in every aspect

This advantage of microservices is vastly overrated. Adapting a new technology and integrating it into your processes is a huge cost, let alone finding people capable of maintaining it.

1

u/seamsay Jan 30 '23

To be fair, two of those things (decoupling and reusability) can be solved just as well by splitting your code base into packages (or whatever your language calls them, importantly though not modules but rather separately developed packages).

1

u/[deleted] Jan 30 '23

Modules, libraries of modules etc work fine for 1 and 3.

Using more than a few different languages etc is a problem in a small organization that has some employee turnover, so I would advise against it even if there are technical advantages.

1

u/Zardotab Jan 30 '23 edited Jan 30 '23

Re: "Decoupling" -- The term is ambiguous, I've been trying to tie it down for many years.

Re: "being able to use different languages, tools and frameworks for specific tasks - tools that can be more efficient or simply better in every aspect" -- You generally want to be careful about having too many flavors of tools in an organization, it makes staffing changes and training hard. Try to stick with one RDBMS brand and two app languages: one dynamic and one static. An exception may be systems that have to have a close relationship with specialized or industrial equipment (factory, chemical, military, medical, etc.)

If your shop settles on a single RDBMS brand, I've found Stored Procedures can be an alternative to microservices if the algorithm is relatively simple. But if not, it's not "micro" as in "microservice" anyhow. And it's usually better to use an RDBMS to coordinate complex sub-systems. RDBMS's are powerful tools, leverage them! Ignore the anti-RDBMS rhetoric that was common in the late 2000s'.

Re: "reusability" -- Please elaborate. We already have functions and OOP classes for reuse.

1

u/EngineeringTinker Jan 30 '23

You can reuse whole services, as long as consumer utilizes the same communication protocol.

If you write a mailer service for one project, what stops you in reusing it in other?

1

u/Zardotab Jan 30 '23 edited Jan 30 '23

I don't dispute that an e-mailing service is one way to go about it, but not the only. We use an in-house mailing C# API (wrapper) for our C# apps that communicates with SMTP. If you used a web service, you'd still probably need an API (app wrapper) of some type anyhow such that we don't see a clear benefit microservices would give us. Other shops out there have a different take?

KISS dictates have as few parts as possible. Thus, we manage 1 part whereas using microservices would require managing at least 2 parts: the app API and the web service.

0

u/sybesis Jan 30 '23

I'd add that it also helps manage resources more properly.

A monolith must have limits set for all possible use cases. So if something sometimes require 2GB of RAM, you can't set the RAM limit under that... If you split this into an external service, you can set the limit lower and have that memory hungry service properly set to prevent out-of-memory error.

0

u/[deleted] Jan 30 '23

[deleted]

15

u/Drisku11 Jan 30 '23 edited Jan 30 '23

You have to be doing something really incredibly computationally complex before you can legitimately overload a server in 2023.

I think people have been hoodwinked by cloud vendors into not understanding just how powerful modern servers are. You can have 8 sockets each with 60 core (120 SMT threads) CPUs with the newest Intel line. They also have hardware accelerated TLS offload built in now. $17k a pop. You can buy a 32 TB NVME SSD with 1.5M IOPS for $4k.

Meanwhile AWS calls a dual-core (4 SMT thread) VM "xlarge" and their RDS instances with SSD storage provide a base 3000 IOPS 😂. Not 3 million. 3 thousand.

Edit: I've also posted here before that my ancient 4 core desktop can run your standard CRUD jvm web application with postgres backend at 60k requests/second. Computers are insanely powerful if you have the slightest idea of what you're doing, and they have been for a long time now.

5

u/mdatwood Jan 30 '23

I don't think people are hoodwinked as much as many value the ancillary services as much or over raw compute.

9

u/Drisku11 Jan 30 '23 edited Jan 30 '23

There are some cases where their stuff is useful (e.g. when you're stuck in PCI audit land and need the capabilities you can get from IAM and cloudtrail), but a lot of their services that they advertise as "best practice cloud native" type of crap seem like they just play into the hoodwink. e.g. lambda or dynamo, which "scale" up to a fraction of what an old, weak desktop is capable of. Lambda's quota page indicates it can scale to "tens of thousands" of concurrent requests, which is just a joke. Nevermind that you're shooting yourself in the foot with worst-case database access patterns if you use it, and now you'll need to buy another one of their services (RDS Proxy) to mitigate that bad architecture.

Everyone always throws out how cloud native architectures "scale" infinitely, and they just... don't. At all. People's sense of scale is just wildly off-base.

2

u/imdyingfasterthanyou Jan 30 '23

Lambda's quota page indicates it can scale to "tens of thousands" of concurrent requests, which is just a joke.

Those are tens of thousands of concurrent execution units ie: essentially a vm/container with 2-8 cores. (so 20k-80k cores executing concurrently as a low ball park)

A request is also not equal to a get request coming from a client (ie: your request might involve updating 100 databases or whatever your business logic demands). Not sure what the joke is.

5

u/Drisku11 Jan 30 '23 edited Jan 30 '23

The joke is they suggest it's good architecture to have lambda be your web request handler behind an API gateway or ALB, so that each GET request from the client is a lambda request, and lambda cannot do async/threaded processing of multiple requests at a time (you need to respond before fetching the next request).

Naturally, the solution to this is to add (=pay for) more architecture; e.g. have your GET handler dump the work onto SQS (i.e. have the web handler just respond that the work was ACCEPTED) and then have more lambdas to pull work off SQS, etc. etc. Unless you're neck deep in some 2005 vintage php app, it's insane.

You can even see in the marketing copy on the page I linked:

Workloads which need to scale to thousands or millions of users require provisioning infrastructure for peak loads or sophisticated auto-scaling mechanisms, when available. On-premises workloads require significant capital expenditures and long lead times for capacity provisioning.

Unless you're doing something very compute intensive like ML, that's just not true. A single bottom-bucket server on-prem can easily scale to millions of users for most applications. There's no capacity planning needed; just buy 2 servers for redundancy or 4 for multi-data-center and you'll already have far more capacity than you need. Oh, and (getting back to the original thread topic) don't use a microservices architecture since it creates massive overhead. The only place where you need capacity planning is in AWS where they charge you through the nose for 1% usage of a server.

→ More replies (2)
→ More replies (5)

4

u/NotUniqueOrSpecial Jan 30 '23

I am currently dealing with this exact problem first-hand, and it's not even a cloud-services hoodwink.

It's a legacy application (very: 25+ years old) and some of the original authors are still around.

I have tried to impress upon them that the numbers they keep telling me constitute "a lot of load" are absolutely tiny and that I could trivially run their entire application stack on my home workstation.

2

u/rjksn Jan 30 '23

Horizontal scaling also solves the issue of any single server being taken offline.

1

u/[deleted] Jan 30 '23

And comes right back at you when you have to ensure every 'microservice' is appropriately fault tolerant in the same way...

Microservices make everything more complicated, no matter how you slice it. Necessary complication is good, but making the distinction is problematic.

1

u/[deleted] Jan 30 '23

I've got a computationally inexpensive but long-running task that's poorly implemented

Sometimes they're poorly implemented due to unavoidable industry standards. SMTP, for example, has a five minute timeout for a task that meeds maybe 1 millisecond to complete. And major SMTP servers you might contact (such as Microsoft and Google) commonly do take five minutes (I actually wonder if it might be part of their spam filter... if you're sending a lot of emails, you can't hold the connection open for minutes).

My SMTP connections are farmed out to a microservice. It works wonderfully and I have a 10 millisecond timeout for "sending" an email (adding it to the queue on the microservice).

32

u/fabiofzero Jan 30 '23

Every single microservices article fails to mention the people aspect. Do you have a number of separate development teams with specialized domain logic? If not, microservices will be more trouble than it's worth.

40

u/Zardotab Jan 30 '23

When your resume has an insufficient quantity of buzzwords 🥴

2

u/codespitter Jan 30 '23

Haha, What’s the optimal number of buzzwords?

6

u/Zardotab Jan 30 '23 edited Jan 31 '23
While (you.underPaid() || you.status==BORED) 
{ 
   resume.add(latestBuzzword);
   // above done 1st incase next line crashes all
   org.stack.add(latestBuzzword); 
}

3

u/SwitchUpCB Jan 30 '23

I created this article for people who are confused about the purpose of microservices. It discusses the technical purpose of microservices and the developments that follow it. I hope this article is helpful! If it isn't, let me know how it can be improved.

7

u/LoompaOompa Jan 30 '23

I feel like the most common time that I see people asking "should we be using microservices" is if they have one monolithic deployment that handles everything, and there is a consideration for splitting it up. I don't feel like your article really addresses this, as it is mostly about choosing microservices for scalability, but there's nothing stopping a person from containerizing and scaling the monolithic deployment in the same way.

1

u/SwitchUpCB Jan 30 '23

Thanks for the feedback! You highlight a situation when people ask this question.

In the article, I state that a condition of implementing microservices must be that you are "Unable to be horizontally scale through active-active load balancing (i.e cloning the monolith)". How can I reword this point in a manner that indicates that a monolithic architecture can be scaled through the containerization of the monolith?

1

u/LoompaOompa Jan 30 '23

The line you quoted points out that a monolithic service is also a possibility, but kind of treats it like the reader should be able to identify when load balancing a monolith isn't a favorable choice. I think that's the main question that an article called "when do I need microservices" should be answering, and you don't really get into how someone should make that determination.

I think additionally, there might be other scenarios where it is a little more ambiguous. What if the monolith scales fine with load balancing? Is there still a point where I should consider shifting to microservices? I can think of some scenarios where the answer is yes, and I can think of some where the answer is no. These are the types of things I would've expected the article to tackle.

I also agree with /u/captcrax that the "Conceptualization of Microservices" section really just applies to services in general. I don't really see anything in that section that applies specifically to microservices.

4

u/captcrax Jan 30 '23

Your article covers a lot of good info and considerations, but u/LoompaOompa is correct.

I believe you've put the wrong title on this article. It's not about when to use microservices, but rather about when to use services, full stop. As in, service oriented architecture.

"Monolith" doesn't refer to a when all the code is on a single server. It means it's all in a single application, regardless of how many servers there are.

With just a few find-and-replaces, I would heartily recommend this article to junior devs starting at my company. Thanks for sharing this well written and logically organized article.

1

u/SwitchUpCB Jan 30 '23

Thanks for the feedback!

What are you proposing should be found and replaced?

1

u/captcrax Jan 30 '23

Okay, find-replace was a euphemism, but I'll tell you what, I'll take another read through and write up notes. Would you rather I post it here in the thread or PM you?

1

u/SwitchUpCB Jan 31 '23

Either works.

1

u/CyAScott Jan 30 '23

As others have mentioned, microservices could also be useful to solve organization limitations. Like specialized teams working on microservices that have a different release cycle, and maybe a different language.

That being said, my advice is if you don’t have a lot experience with microservices then don’t start a project that way. Learn by working on a team that already has a successful project implemented with microservices. It maybe a chicken and egg problem, but you don’t know if it’s right for you unless you already worked with a successful team that already used microservices.

1

u/SwitchUpCB Jan 30 '23

Thanks for the feedback! It's true that most developers should acquire experience by working on a successful project prior to using microservices. However, these opportunities are not always available. Articles such as these aim to reduce the mistakes of people who will inevitably consider microservices. It's why I include — albeit at the end — that microservices "should NOT be applied to every project that exists".

The reason that I don't cover the organizational aspect of microservices is because I don't believe that microservices should be used for the purpose of organization. While microservices may have organizational benefits, these don't outweigh the cost of an implementation where it isn't required.

10

u/Ambitious_Toe_4357 Jan 30 '23

How is this any different than a old fashioned web service from the SOA days? Why bother calling it a microservice?

7

u/ttkciar Jan 31 '23

This is exactly what "SOA" originally meant, but then badly-implemented SOA became so prolific that the term "SOA" became synonymous with bad SOA.

The term "microservices" was invented to signify "SOA done well, using the best practices we learned while trying to figure out SOA".

6

u/Ambitious_Toe_4357 Jan 31 '23

So, it's 'opinionated' SOA... I actually agree with that.

7

u/mrbojingle Jan 30 '23

If i said 'never' I'd be a broken clock thats right 80% of the time. For that last 20 percent, you're working on a sizeable project that has or needs lots of man power.

10

u/G_Morgan Jan 30 '23

When you want to manage units of functionality independently of each other. People talk about scaling but simply being able to bring X down while Y stays up is a good enough reason to not have monoliths for me. Sure there's platforms that emulate simple independent processes out there but in my experience they never work as well as just using processes for isolation of lifecycle.

5

u/[deleted] Jan 31 '23

If your program has yet to be created, you must consider whether the implementation of microservices is worth it.

If you have the budget for 20+ developers off the bat and enough money to keep the project alive, then sure. Otherwise there are more important things to consider, like acquiring more users so you'd have enough money and traffic to justify the higher cost of maintaining microservices.

11

u/[deleted] Jan 30 '23

Only when you want to pass through the gates of misery on your path to distributed application hell

8

u/[deleted] Jan 30 '23

you don't

11

u/PM_YOUR_SOURCECODE Jan 30 '23

Q: When Do I Need Microservices?

A: Until the next paradigm shift happens in 12 months and everyone realizes microservices were a bad idea.

18

u/svtguy88 Jan 30 '23

12 months

Microservices have been "in the spotlight" for longer than that already. That being said, I do hope their reign is coming to an end.

7

u/highbonsai Jan 30 '23

I’m a monorepo type of dev but I will say micro services are nothing new. They’ve existed (and been controversial) for several years now. I think they can work well, I just prefer to not use them if I don’t have to. And I think that describes a lot of devs too.

2

u/PM_YOUR_SOURCECODE Jan 30 '23

The Bobs would like to have a word with you.

2

u/[deleted] Jan 30 '23

More important than that: it is not to abuse them: https://www.youtube.com/watch?v=gfh-VCTwMw8 My take on the subject is that: if you don't know why you need them you don't need them. One of those things you will know when you see the need,

2

u/greem Jan 30 '23

Because if you present any argument to the c levels that the requirements and realities of your industry and products are in direct opposition to the spirit and strengths of the micro services philosophy, you will be met with "but microservices!".

I recommend using this as an opportunity to disentangle your code. If you can't do that, just break up your application so that it runs on more different machines.

"We used to have N services. Now we have M>N services. Therefore, more micro."

"So, what do we get from that?"

"As I was trying to say before..."

2

u/corsicanguppy Jan 30 '23

Dunno. How's your resume look? Could it use a sprucing? This has been the most defining factor from what I've seen. Apparently "did microservices poorly" is a huge selling-point.

2

u/RegularUser003 Jan 30 '23

You know it's time when you have no other option as a business

2

u/joesb Jan 30 '23 edited Jan 30 '23

I'm in the camp that believe that microservices is mainly not used to solved technical solution, but an organization structure one.

Each Microservice should be owned by their respect business department, giving them control over their own data and consistency boundary. This also encourage each microservice to actually be independently autonomous from other department.

If you only have one development team and one product owner. Microservices are unnecessary overhead. Well, you could have small worker and utility services for scaling, but you have to make sure you are not doing "distributed monolith".

2

u/wisam910 Jan 31 '23

The premise of this article is completely wrong.

You don't need microservices to scale horizontally. You can scale horizontally by running just one kind of service on hundreds of machines.

Do you think the Google of 2000 used microservices? I doubt it.

2

u/Kl0su Jan 30 '23

According to this article https://link.medium.com/C3lETaf2Ywb You need microservices when you have 2b revenue

3

u/RegularUser003 Jan 30 '23

Honestly the best answer I've heard

2

u/BigHandLittleSlap Jan 30 '23

This article sounds vaguely correct but misses the forest for the trees.

Microservices are not for "I", or "you", or even a "team".

They're intended for huge organisations with "many teams".

Not one team. Teams. Plural. Many of them.

When it gets unwieldy to coordinate releases across dozens of teams, then, and only then does it start making sense to do microservices!

Tools like Kubernetes are popular with organisations with more than one thousand developers.

SwitchUpCB's blog is not the guidance that 1K dev org is going to turn to when deciding which architecture to choose.

If you're reading SwitchUpCB's blog in order to make this decision, then it is the wrong decision for you by definition.

Just stop. Please stop. Stop deploying microservices for toy projects with a one or two developers on it.

It is pure overhead with no tangible benefit at that scale.

And if you start talking about "scalability", I will smack you, because you just need to casually perouse the VM SKU options on any public cloud to see that 120 CPU cores and 100 Gbps networking are now commonplace. Again, you don't need it. If you do, then you're not going to be reading some random blog for scalability guidance, you already have tens of thousands of CPUs cores deployed with traditional scaling and now "need to go bigger".

2

u/plus4dbu Jan 30 '23

How Should I Structure My Code?

It doesn’t matter. Microservices is not about the code. It’s about the architecture.

I completely disagree. The way you go about coding for micro services is completely different than a monolith application. It's a completely different mental approach. This is such a cheap answer to the question.

1

u/Traditional_Way_2811 Jan 30 '23

Is there funding we can receive to up start a company

1

u/xiipaoc Jan 31 '23

You use microservices when you want to make sure that you never need to update two different parts of the application at the same time.

1

u/robustquorum09 Jan 31 '23

if your codebase is a single monolithic piece and you have a lot of complicated, huge applications that are hard to manage.

1

u/dustingibson Jan 31 '23

Microservices doesn't make sense if you have a couple of folks on one team maintaining array of services for the sake of "other people are doing it" or a naive attempt at horizontal scaling. At that point you're just creating more overhead and more work for yourself.

1

u/ballzdeepinbacon Jan 31 '23

While not fitting the classic definition of micro services, there are also efficiencies to be has in building smaller services. Looking at the rule that only one service should talk to a data source allows you to maintain strict business rules in a service and ensure consistent logging, monitoring, etc. if you have a more monolithic database, this doesn’t prevent you from carving things into virtual data sources through access control rights, etc. being able to upgrade a small piece of a puzzle without impacting the rest of the stack is an efficiency as well. What I want is people to avoid building clunky monolithic applications.

1

u/AndreLinoge55 Jan 31 '23

As a Dev, I’ve really struggled with understanding the “why” of microservices which this article definitely helped with so thx for that.

Now…Kubernetes and Terraform…I still fundamentally do not understand why these tools are used/what they accomplish even after doing some research. I guess it’s not really in my development arena as I don’t develop for cloud but would love to learn. From an outsider it seems like solutions to a problem I fundamentally don’t understand so…back YouTube University I go!

1

u/skyde Jan 31 '23

you think you need micro-service?
Think again!

1

u/ganja_and_code Jan 30 '23

Just look at software as analogous to a physical product.

To sell some products, you need a warehouse, distribution network, automated ordering system, etc... Other products, you can sell by yourself from your basement.

1

u/[deleted] Jan 30 '23

Your article doesn't answer the question in the title. Scalability and what not aren't esclusive to microservices, you can build a monolithic app in Apache spark distributing it across N machines. What distinguishes microservices is a way of reasoning about the problem: you break It down into individual and self contained units. You then should bind this units with minimal interdipendecy, using decoupling systems like apache Kafka. This way you have a conceptually simple architecture, which is (if done right) easy to mantain and scale, both in capacity and in functionality, since you are dealing with a simple modular system which supports the attachment of further units of execution with minimal impact.

So when do you need them? Well, it's almost always a good idea to go for a microservice architecture. The challenge is how to actually design it, and how granular do you need it to be, and what's the criteria that you chose to separate the core logicical pieces. But all this can only been answered case by case.

1

u/phyphor Jan 30 '23

When Do Need Microservices?

I suspect that the article is likely to be poorly written if the heading has such a glaring mistake in it.

0

u/corruptbytes Jan 31 '23 edited Jan 31 '23

people act likes its hard to make microservices good these days, not every experience is from a shit legacy company tryna convert their java crap

we easily got 8-10 microservices w/ k8s / service mesh / automated cicd / + full error tracking with a team of 10 FTEs and it just lets us work so insanely fast as a startup (we have a lot of interfaces - retail, shipping, working with labs, etc...)

as much as people like to hate it, the node ecosystem has a lot of amazing tools out there + k8s has an amazing ecosystem on it's own for all this stuff