331 points · by winslett · 4y ago · 296 comments
There is an essay in the mythical man month about Conways law and microservices are very much about a way to use Conways law to achieve scale of development. You likely don't need microservice until you hit a scale where the monolith is a real pain point. You can probably cope with a monolith especially with some reasonable design effort up to the 100 developers maybe more with a lot of separation but at some point in the >25 developers range it becomes cheaper and easier to switch to multiple deployed units of software and deal with the increased system complexity and interface designs and the inherent versioning issues it causes.
It is easier to start with a monolith, find the right design and then split on the boundaries than it is to make the correct microservices to begin with.
It may be a solution, but there were already solutions for that. As far as I remember, the orignal argument of microservices was to allow different teams to use whatever languages/tools they choose, as long as they provided an API. As opposed to having IT, payroll, and sales all having to wait for one development team to make everything. Then with docker and containers it became that you could isolate deployments, and scale out just the parts that need it. Which is great if you need to minimize outages, and have some parts of your system that get major spikes in traffic, and you decide it's worth the extra complexity.
APIs.
I've deployed about 10 or micro-services for use cases where a simple API is required for my applications. Maybe it's literally querying a row in a table and returning the result in JSON format. Or maybe it's to generate a JWT to access Apple Maps.
Just craft it up in NodeJS, deploy to Lambda, and those little services haven't changed in years but they just keep cranking away.
We can have both monoliths and micro-services where appropriate.
While "microservice" obviously literally means a small service, when people talk about microservice architecture they're usually talking about building out applications that look like a single service to the end-user but in reality are a whole bunch of small services that talk to each other.
Just creating a small service that exposes a small piece of functionality is clearly the right thing to do in many cases, but that's not what the discussion about microservices architectures is really about.
I don't really agree. It's probably the most agreed upon benefit, but there are others. Fundamentally, microservices allow you to isolate state. I can take two services and split them up - and now I've split their state spaces. I can put a queue service between them and now I've sliced out the state of their communication.
This slicing up of state has a ton of benefits if done right.
1. Isolation of state is basically the key to having scalable concurrency. Watch the Whatsapp talk on Erlang and they say "Isolation, Isolation, Isolation".
2. Isolation of services is great for security. You can split up permissions across your services, limit their access in a more granular way, etc.
Those are pretty nice wins. They're achievable through discipline in a monolith (heavy use of module boundaries, heavy use of immutability - something most mainstream languages don't encourage) but a network boundary really forces these things and makes unintentional stateful coupling a lot more painful.
> It is easier to start with a monolith, find the right design and then split on the boundaries than it is to make the correct microservices to begin with.
I disagree. Starting with a bad set of microservices can be fixed by merging. Merging two codebases is trivial compared to splitting. Again, if I have isolation between the services, even if the slicing up was done badly, even if they're coupled, I can just remove the layer between them.
Splitting has to start from a place of coupling and then try to decouple - this is especially hard with languages that encourage encapsulated mutable state (most of them).
There is still coupling in microservices, it has just shifted to messaging, networking, and queuing. If you get any of those parts wrong, you have a worse mess to untangle with less mature debugging/logging tooling than a monolith enjoys, all the while likely dealing with eventual consistency (depending on the design). I'm not saying don't start with a microservice, but it likely wouldn't be the very first tool I would reach for when starting out if a monolith would do the job effectively. Most things will never be hyperscale and won't benefit from the increased concurrency. You can go a very long way with a "majestic monolith" and a bit of care.
Sure, in the sense that your service is "coupled" to a queue and if you don't abstract that away it's hard to change that queue implementation. But in the sense of two services you wrote being coupled, they aren't, in terms of shared state. That gets pulled out. There is no way for one service to mutate the memory of another - it has to send a message to it.
That can be TCP or it can be over some queue or stream or whatever.
> If you get any of those parts wrong, you have a worse mess to untangle with less mature debugging/logging tooling than a monolith enjoys
This is the case with any concurrent system. The fact that so many languages lack concurrency primitives is probably why people don't run into this more often. If you use concurrency primitives in your language, you already have this.
> all the while likely dealing with eventual consistency (depending on the design)
There's nothing eventually consistent about this system. It fundamentally has causal consistency (since messages from a service must come after messages to that service that triggered them), and it's perfectly capable of leveraging transactions.
> I'm not saying don't start with a microservice, but it likely wouldn't be the very first tool I would reach for when starting out if a monolith would do the job effectively.
To each their own. I much prefer it. It's far simpler to maintain "good" design since the network boundary creates a hard line in the sand that you physically can not violate.
Dr. Alan Kay would like a word. This is literally the premise behind OO:
> "OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things."—Dr. Alan Kay
Outside of "extreme late-binding," which is a fascinating topic in its own right, isolating state is exactly the point of OOP. If we need microservices to accomplish isolation of state, that suggests we got OOP wrong, very wrong.
> that suggests we got OOP wrong, very wrong.
Alan Kay very clearly states that people "got it wrong" and that OOP was supposed to be about messaging. ie: He intended for it to be one thing, but it isn't that thing.
> I'm sorry that I long ago coined the term "objects" for this topic because it gets many people to focus on the lesser idea. The big idea is "messaging"
> The key in making great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be. [..]
http://wiki.c2.com/?AlanKayOnMessaging
https://computinged.wordpress.com/2010/09/11/moti-asks-objec...
It does, but that's because there are different flavors of OOP. Alan Kay's original take on OO was closer to the actor model than what grew into the mainstream spin on OOP with inheritance and the rest.
If you take 10 steps back and squint, microservices & the actor model start to look pretty similar.
I don't think there's any question about that.
The only language that really seems to get this right is Erlang (and Elixir).
And I suppose Smalltalk, but I don't think even Smalltalk takes it as far as the Erlang VM.
They cause exactly 0 extra problems. A call from function A to function B can fail due to B having a bug. A call from service A to service B can fail due to B having a bug or a network failure. Either way, failure is possible and has to be handled - the network only makes that more obvious.
Further, a call between functions can cause mutated shared state - not the case across a boundary, they physically do not share mutable state.
> and you've just shifted the complexity to now securing the network
Not really. Fundamentally you have split your service capabilites up - now you can apply least privilege as you desire.
And the distributed, cross-service mutated state is a hell of a lot harder to trace and debug.
Joe Armstrong talks about this better than I'm going to: https://youtu.be/lKXe3HUG2l4?t=1438
That timestamp is rough, I just found a related section of the talk.
> And the network-defined state is a hell of a lot harder to trace and debug.
There's no such thing as network-defined state. I assume you're saying that it's harder to debug bugs that span systems, which is true, but not interesting since that's fundamental to concurrent systems and not to microservices.
I think it's not really state isolation: your state is now spread across multiple separate services and a queue, which is objectively more complicated. To me, it's more the extreme version of things like dunder methods in Python or opaque structs in C: it prevents a specific type of programmer behavior. But honestly, it feels easier to solve this in code review.
Like, I agree it's bad to reach behind the public API of something, but microservices aren't immune to this. I've never worked on a microservice architecture that didn't have weird APIs just to support specific use cases, or had a bunch of WONTFIX bugs because other services depended on the buggy behavior. That's not fundamentally different than "this super important program calls .__use_me_and_get_fired__": you have an external program dictating the behavior and architecture of your own.
And you get multiple other layers of complexity here: networks, distributed transactions, separate dependency graphs, securing inter-server communications, auth/auth.
I don't think you're entirely wrong--there's a lot of history looking at state as a series of immutable updates (Git, Redux), and I think it is harder to "cheat" in this way using microservices. I just think it's far from a clear win.
You can have logical dependencies between those "isolated" states anyway so I don't see that as a benefit really compared to say Java OOP private fields.
I see two common sources of state in any backend (monolithic or not):
1) Caching, whether resources or flags, whitelists
2) Connection pools.
If there are ever any issues with those they can be segmented inside a monolith for a fraction of the cost of going to microservices (either using the same boundaries as if you had split into microservices -- or other boundaries, like just one set of caches/connection pools per endpoint handler..)
So I agree with the OP that the social aspect and development process is the only rational for microservices.
Otherwise, just scale the monolith horizontally to the same number of instances and you have strictly more ways to partition state; microservices only give you one way to partition state that may not even be the best one.
If you can scale up your number of workers for a particular emergency then things get easier to handle.
Good luck changing your design or making end-to-end features when you have teams protecting "their" part of the software.
You've just made sure that any significant change to the system requires coordinating many different teams, making it at least one order more difficult than before, and a lot more bureaucratic.
And, I get it. Selfishly I would love to come onto a project and only have to worry about net-new development. It is hard to learn, and then positively contribute within another engineered system... of any complexity. When it's "my code" I tend to be much more productive, and it's easier to find my way through the forest.
Anymore, everyone is on a power-grab for "my tools" and "my way" in regards to everything they're working on with near-zero attempt to understand the base needs of the business/feature. Microservices fill this need well as devs can work with their preferred toolset and just setup I/O boundaries for everyone else to use their service. Also, this is good for resume-driven development as you can often claim creation/ownership over some "piece" which looks way better on paper vs. "contributed to a big 'ol project."
I'm not against microservices, I'm just being honest with how I've seen them socially play out - all of this is anecdotal to my experiences.
Fiefdoms, whether implicit or explicit, are pervasive in organizations beyond trivial size; IME, software architecture choices may impact the shape of the fiefdoms, but not their existence.
It seems to me that people are simply terrible at modularizing code. (Including me.) I've seen this problem far more often than not, in every organization I've worked with, for my entire career.
Just the other day I worked on a function that did some Windows API calls for file I/O, allocated a bunch of memory, and processed the file contents. I split it up so the code that needed the Windows API did just that - it didn't allocate any memory, and the processing was done with a callback.
That meant the Windows API accessing code didn't need to import anything from the rest of the program, and the rest didn't need to import the Windows API.
(There are some success stories. The popularization of generic algorithms and ranges (or iterators) has been a big improvement. And the use of global variables has become frowned upon.)
Once you realize you needed it, its too late.
Then once you've been burnt on that fire for a bit, you go all out in designing the next few projects with framework and forethought and wind up with 100 lines of that for a 10 line script.
the moral is "life's a bitch"
Otherwise we get stuck in "modularization bad" or "modularization good" mindsets, where both are wrong.
Well, in my experience it makes _some_ people more thoughtful about those things.
Instagram - monolith
StackOverflow - monolith (at least until SO Enterprise)
There are many others.
There is a reason why we avoided "distributed systems" in the past. It's insanely hard. Microsevices solve some problems in theory but create actual problems in practice.
For most companies out there, distributed systems solve problems the companies don't even have. But, boy, do they need 10x more engineers to maintain this all.
Now guess the size of the code wrangler team. And as this was so super-extravagant, guess the number of developers who were "promoted" to work on those micro-services.
> But, boy, do they need 10x more engineers to maintain this all.
Well stupidity saves you here. Ignore the one team per microservice rule and swap it with the "one-size-fits-it-all" developer rule: just promote one of the single team to be responsible for all micro-services. One lunatic that pushes code fast enough that management does not realize what is going on. Once everything is up and running, it just runs. The rest is downtime eventually, but you know what, its a software problem, what could be done? As long as everyone involved looks busy - and it's easy with plenty of micro-services to play whack-a-mole, bring one up again, kill two others, it is just a fail in the design as they should have been designed with failover but that was missed!
Microservices don't fix this. If I'm working on a feature in a monolith and I need to modify code someone else is also working on for some other feature that same situation would occur in a microservices based app. Just because the code is in a different git repo, and called with via an RPC doesn't change the fact that you need to change it.
Most software is monolithic, and most critical software is millions lines of code that hundreds or thousands of people have worked on - all without using microservices.
Hmm? You can do that simply with API boundaries inside a program. Linux kernel has huge development team that compiles a all binary.
In the monorepo world, your whole system is broken, it is all hands on board to try to fix this, everyone is stressed out.
In the microservice world, you have only one microservice which went down, so most teams don't have to worry.. in the worst case, they'll say: "Sorry, but we depend on service X and they are down.. blame them, nothing we can do". Sure, that team which introduced the bug is stressed, but the average company stress is much lower.
Having a successful monorepo requires organized, cohesive team with good communications -- or at least a team with a highly experienced people with veto power (this is the Linux kernel model). Unfortunately, a lot of real-life businesses do not have it.
My experience has been that one service going down (or even running slowly) can lead to cascading failures where identifying the root cause is a slow painful process. I know that in a well designed system that doesn't happen, but that's the nature of all bugs, isn't it?
No, not at all. And the kernel is a single repo even.
> In the microservice world, you have only one microservice which went down, so most teams don't have to worry.... blame them, nothing we can do
Well how is that better than just switching the dependency back to last known version and ship instead being dependent on a whole different team just to get dependencies fixed _and_ running.
> Unfortunately, a lot of real-life businesses do not have it.
That may be true, however benefit of those properties are in different kind of development projects, and this is not the question of whether monolith or microservices IMHO. Also not mono repo or non-source binary distribution.
If anything, there is MORE communication.
And how many teams who do distributed systems really know what will happen if a critical service goes down? The system is down - same effect.
Most orgs do not have these things - especially not at the level of the Linux team. Also the motives of OSS are completely different than that of your typical business - I personally think this keeps OSS team coherent/productive for far longer than your typical corp can.
I can't tell you about Okta, but there used to be a (now apparently gone) article by Nelson Elhague about their test parallelization infrastructure. Many thousands of pretty slow test ran for every Jenkins build, massively parallelized across machines to get an acceptable response time. At the time he wrote this, there was no modularization to speak of, so every test really had to run for every build. Very expensive, but there's a lot of value on getting the equivalent of integration-level tests for almost every critical system automatically.
As a monorepo grows, the technologies used have to change to make its disadvantages spiral out of control: Serious modularization of codebases, something like Bazel to make sure code isn't overbuilt, and a testing strategy that finds the right balance of finding problems and keeping expenses in control. Every company with a monorepo ends up walking that road, but the good part is that by the time you have a problem, you definitely have proof that your organization is in a situation where the problem is worth solving.
This is very different from, say, what I saw at a company that had Fred George as CTO, and was going all in on microservices with one customer and about a dozen engineers, all of which wrote in the same JVM language. At that point, all the work that avoids running too many tests is probably going to be a net loss, and even more so when one considers opportunity costs.
Sounds pretty reasonable.
I'm not sure that's right.
Did they _have_ to? They could have run tests for affected transitive dependencies, cached build artefacts, randomly sampled integration tests on master. There's plenty they could have done to reduce the bill.
Microservices were also presented as a solution for encapsulation. But if you cannot write good encapsulated code in a monolith, what makes you think microservices are the answer? http://www.codingthearchitecture.com/2014/07/06/distributed_...
Microservices (or just services) are the solution of having more bandwidth for a set of features without having to more of everything else and preventing some part of the code to influence negatively some others.
This reminds me of the discussion on let pedestrians define the walkways[0] [1]
"As time goes on, we get smarter. We learn more about ourselves or our customers — what we or they really want. Therefore, we’re at our dumbest at the beginning, and at our smartest at the end. So when should you make decisions? When you have the most information, when you’re at your smartest: as late as possible."
[0] https://sive.rs/walkways [1] https://www.theguardian.com/cities/2018/oct/05/desire-paths-...
* six months pass by * - why isn't it done yet? -- we had to onboard and train all those new hires which sucked up a lot of dev time plus the new architecture added complexity and increased communication costs - How can we make our onboarding process faster?
* sigh and the cycles repeats it self
There might be some other cases where you have hard business requirements and such for some software to be able to ship without other software and need to build clean lines and services so features can be extracted and probably some other edge cases, but the larger point should be that extracting the service should almost be demanded, both technologically and organizationally. If you have a choice and it isn't clear, then a service is probably the wrong thing. Services also really shouldn't be "micro" until you're an absolutely huge company and you can burn entire teams on small edge cases.
I’m not sure that that’s entirely true. To be sure that’s an aspect, but it’s also conceptually quite reasonable to desire the best tool for a particular job rather than employ a kitchen sink for everything. Separation of concerns is a commonly admired quality in code, and it makes sense sometimes to have this separation be at the repo level.
I don’t jive with the “only organizational not technical” characterizations this thread is rife with. It’s now hipster to say the cool shiny thing is lame, and it blinds some utility.
> It is easier to start with a monolith, find the right design and then split on the boundaries than it is to make the correct microservices to begin with.
This I definitely agree with in many, perhaps most, cases. But of course inertia, especially in organizations, could have future you lamenting such a decision you now have no easy way out of.
In other words, it's a great way to ship your org chart.
I've only ever seen a handful of examples where the microservice boundaries were set regardless on how the actual teams are organized in the reporting structure.
Otherwise, microservices just turn what was once easy into very complicated.
Microservices was always a solution to the problem that SOA got swallowed by “implementing XML heavy standards” and lost attention to it's architectural principles.
(SOA was originally, and microservices a return to, a solution to reusing components and isolating faults so you need fewer, not more, developers and support personnel dedicated to any given system or collection of systems.)
Not pleasant, but true.
Wasn't Continuous Integration (CI servers) created long ago to solve that?
Where developers can test and release their own changes, incrementally, without stepping on each other toes?
What is next?
Microservices forces boundaries, which in turn allows you to scale the number of teams to the number of service boundaries and now you're no longer stepping on each other.
With the disclaimer that I'm an embedded programmer so I don't have a dog in this fight, my reading of the literature suggests it's best seen as an organizational tool rather than a performance tool.
That certainly does help with avoiding conflicts. There are only so many conflicts that you can pick up in a few hours of work.
- a mono repository
- a single codebase for a single system
- your micro services are supervisors and gen servers (and a few other processes) in a supervision tree
- you decide which erlang node run which apps
- your monolith can scale easily thanks to libcluster and horde
- ...
Also, there is the midpoint between monolith and micro service, and this is called Service Oriented Architecture (SOA), you could have: - a DAL (Data Abstraction Layer) service
- a Business Logic service (talking to the DAL)
- an API (talking to the Business Logic service)
- a Frontend (talking to the API)
Your API (or gateway, or whatever you want to call it) can serve as glue for third-party services (like Stripe, or anything unrelated to your business).Microservices are a solution for an organizational problem, not a tech one. You need multiple teams to work on the same system without blocking each others. This is a solution for huge corporations, not your 2 pizzas team startup.
If you're using K8s, what I would suggest is:
- create multiple releases of your Mix project[1] with specific OTP applications in each
- one Docker container per release
- one K8s Deployment per release
- one headless K8s Service selecting the pods for all your deployments
- use libcluster for automated cluster formation
Then, with node affinity/tolerations, you can control on which physical node you'll run it (if you want).If you're not using K8s, you can use an Ansible playbook to deploy each distinct release on the target host, and you can use libcluster with a static cluster configuration. This will work the same.
[0] - https://medium.com/@david-delassus/elixir-and-kubernetes-a-l...
[1] - https://elixir-lang.org/getting-started/mix-otp/config-and-r...
I asked the more senior Elixir devs if we should do something to take advantage of the platform and was met with shrugs.
- a DAL (Data Abstraction Layer) service
- a Business Logic service (talking to the DAL)
- an API (talking to the Business Logic service)
- a Frontend (talking to the API)"
For me what you describled is just a common monolith.I've been developing for 8+ years and have seen this model at every company where I've worked. I really thought this was just the "standard" way that everybody used to develop. I've also worked on a couple of CQRS architectures but the "layering" is still very similar to what you described.
I'm curious now, how do other monolith architectures look like if not like this?
Nobody said a monolith can't be split in modules :)
IMHO, a well-written monolith is like a microservice architecture but without the network layer in between boundaries.
Literally add one character to one of my liveview modules:
Rebuilding...
Compiling 67 files (.ex)* "In vim I can do this in 3 keystrokes, in emacs it takes 5!" (where "this" is some vim-idiomatic thing you'd never do in emacs).
* "Ruby leads to bad programs, I have inherited a legacy ruby codebase and you wouldn't believe what they did..." / "Python leads to bad programs, I have inherited a legacy python codebase and you wouldn't believe what they did..."
* My team took a python/ruby app and rewrote it ruby/python, and now it's 99% faster and our productivity is way higher!
What I'm hinting at is this: You can write a bad or good microservice or monolith. The rules are different. You'll have different frustrations and tradeoffs. You'll have to play to the architecture's strengths and avoid it's weaknesses. You'll NEED institutional standards to keep people from doing the wrong thing for the architecture model and making a mess.
But mostly I see comparisons with Ruby/Python versus compiled/more mature languages like Java/C#. It generally doesn't make sense to contemplate a rewrite unless you're moving to something significantly different, and Ruby and Python aren't really too dissimilar.
Last time I asked our ops guy to define microservices for me, he couldn't - instead he told me to read a 400 page book by some popular microservices preacher (who of course makes a lot of money by consulting for companies looking to use or currently using microservices ;))
If you cannot explain the general concepts to me, maybe you do not know what it is, and I think that is a big part of the problem.
Today I don't know wtf it means. I guess it depends upon who you ask.
Until then you're going to have these things forced on you by your local Architect, forced on you by running a bunch of separate processes on separate containers with DNS as the cluster's service-lookup framework.
It's easy to get to a point where you have a big ball of mud of 100 micro-services where each new features touches 20 of them, and just hack in whatever new APIs everywhere that's needed to push a new feature out (but probably buggy due to async state and race conditions that noone was trained enough to figure out up front).
All that is pretty equivalent to what you talk about with monoliths.
Developers are their own worst enemy. They love shiny buzzwords and using unnecessary tools and concepts just to say they did. Conceptually you can't blame architecture patterns, that makes no sense. Blame those who choose to adopt patterns for the wrong reasons.
Microservices are not needed for scaling an org .
But even fighting for RDMS in 2022 is getting daunting as so many people will immediately start pushing for document DB's, GraphQL, etc. Seriously - I feel like SWE's have no idea the powerhouse a modest MySQL/Postgres instance can crank out while perfectly maintaining their data (ACID, replication, etc).
Everyone wants to use tools that were designed for FAANG scale regardless of org size. Anecdotally I've fought this hard because it's almost always at incredible detriment to the business's needs.
I find that modern devs balk at "single RDMS database + stateless middle tier" but only for selfish reasons like resume-driven development. This pattern is really burning me out more than anything else of my career.
Again, all this is personal anecdotes.
So they'll see some numbers that are on the upper end or beyond what they're used to seeing, and to them that's big scale. How do you solve that? Well, you reach for the tools other people have used when they have "big scale". All the literature says you can't just increase your instance size when you have big scale, so why would you try that?
And yes, that's wrong. But it drives a lot of the mentality.
Seriously, you can launch a server that has almost a terabyte of RAM! Is your business doing enough to make that database even blink? "My sources say no".
Im not saying you have to use nosql or whatever, but some sort of small future proofing (eg introducing different schemas/permissions for your different data domains inside your monolith) can help make future database seperation much easier.
If you're doing a B2B app its a different story, much harder to hit the limits of a big RDS instance.
The real answer, as in most software engineering is "it depends"
And then begins the dance of balancing what we currently need (we have maybe 100K DAU and launched recently) and what we predict we might need if things go right. So you don't need to go full on K8S with some crazy sharded database and 50 microservices on day 1, but you also don't want a PHP/MySQL monolith if you're building something that works like, say, Twitter, because you'll have to scrap ALL of that under huge pressure if things start to take off.
The way that you're encouraged to architect your code makes it really easy to separate a specific piece(s) if you need to. The functional, no-side-effects approach combined with Elixir's ability to easily communicate between nodes means that if I need to separate a particular set of functionality to certain servers...it's just moving things around.
If I take a function call_me(arg1, arg2) and it returns a result without side effects, it's no different for me to say call_me(node, arg1, arg2) because it's still going to give me the same result just from a different server.
This flexibility means that I can comfortably built a monolith and not have to worry about having to untangle it later if I need to. I love it. It gives me long term peace of mind with short term productivity.
I understand that microservices often become necessary in organizations when they are constitutionally incapable of addressing the root issues directly. But we shouldn't normalize introducing microservices so that we can ignore poor architecture and process, which underlies the majority of cases I see.
SoA is superior when you have large numbers of devs coordinating and working on the same product. For smaller teams monoliths seem to be the way to go.
I think if you can't do that in a codebase, then one has bigger organizational problems than the technology itself.
Also assigning many developers to work on the same set of files is a recipe for disaster (if said developers cannot get along or organize themselves) while working on the very same place/file.
Monolith is still better in my view, despite having experienced that.
The key IMO is to have a clear and singular vision and how all the different parts need to fit into it. If you let each little clump of people do their own thing, then you will have chaos.
It was an egregious Spring/Struts1 app, and it was a breeze to develop on. Fixed my first bug on day 2 of the job. With microservices, would have taken me 3 months.
Probably not, that's really the point :)
Although I think the limit is significantly higher today. Monorepo tooling is orders of magnitude better than 10 years ago.
I read about Bazel, which looked really nice. Any other interesting tools to check out?
You don't get to that LOC count without huge teams and decades of time. Any project of that timeline/complexity/size should constantly be having functionality split off so that organizational units can be better groked/understood. To put it a different way, when projects hit this sorta size I have experienced them naturally shedding off functionality that makes sense to be external in a service-based development strategy.
These are the situations where it 100% makes sense for microservice architecture as you've hit the social/technical complexities where breaking things into organizational units makes sense.
You are describing the consequences of poor architecture and process, not anything intrinsic to software projects.
Right, and our empirical observations over these topics are different.
I just read your profile and frankly the projects/industries that we are involved in are very different, only confirmed by throwing "C++" out there - the closest I get to that is some hobbyist C development.
I apologize for agreeing with parent comment's generalization at 100k LOC being a "mega-monolith", along with what I added with team sizes/decades for timelines. Empirically and anecdotally this is what I personally have observed, specifically in regulated fields ie: banking, payments, and education. This is a perfect example as-to what happens when I don't include the word "anecdotal" in my HN comments...
Developers from different industry niches have very different ideals in regards to what a "monolith" is, or what a "two-pizza" team is capable of over time. I find your "wait what?" comment to be a bit dismissive, only to end your comment directly telling me what I am describing which clearly implies I don't know what I'm talking about.
We likely just have different experiences with project complexities, sizes, teams, etc. Sorry if this comes off as aggressive.
Huge teams and decades of time gets you to 1M+ range, not the 100K+ range.
I feel weird defending myself but... yeah. This is actually my experience.
I get that teams at FAANGs/startups can typically move faster but for your run-of-the-mill corporate America development teams people do not move that fast.
Personally, I have only moved that fast at startups which is why I typically find myself at them.
Again, this is anecdotal to my personal experience.
I think that the one major disadvantage of having a big monorepo, is that with those multiple entry points, you might end up with a bunch of unused dependencies. But even that is manageable I think: you can have different package dependencies definitions whilst using the same codebase.
I've always worked with small teams (max up to 5 or 6 developers) and that's another point in favor of monorepos. I understand that big companies might want to have different teams working on different repos, for organisation reasons.
NextJS, for example, doesn’t let you manage service lifecycle methods (unless you write a custom server - which they explicitly warn you against). NextJS wants to be special, that’s dumb and it sucks (well, in the context of using it to drive your SaaS platform, it’s pretty smart).
Remix, for example, wants to control your client/server API calls, so you’re hard pressed to use other tools like GraphQL, and incur the risk for growing into microservices if you need it. Same story as NextJS about being special and probably driving SaaS platform sales.
Amazon just makes you manage an alphabet soup worth of products, which are all pretty expensive - unless you want to just lambda it… meaning custom runtimes and … back to microservices.
Point: microservices aren’t just driven by your org anymore, they’re pushed by vendors.
Are there specific lifecycle methods you want to tap into with Next.js? Open to feedback there. The reason the "custom server" is not recommended (it's poorly named, I'd argue it's an "ejected server") is because the main use cases folks were ejecting for have since been merged into Next.js core (like internationalization).
The docs for Custom Servers [0] begin with a bunch of language and warnings strongly encouraging you to forego this route. The consequence? I don't know – it feels like it's not maintained, and maybe won't be there between major versions.
If I want to use some function, I often just import it and call it directly, instead of calling one serverless function from another over http. That means the function gets bundled into a few lambdas, but so far, I've had no issues with that. The monolith abstraction hasn't really leaked for me.
Running NextJS as a handful of lambdas is fine, but you still likely need to initialize other services in the background (like databases)... otherwise you have a monolithic front-end... as in: "my monolithic front end talks to my monolithic back end, so I really have two micro/macro services", and maybe I should investigate breaking the FE/BE down into smaller components".
sure, you can use pgbouncer, etc. but it becomes sorta cost prohibitive to run a few apps.How you make the database connection work with serverless connection requirements seems like a minor issue. I haven't used it but it seems like next + prisma (+ tailwind lol) is the default stack of tutorial writers these days.
Skip Next and go straight for Express. NextJS does nothing useful that you can't easily do yourself, and only makes life difficult down the road.
> they’re pushed by vendors
yes, Apollo with GraphQL, Vercel, etc. It's a huge cottage industry. But this is how IT has always worked. Just look at some of the garbage Oracle and IBM have been pushing since the '80s. If your org is falling for a slick sales pitch or the latest Google cargo cult, then that's on them. If you're in IT, then it's your responsibility to educate the execs on what they actually need. If they would rather listen to the sales guy over at Oracle than you (often likely), then it's time to move on.
But suggesting that you can use express instead of Next, to me, is a clear indication you have absolutely no idea what Next is.
But Next.js is also just a well-built framework that won some hearts and minds because it's ...a good framework, not because of some extremely slick salespeople.
And if being a technical contrarian is interesting, you can always use it with one of Vercel's biggest competitors: https://www.netlify.com/with/nextjs/
I.e. Remix doesn't have a good story for off-boarding from a monolith – so it's inherently risky to build on top of.
GraphQL really isn't that hard, and if I'm going to build an API anyway, why not just start with a piece that's going to eliminate the endless refactoring of data-stitching when the needs of my pages (or underlying components) change?
Highest scoring one (2018): https://news.ycombinator.com/item?id=17499137
We went through a hiring surge a year or so ago and I was astounded how many candidates had never used any cloud, GitHub, containers, micro services, modern tooling or language versions, etc. These are all things I assumed everyone had been using for several years now. Or if not, they'd already tried it and decided to move elsewhere. It was eye opening.
On their on premises monolith skills will come in handy with the bleeding edge companies in a few years.
Then one of the "questions" in the Q&A was a pretty aggressive attack based on how unproductive the skeptics company had been to date and how they were on the verge of failing.
The speaker asked how many development teams they had and what was the size of their DevOps/Tooling team(s). When the skeptic admitted they only had a few developers, the speaker recommended they IMMEDIATELY pivot to Django/Rails/Node.js/.Net; "whatever you are most comfortable with". And then said "Why are you still standing there? You need to pivot tomorrow morning."
I think of those two questions every time I read or consider microservices. "How many teams. How big is your DevOps/Tooling team."
When figuring out what to spin-off as a microservice, we do this by functionality. Why not just make it easier in the monolith and organize by functionality instead? Let's act like 4yr olds, not 3yr olds: https://pubmed.ncbi.nlm.nih.gov/12090481/
I can't imagine having different build products and deployment stories for every service type, nor can I imagine institutionalized version skew of more than a couple of weeks.
This probably doesn't scale to large teams, but it let a small team work pretty effectively with thousands of microservices.
Doesn't really seem fair. On the one hand you might need to do a bit of work so that you can say `docker-compose up` or `nomad up` or whatever, but at the same time there are plenty of issues with running binaries/databases directly on a laptop - version skew, for instance.
> So long for understanding our systems
This is fundamental to all asynchronous systems. You don't have backtraces anymore. If your service has concurrency primitives you probably already have to solve this problem with tracing, microservices just give you another asynchronous primitive.
> If we can’t debug them, maybe we can test them
Bringing up your entire application is what you'd have to do in a monolith as well, I don't understand this criticism. Also, "teaching" your CI to do this is 0 additional work - it's gonna be another "docker-compose up" or whatever, generally speaking.
Our microservice codebase runs on laptops just as it runs in the cloud. It's pretty nice.
With regards to "That is probably a bit too much effort so we’re just going to test each piece in isolation" - again, this is the same thing with your monolith. You'll just do this at the module level.
This is really a "right tool for the job" situation. And that's hard for people to understand, since oftentimes you don't know what you're building upfront.
It's not all bad. In my 8 years in the industry there has been an incredible shift in what a single person and/or small teams are capable of versus the status quo at the time. It comes at what I can only describe as a Schrodinger Cost - i.e a cost that is sometimes worth it and sometimes not.
The core idea is that services communicating via an API that have self-contained infrastructure is easier in a large organization, easier to scale, and allows you to make the right technical decisions for the problem.
And since you have no clear definition of why and what outcomes you expect, you also get massive scope creep in the middle of all this. Then you run into all the things no one planned for because there was no plan like how do we serve business functions like BI from our 30 new micro-service databases.
but you can't. Once you go RPC you hit the CAP theorem and need to deal with the reality of running a distributed system. Erlang is the only mainstream-ish production ready language I know of that attempts to solve this. And it is still very much caveat emptor. This is also where you might also bring up nondeterministic latency characteristics.
I'm currently building a backend in which will need real time capabilities and also standard restful http services.
Separating the real time service which will need a significant amount of performance more than the restful services will help me better scale.
Furthermore, the entire backend is written in python, because that is what I'm currently capable of at the moment, but in the future, migrating the real time service to Go will be heavily favorable - by separating it into its own service allows for that rewrite to happen at ease.
Now, there are many cases where building microservices are an overkill, but this isn't a one size fits all approach as the author would suggest, and I think we should all be tired of hearing a this or that type of article.
Such a "monolith" need not be the only one in the company. One per high level module or team works well.
I guess my point is, it doesn't have to be either giant monolith or tiny micro services in separate repos. There's everything in between as well.
I feel more inefficiencies were caused by forcing a microservice solution to every problem; than by big monoliths.
Some services need it, like a backend intake platform of some sort that needs to have radically different performance characteristics than a user facing frontend. But for most services it just does not make a lot of sense to do this.
We've found that "moduliths" (modular monoliths split into clearly defined bounded contexts with public APIs) work as well as microservices for scaling development: each team is responsible for their own module, there are very few conflicts, there's no spaghetti because we have architectural reviews whenever a module wishes to cross the "module barrier" and call into another module etc. (i.e. introducing a new dependency). You can spin up as many modulith instances as you wish as well.
The problem is that our modulith is written in PHP using a very popular enterprisey framework. PHP is based on the paradigm of spinning up a new process per request (php-fpm can recycle them but still), so every request ends up reinitializing the whole framework every time: its entire dependency injection tree. Every new module increases response times linearly, it doesn't scale. Another issue is that the single DB (common for monoliths) becomes the bottleneck, as all modules/contexts go through it.
Our PHP modulith is very costly in terms of runtime. A similar request into a microservice is usually 20-50 times faster because it's written in Go and manages its own DB. I think if our monolith was written in Go or Java from the very beginning we would have less impressive results after switching to microservices. Stuff rewritten from scratch is also usually faster than tons of old accumulated cruft.
Deployment/compilation is much faster now, the old monolith also used to have a lot of JS/CSS processing, PHP linters during build etc. so a tiny change to a module would trigger full recompilation of all modules running for 30-40 minutes. Each microservice is a separate deployment however, so a change to it only takes 1-2 minutes to deploy/release.
My point is that when people are talking about monoliths vs microservices they are often comparing dinosaurs written 10-15 years ago (PHP, old frameworks with bad design decisions, tons of accumulated spaghetti) to modern, more lightweight languages/tooling (for example, Go, k8s etc)
I think a "modern modulith" has its right to exist and is a viable competitor to microservices, provided they use more lightweight frameworks/tools, use paradigms such as modules and CQRS, and if somehow they allow smart, incremental deployments.
If you asked my boss, we're using microservices. But really we're just taking common tasks and breaking them out to their own service. Now that's kinda like microservices, and it is very handy ... but it is not the full definition that I know of.
Micro service or monolith? Hmm, I’d like F1 car or tank. If it fucking matters, you know which one you need.
Give Me Back My Monolith - https://news.ycombinator.com/item?id=19382765 - March 2019 (411 comments)
After that, the amount of cpu (i.e. dollars) and wall time wasted on encode-decode.
Anyone who does a microservice migration is not accounting for the above two costs.
Not to mention the additional complexity – now every "service" needs an LB.
You've converted a simple 1 person job into multiple days for many people.
microservices are a scam.
Generally, when people discuss going back to the “monolith” they just haven’t found the right distributed architecture.
As someone who has spent the last 3 years of their life maintaining and scaling one this is madness.
Microservices on AWS with lambda+dynamo+auroa+api-gateway work very well. There's built in transparency. There is logging. You can set everything up with terraform.
Terraform makes the setup trivial. Compared to monoliths that I've seen that involve a lot of brittle manual steps, it's not even a competition. AWS Lambda with xray and other logging tools makes tracking down errors trivial. I have yet to see a monolith with anything comparable.
"Oh but I get a stack trace in my monolith" is false advertisement. How useful is that stack trace when the stack is corrupted? Or when memory is corrupted because one line in another part of the monolith has an error that slowly screwed up some datastructure in another part of the monolith? I'll take Lambdas that are all short, totally isolated, and easy to understand, any day. Debugging and understanding is much harder with a monolith.
And yes. To test, you need to bring up the entire working application. Just like you need to bring up the monolith. Oh? You mean, most people who test monolith don't bring them up, they just test some mocked version of some module in isolation? Well, they're probably testing the testing framework itself more than the monolith. With localstack you can bring up the entire AWS setup locally, automatically, run component and end to end tests. It's far more testable than a monolith. And far more obvious when an interaction is not tested.
Monoliths are dead. Stop writing them. And start learning modern tooling.
What you bring up here is a discussion of execution environments for your code -- similar to a discussion of the best OS or programming language -- not whether the code is monolith or micro-service.
50 Amazon Lambda functions that all use the same database / data stores and understands the same data directly without going through APIs is definitely a monolith in my book.
PS: If you first allow for the possibility of a completely odd event like a corrupted stack trace (what are you programming in, pure C?) then to be fair I think you have to allow for the possibility of a bug in Lambda leaking state across invocations too.