Challenges of Decomposing a Massive Front-End Using Micro-Frontends

Rate this content
Bookmark
Slides

Our web UI application is pretty big - hundreds of people have been actively building it during the past eight years. We started facing scalability issues and technological limitations. We evaluated plenty of options and settled on micro-frontends. This evening we will discuss:

- Differences between various micro-frontend architectures

- Why we made this choice and if it's helpful for you

- What we gained

- What we sacrificed (yes, there are downsides)

- What challenges are still ahead of us

This talk has been presented at React Day Berlin 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

A microfrontend is an architectural style where a web application is divided into smaller, independently deployable frontend components, enabling teams to work on them autonomously.

Microfrontends become beneficial when you start experiencing pain points with scaling, maintaining, or deploying large web applications. They are particularly useful for large teams and complex projects.

Key challenges include defining a migration strategy, dividing domains effectively, managing dependencies and pipelines, handling shared state, and preventing code duplication.

Recommended tools include Module Federation and NX for monorepo management. Some teams also use VIT and custom scripts to manage microfrontend setups.

Microfrontends allow for more focused and faster testing by isolating tests to specific components. This reduces overall build and test times and can improve the reliability of continuous integration and deployment pipelines.

Horizontal split involves multiple frontend frameworks on the same page, while vertical split divides the application by domain, with only one microfrontend on the screen at a time.

Shared state in microfrontends can be managed using global objects, PubSub mechanisms, or state management libraries like Redux. It is often less problematic than it is perceived to be.

Monorepos are recommended because they simplify dependency management, improve discoverability of microfrontends, and make it easier to apply updates and maintain the codebase.

Common misconceptions include the belief that microfrontends always involve multiple frameworks on the same page and that they are only beneficial for very large companies.

Microfrontends can enhance developer experience by allowing teams to work more independently and make decisions autonomously. This can lead to faster development cycles and higher job satisfaction.

Oleksandr Tryshchenko
Oleksandr Tryshchenko
28 min
08 Dec, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Microfrontends offer a potential solution to frontend engineering problems, improving testing efficiency and allowing for faster development. There are misconceptions about microfrontends, with different approaches such as horizontal and vertical splits. Monorepos are recommended for managing microfrontends. Data management and side effects can be handled through various approaches. Building microfrontends without a monorepo can be challenging, but it depends on the scale of the application. Trust in people and implementing a registry of components help avoid duplication. Tools like Module Federation and NX are useful for managing microfrontends.

1. A Dream, Pager Duty, and Microfrontends

Short description:

It's a nice, sunny day. You're gliding across the fjords. Water consumes you. You take a look at your phone and see a pager duty notification. You understand the problem, but it's caused by someone not even a frontend engineer. You fix it, but encounter issues. Eventually, you merge your pull requests. Microfrontends is a potential solution to this problem.

It's a nice, sunny day. You're gliding across the fjords. The nice sun rays fall on the lush forests and those fjords. You are dreaming to have this vacation for a long time. You are truly happy until something gets wrong.

Water consumes you. You lose control. You don't understand what's happening until you wake up. It's been a dream. It's been a bad dream and something has clearly woken you up. You take a look at your phone and you see that it is a pager duty notification. You have a duty to do.

Annoyed, you wake up. You stand up and lazily go to your computer to see what has happened. After some minutes of looking into the issue, you understand what the problem is. Nevertheless, you are extremely annoyed that it's caused not even by your team, but somebody who is not even a frontend engineer.

You hit the table because you're angry. You forget you have a kid who is woken up by your anger and now you have to explain your son why your father, Keith's father, has to fix a mobile phone validation library at night. You do the fix. You open the pull request, which takes 40 minutes to build. You make a coffee while you wait, and in the end instead of a happy green checkmark, you get a red cross.

Wakey test again. You click the restart button. You finish your cold tea to see your green checkmark. You merge your pull requests. You can go sleep for a couple of hours until you're going to wake up and do more job.

It's an example of a combination of a technological problem and an organizational challenge. It shouldn't have happened. Nevertheless, it's there. Microfrontends is one of the potential solutions to address this problem.

2. Microfrontends and Communication

Short description:

Today we are going to talk about microfrontends. We will share experiences from different companies and dispel stereotypes surrounding this topic. When discussing ideas in a group, the conversation often expands and deviates from the original plan. Many people can relate to this, as it can be challenging to effectively communicate and make decisions in larger groups. This concept applies not only to software development but also to other areas, such as politics.

Thank you all for coming here. My name is Alex, and today we are going to talk about microfrontends. I was fortunate or fortunate enough to work in three companies which did microfrontends. Those were fairly different companies, and they wanted to share their experience. How did they do it? Also, dispel some stereotypes which surrounds the topic of microfrontends in general.

Let's talk about your company. You're working and you get an idea. You want to do something very straightforward, very simple, very tangible, and it's going to have very predictable and clear output. Seems easy, right? Let's do X and we're going to get Y. Very straightforward. But no, there is a guy with opinions, and now you have to convince him how you're going to do this. And at least his point makes sense, like, understand, okay, I see where you're coming from. Let's have a chat. Unless discussion expands. Expands in dimensions you didn't envision at first. And the further it goes, the more it deviates from the place it started until eventually it's gone.

