Live data from Hacker News

Microfrontends should be a last resort

breck-mckye.com

131–140 of 143 posts

Re: Microfrontends should be a last resort

#131

Okay I think we have crossed a line here. What's the difference between microfront ends and a website with multiple pages? Wouldn't the point be to keep the style consistent anyway?

usually microfrontends have some shared UI and functionality core and several applications under them. This usually comes in the form of a shared top-bar and authentication layer as well as some kind of loader/routing to load each specific frontend.

Keeping style consistent is actually harder using microfrontends compared to shared libraries. It is more about letting each application choose its own tech stack and not be burdened by the other application's tech debt.

Re: Microfrontends should be a last resort

#132

Personally, I wouldn't call it a "last resort", but I definitely agree that keeping a functioning monolith is preferred. Nevertheless, one thing to keep in mind (and I do consulting on MF for the last 5 years) is that most projects / teams are not well prepared and actually not at all suited for MF. MF solutions are usually just done from a technology POV, which is already a problem. Next thing is that the used techn…

We’re about to embark on the MFE journey and I’m concerned about pulling it off in a way that will have justified the effort. Our motivations are pure, we have many feature teams, we’re driving toward team independence, already breaking up the monolith into Microservices, etc. But on the FE we have the standard requirement to maintain eventual (definition tbd) UI consistency and so intend to continue to maintain a la…

This gets you most of the advantages of a microfrontend:

1) Monorepo with multiple workspaces

2) With several separate independently deployed applications, each maintained by a separate team

3) That share a set of common packages for common stuff (auth, etc) with full typescript definitions

4) Add CI to typecheck if any shared package changes types you get errors

5) Preferably with the packages being able to be independently run for development (something like storybook, although I don't recommend it)

6) Preferably with the packages being kept small, lean, with limited number of external dependencies (ie, settle on the cross-team deps to use, so framework, routing, data-fetching, etc)

7) Some kind of pre-commit git hook or CI script to validate a set of core shared dependencies used by packages are kept in sync (ie, everyone is running the EXACT SAME React version). I use this one: https://gist.github.com/DanielHoffmann/a456aadb2f27880d59241...

8) Shared build configuration and tools, all apps are validated, built and bundled by the same code.

9) NO PACKAGE PUBLISHING/VERSIONING, all dependencies are workspace:*

For example:

  folder-structure:
  /apps/{team1-app-name}/
  /apps/{team2-app-name}/
  /packages/auth/
  /packages/some-util-lib/

  /package.json
  "scripts": (test, lint, format, typecheck all done at the top level package.json)
  "workspaces": [
    "apps/*",
    "packages/*",
  ],

  /packages/auth/package.json
  "scripts": (dev to run in development mode)
  "devDependencies": { "some-util-lib": "workspace:*", "react": "^18.0.0" }
  "peerDependencies": { "some-util-lib": "*", "react": "*" }

  /apps/{team1-app-name}/package.json
  "scripts": (dev to run in development mode, build for production builds)
  "dependencies": {
     "auth": "workspace:*"
     "some-util-lib": "workspace:*"
  }

This doesn't give you 100% of the independence of microfrontends, but it does give you quite a lot of bang for your buck. Depending how much independence or reuse you want you might want more or less shared external dependencies (for example your shared packages could be framework agnostic and just use raw JS)

The build/bundling configuration can set up separate chunks for the core set of shared dependencies (react, router, etc) to improve build times, load speeds and caching*

Re: Microfrontends should be a last resort

#133

I think microfrontends are the ultimate extension of what I call "the myth of code reuse". Everyone thinks because they can create "small reusable slices" of full frontend code that this comes for free without a load of problems that get in the way of the mythical land. The only issue is everyone who has tried microfrontends is universally full of regret. Other attempts at this are: 1) having an enforced centralised…

How many times per second do you think awk, grep, sed, et al are being used right now?

Composable tools exist. Whatever horseshit is going on around ANY bigger sized application is not. Excel, any random React app, GIMP… sure, compositional engineer might be taking place WITHIN the application, but it is barely composable beyond a Copy, Paste, Save As dialog and the ability to arrange the window with other windows.

Can’t you see how things immediately invert and turn inwards, away from interaction, away from composability, the moment the turn towards structured interfaces begins?

An API is a narcissist. You have to live in its world. A Unix pipe is a communist.

Think, aggregate vs combined in terms of the GPL… pipes vs APIs…

Re: Microfrontends should be a last resort

#134
post #107
post #104

Earlier quoted context omitted.

They can, but the walls are not strong enough to perturb those programmers who do not know any better, don’t care, or are under sufficient pressure to sweep aside good practice. Micro-anything is the philosophy based in the presumption that your engineers will not respect softer walls and modules and therefore strong ones must be constructed. It’s obvious that strong walls have immense cost, but perhaps for a large e…

I thought it was more about independence. Got a bug in your service? Instead of one massive build deployed once an hour/day/week/etc. that gets rolled back if any commit was bad, you deploy your service when it changes and don't worry too much about the unrelated pieces.

Yeah there's definitely other tradeoffs involved when decomposing a program into multiple binaries connected over the network, deployment coupling being one of them.

However, I still think this is fairly related to what I was trying to convey because it's related to the _process_ of the engineering vs. the technical merit of the deployed solution. The tradeoff space you're describing is pretty much a function of how big the team is, how it's structured, the products uptime requirements, deployment frequency, etc. as opposed to the technical merit of the design in isolation.

I don't think I worded it particularly well in my original comment, but I think these tradeoffs are interesting and frequently people talk past eachother about them because the 'right' decision depends on all the non-technical factors of the product.

