Live data from Hacker News

Monolith First (2015)

martinfowler.com

201–210 of 356 posts

Re: Monolith First (2015)

#201

Earlier quoted context omitted.

You can still build a "monolith" but in a very modular way. Can't scale independently like microservices, but what if you don't need scale! Compile times are higher but what if you don't need to compile that much code! One error can bring down all "monolith services" but what if your app is not that big! I'd wager, something like 90% of software projects in companies can just get by with monoliths. You know...there a…

Never really got this "One error can bring down all "monolith services"". Can you share one example where an error couldn't be handled gracefully in a monolith? Say if my shipping service fails for some reason, I can still fallback to a default cost in a monolith.

Agreed. I've found propogating an error across multiple services to be a much harder problem than handling it with return values/exceptions in a monolith.

Re: Monolith First (2015)

#202
post #71

Hahaha. I have been saying the same for years but have either been punished by my managers or mercilessly downvoted on HN. Somehow mentioning that microservices might not be perfect solution in every case triggers a lot of people. I have actually helped save at least one project in a huge bank which got rolled from 140 services into one. The team got also scaled down to third of its size but was able to work on this…

> There are actually ways to manage huge monolithic application that don't require each team to have their own repository, ci/cd, binary, etc. Would be interested to hear about some of these.

Well for starters, each component's API can be published and versioned separately from its implementation.

The build of a component would only have access to the API's of the other components (and this can include not having knowledge of the container it runs in).

The implementation can then change rapidly, with the API that the other teams develop against moving more slowly.

Even so, code reviews can be critical. The things to look out for (and block if possible) are hidden or poorly defined parameters like database connections/transactions, thread local storage and general bag parameters.

In some languages dependency injection should be useful here. Unfortunately DI tools like Spring can actually expose the internals of components, introduce container based hidden parameters and usually end up being a versioned dependency of every component.

Re: Monolith First (2015)

#203
But how monolithic were our monoliths anyway? Take your bog-standard ecommerce solution, built with a LAMP stack.

Okay, we've got a php process. Let's put our business logic there.

Okay, I need a database. With current cloud practices, that's probably going to be deployed in a different machine. We've got our business logic service and our datastore separated by a network bound from the get go.

Okay this is not very performant, I need to cache some data. Let's add a redis instance in our cloud provider. I guess this we'll be our cache service.

Okay we need to do full-text search, let's add an elasticsearch cluster through our cloud provider.

Okay I need to store users. We can built that into our business logic core, of course, but screw that. We are using Auth0. I guess our "user service" is distributed now. Okay, my php process can't keep up with all this requests, let's scale this horizontally by deploying multiple php processes behind a load balancer!

Okay, now I need to do some batch processing after hours. I could add a cron job for that, but I don't want to deal with everything needed for retrying/reprocessing/failure handling plus now that it's a multi-instance deployment it's not even clear which process should do this! Let's put this work in a Lambda from our cloud provider.

So until now, we had a star architecture where everything talked to our business core. But adding this lambda that will talk directly to other services without consulting the core we've lost that.

Now, stripping out the business core into its constituent parts doesn't sound so strange, does it?

Re: Monolith First (2015)

#204
We did the journey both ways:

Monolith -> Microservices -> Monolith

The first monolith was so bad that microservices made sense at that point in time. The current monolith is an exemplar of why we do not use microservices anymore. Everything about not fucking with wire protocols or distributed anything is 100x more productive than the alternatives.

Deciding you need to split your code base up into perfectly-isolated little boxes tells me you probably have a development team full of children who cannot work together on a cohesive software architecture that everyone can agree upon.

Re: Monolith First (2015)

#205
post #49

I'm embarrassed to say that I recently built microservices first, and am now kicking myself as I merge them back in to a monolith.

If you don't mind telling this story, why did you end up merging them back in? I would have thought that needlessly making microservices is bad but not bad enough to justify merging back.