Please raise your hands who can relate to the story. Many people. And people who are sitting around you, people who are part of those calls, they don't really want to be there. They also have life to live and they have kids who don't want to know about phone libraries. There is a lot of research about this. It's not a bleeding-edge subject. There was Fred Brooks. He was an engineer and engineering manager, like, many years ago, before many of us were even born. And he wrote a book. The book is called the Mythical Man Mouth, where he describes the concept of people interacting on scale. And the bigger the group is, the harder it is for people to effectively communicate and make decisions. There are similar concepts and I would say that it's credible enough to make our assumptions on this. And it also applies to different spheres of our life. If you will take a look at politics, for example, countries which are like deeply decentralized, they tend to be more effective in managing themselves.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Monolith to Micro-Frontends
React Advanced Conference 2022React Advanced Conference 2022
22 min
Monolith to Micro-Frontends
Top Content
Microfrontends are considered as a solution to the problems of exponential growth, code duplication, and unclear ownership in older applications. Transitioning from a monolith to microfrontends involves decoupling the system and exploring options like a modular monolith. Microfrontends enable independent deployments and runtime composition, but there is a discussion about the alternative of keeping an integrated application composed at runtime. Choosing a composition model and a router are crucial decisions in the technical plan. The Strangler pattern and the reverse Strangler pattern are used to gradually replace parts of the monolith with the new application.
Micro-Frontends With React & Vite Module Federation
React Advanced Conference 2023React Advanced Conference 2023
20 min
Micro-Frontends With React & Vite Module Federation
Top Content
Watch video: Micro-Frontends With React & Vite Module Federation
Microfrontends is an architecture used by big companies to split monolithic frontend applications into manageable parts. Maintaining a consistent look and feel across different microfrontends is a challenge. Sharing styles can be done through Vanilla CSS, CSS modules, or CSS in JS. JavaScript variables can be used in styles, but readability and runtime overhead are considerations. Sharing state in microfrontends can be achieved through custom events, broadcast channels, shared state managers, or custom PubSub implementations. Module federation with Vite allows for client composition and sharing dependencies. Configuration is similar to Webpack, and future work includes working on the QUIC framework.
Federated Microfrontends at Scale
React Summit 2023React Summit 2023
31 min
Federated Microfrontends at Scale
Top Content
Watch video: Federated Microfrontends at Scale
This Talk discusses the transition from a PHP monolith to a federated micro-frontend setup at Personio. They implemented orchestration and federation using Next.js as a module host and router. The use of federated modules and the integration library allowed for a single runtime while building and deploying independently. The Talk also highlights the importance of early adopters and the challenges of building an internal open source system.
“Microfrontends” for Mobile in React Native
React Advanced Conference 2023React Advanced Conference 2023
24 min
“Microfrontends” for Mobile in React Native
Top Content
Watch video: “Microfrontends” for Mobile in React Native
Micro frontends are an architectural style where independent deliverable frontend applications compose a greater application. They allow for independent development and deployment, breaking down teams into feature verticals. React Native's architecture enables updating the JavaScript layer without going through the app store. Code Push can be used to deploy separate JavaScript bundles for each micro frontend. However, there are challenges with managing native code and dependencies in a micro frontend ecosystem for mobile apps.
Sharing is Caring: (How) Should Micro Frontends Share State?
React Summit 2022React Summit 2022
23 min
Sharing is Caring: (How) Should Micro Frontends Share State?
Top Content
Micro-frontends allow development teams to work autonomously and with less friction and limitations. Organizing teams around business concerns, in alignment with subdomains, rather than technical concerns, can lead to software that is split nicely and user stories falling under the responsibility of a single team. Having a logical backup or reference point is important for implementing microfrontends without breaking their isolation. Microfrontends can communicate with each other using the window object and custom events. Microfrontends should be kept isolated while maintaining communication through various approaches.

Workshops on related topic

Micro Frontends with Module Federation and React
JSNation Live 2021JSNation Live 2021
113 min
Micro Frontends with Module Federation and React
Workshop
Alex Lobera
Alex Lobera
Did you ever work in a monolithic Next.js app? I did and scaling a large React app so that many teams can work simultaneously is not easy. With micro frontends you can break up a frontend monolith into smaller pieces so that each team can build and deploy independently. In this workshop you'll learn how to build large React apps that scale using micro frontends.
Micro-Frontends with Module Federation and Angular
JSNation Live 2021JSNation Live 2021
113 min
Micro-Frontends with Module Federation and Angular
Workshop
Manfred Steyer
Manfred Steyer
Ever more companies are choosing Micro-Frontends. However, they are anything but easy to implement. Fortunately, Module Federation introduced with webpack 5 has initiated a crucial change of direction.
In this interactive workshop, you will learn from Manfred Steyer -- Angular GDE and Trusted Collaborator in the Angular team -- how to plan and implement Micro-Frontend architectures with Angular and the brand new webpack Module Federation. We talk about sharing libraries and advanced concepts like dealing with version mismatches, dynamic Module Federation, and integration into monorepos.
After the individual exercises, you will have a case study you can use as a template for your projects. This workshop helps you evaluate the individual options for your projects.
Prerequisites:You should have some experience with Angular.