Re: Microfrontends should be a last resort

#135
post #120

Earlier quoted context omitted.

Why does a monolith imply one massive build? Pretty much every compiled language has some concept of pre-compiled modules. Java has class files, C/C++ has shared/static object files, Rust has rlibs, Golang has internal object files, and so on. Caching them in a CI/CD pipeline is one of the first steps in the DevOps checklist for reducing build times.

Massive in terms of the changes going into it rather than the time required. Commits will be batched together while the previous CI/CD job runs, then each deploy will have a bunch of stuff on it. A single failure will halt the deploy for every change, and someone will need to go find and revert whatever caused it. Microservices split up the management across services, which ideally means each team only has to fix its…

Agreed that perhaps the notion of walls I used was too narrowly focused on code modularity, but I think we're pretty much saying the same thing about isolation and independence. The ability to apply local reasoning is the important part - if 'wall' is taken to mean something like this then I think we are in agreement.

Re: Microfrontends should be a last resort

#136
post #107

Earlier quoted context omitted.

I thought it was more about independence. Got a bug in your service? Instead of one massive build deployed once an hour/day/week/etc. that gets rolled back if any commit was bad, you deploy your service when it changes and don't worry too much about the unrelated pieces.

Got a feature that touches several modules? Instead of one massive build deployed once, you deploy each service. With dependencies you need to wait after each deployment to check if everything is ok. Instead of one big build and one deployment, you get quick build, deployment, check, quick build deployment, check... So in case of microservices/microfrontends you gain minutes on build time but lose hours/days on deplo…

Yes that is true, but the other side of that coin is that deploying changes to the interface between modules is now hard - that's the tradeoff space. If you have really clear interfaces with low churn then you probably have a net win, but in my experience it's really hard to get those interfaces right and that cost can end up beating your gains.

Re: Microfrontends should be a last resort

#137
I was working somewhere earlier this year that was thinking about going into micro frontends. To me the frameworks seemed pretty immature. I had perhaps naively thought when I first heard about micro frontends that they would be a bunch of iframes that you could compose together on a page, each with its own data fetching logic and thus reuse stuff that was otherwise totally disparate. But someone pointed out some practical difficulties of doing this and I agree it would be quite tough to pull off. It seemed like micro frontends just were trying to get the benefits of a monorepo but with everything in separate repos. And then having some complicated build logic so that hypothetical team could be working in angular 2 and hypothetical team b could be working in react and they could harmoniously mingle their work, in page divided blocks. i.e. at least as it was proposed where I was you couldn't mix and match components on a page, it was just 'route a will use one micro fe, route b will be another'. I'm wondering is this how micro fe is actually done? To me it seems pretty hackneyed and basic, not to mention if you wanted to do this monorepo would be more suitable.

Re: Microfrontends should be a last resort

#138
Microfrontends are just another example of a design pattern. The problem is developers think that they can solve any problem by stacking design patterns in the right order. At some point you need to write the code that makes your app work. Your special sauce. But people procrastinate by obsessing over which patterns they will use.

Re: Microfrontends should be a last resort

#139

Earlier quoted context omitted.

We’re about to embark on the MFE journey and I’m concerned about pulling it off in a way that will have justified the effort. Our motivations are pure, we have many feature teams, we’re driving toward team independence, already breaking up the monolith into Microservices, etc. But on the FE we have the standard requirement to maintain eventual (definition tbd) UI consistency and so intend to continue to maintain a la…

This gets you most of the advantages of a microfrontend: 1) Monorepo with multiple workspaces 2) With several separate independently deployed applications, each maintained by a separate team 3) That share a set of common packages for common stuff (auth, etc) with full typescript definitions 4) Add CI to typecheck if any shared package changes types you get errors 5) Preferably with the packages being able to be indep…

First off, I appreciate the thoughtful write-up, under different circumstances this is the direction I’d probably be heading. However our web Frontend code is all currently in a large-ish (500 packages, 100 apps) monorepo and we’re actively pursuing breaking that up into a hybrid repo model, largely in the interest of true team autonomy. We want our code organization to better reflect our Eng org structure and to establish much stronger lines of ownership and responsibility. Obviously we see other compelling reasons to take this big step, but there’s also a lot of risk involved, particularly around dependency management and figuring out how to accomplish eventual UI consistency across our web apps, all of which will use a large number of shared libraries/components that will be broadly organized into a handful of repos (likely monorepos) representing domains and owned by different teams. The intent is for this evolution to culminate in a microfrontends architecture as a way to support collaboration across autonomous teams without the need for built-time coupling.

Re: Microfrontends should be a last resort

#140
post #136

Earlier quoted context omitted.

Got a feature that touches several modules? Instead of one massive build deployed once, you deploy each service. With dependencies you need to wait after each deployment to check if everything is ok. Instead of one big build and one deployment, you get quick build, deployment, check, quick build deployment, check... So in case of microservices/microfrontends you gain minutes on build time but lose hours/days on deplo…

Yes that is true, but the other side of that coin is that deploying changes to the interface between modules is now hard - that's the tradeoff space. If you have really clear interfaces with low churn then you probably have a net win, but in my experience it's really hard to get those interfaces right and that cost can end up beating your gains.

Not sure what you mean. Changes to the interfaces in modular monolith are much easier than in microservices. You just release new version with updated interfaces - no need for versioning if you update interface and its usages. In case of microservices you must do versioning and either have to keep and support old version of the interface or spend some time to determine when to remove it.
Post reply on HN