It kind of depends how well you chose the service boundaries. If you chose well, there's not a huge downside, just a bit of extra overhead. If you chose poorly, it can make it practically impossible to have a reliable app with acceptable performance. If you start out with microservices before you understand the problem space, you are much more likely to choose poorly.

Re: Monolith First (2015)

#206
post #31

Earlier quoted context omitted.

When the same practices used to sell microservices get applied to modules, packages and libraries, there is no need to put a network in the middle to do the linker's job. But too many are eager to jump into distributed computing without understanding what they are bring into their development workflow and debugging scenarios.

It is much harder to enforce the discipline of those practices across modules boundaries than around network boundaries. So in theory yes you could have a well modularized monolith. In practice it is seldom the case. The other advantage of the network boundary is that you can use different languages / technologies for each of your modules / services.

> So in theory yes you could have a well modularized monolith.

I've often wondered if this is a pattern sitting underneath our noses. I.e., Starting with a monolith with strong boundaries, and giving architects/developers a way to more gracefully break apart the monolith. Today it feels very manual, but it doesn't need to be.

What if we had frameworks that more gracefully scaled from monoliths to distributed systems? If we baked something like GRPC into the system from the beginning, we could more gracefully break the monolith apart. And the "seams" would be more apparent inside the monolith because the GRPC-style calls would be explicit.

(Please don't get too hung up on GRPC, I'm thinking it could be any number of methods; it's more about the pattern than the tooling).

The advantages to this style would be:

* Seeing the explicit boundaries, or potential boundaries, sooner.

* Faster refactoring: it's MUCH easier to refactor a monolith than refactor a distributed architecture.

* Simulating network overhead. For production, the intra-boundary calls would just feel like function calls, but in a develop or testing environment, could you simulate network conditions: lag, failures, etc.

I'm wondering if anything like this exists today?

Re: Monolith First (2015)

#207
post #129

Earlier quoted context omitted.

More generous take on the meta: people do understand (some of) the problems involved but are less worried about debugging scenarios than resume padding. The most useful property of microservices is architecturing CVs.

Correct. What's best for the long term health of the business is not taken into consideration. The Board of Directors and the CEO only care about this quarter and this year, why would the foot soldiers take a long view? As an engineer, the thought process goes: I can use the same old tried and true patterns that will just get the job done. That would be safe and comfortable, but it won't add anything to my skillset/r…

I feel there is also a chicken-egg problem. Is IT hype driven because of RDD or vice versa? I also do not blame any party involved for acting like they do.

Re: Monolith First (2015)

#208
I have worked on both types of applications and what he says is very true. The startup which failed to launch because of difficulties in getting the architecture and infrastructure right. It was around 2014 and the company company eventually ran out money and more importantly missed the time frame. The second product was a massive enterprise product that had 100s of members working on it on any given day. The product was written in Java as a monolith. It was slow to develop and a pain to work on. But it worked and the product succeeded. People complained that it was slow and they were right.

So they decided to break it up into multiple services. First was a pdf report generation service which I wrote in node.js. Then more and more services were added and other other modules were ported as node apps or separate java apps. In the end it was around 12 services and all of them worked well.

The monolith was still there but it's fast enough and users were happy. That's a lesson I'll never forget and have understood that time and velocity are far more important for a product to succeed!

Re: Monolith First (2015)

#210
Most common architecture for SAAS apps is a frontend served from cdn + frontends served by app stores, an api server behind app load balancer (e.g nginx), a database cluster, and a bunch of async long lived cron jobs + on demand jobs.

In that architecture you don’t need that many Microservices. The api server is prolly the most important bit and can be served as a monolith.

Many 10B+ companies use this architecture. It works well and does the job. Mono/Microservices is really about separation of concerns. Separation of concerns mostly around what you want to deploy as a unit, redundancy and what should be scaled as a unit.

Agree with author. Start with one chunk, and split when you feel the pain and need that separation of concern. Fewer pieces are easier to reason about.

Post reply on HN