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

→ More replies (2)

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.

→ More replies (1)
→ More replies (2)

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.

→ More replies (25)

5

u/corsicanguppy Jan 30 '23

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

→ More replies (2)

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.

→ More replies (2)

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?

→ More replies (7)
→ More replies (8)

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.

→ More replies (1)

8

u/Boolean Jan 30 '23

Hacker News is great for that IMO.

→ More replies (3)

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.

→ More replies (4)

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

→ More replies (1)

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.

→ More replies (1)

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)
→ More replies (6)

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.

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

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?

→ More replies (2)

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.

→ More replies (4)
→ More replies (1)

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.

→ More replies (1)

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.

→ More replies (4)

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.

→ More replies (1)

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.

6

u/Ma8e Jan 30 '23

But what clearly isn’t obvious to many developers is that using micro services doesn’t guarantee decoupling.

→ 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.

→ More replies (1)

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.

→ More replies (2)

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)
→ More replies (6)

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

→ More replies (2)

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.

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.

→ More replies (9)

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.

→ More replies (1)
→ More replies (1)
→ More replies (4)

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?

→ More replies (1)

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

-8

u/[deleted] Jan 30 '23

If you have written something that is reusable, want to make money by selling it to others but don't want to give them access to the source code or decompilable binaries and also charge them a monthly fee for it.