Micro Frontend Solution 1 - Thinking
In recent years, microservices architecture has become hugely popular in the backend development community, considered the future direction of IT software architecture. How can we apply the principles of backend microservices to build modern frontend applications? Here I provide a frontend microservices solution that can actually be implemented in production.
Comparison of Backend and Frontend Microservices
Advantages of Backend Microservices:
- Controlled Complexity: Small size, low complexity. Each microservice can be fully managed by a small development team, making it easy to maintain high maintainability and development efficiency.
- Independent Deployment: Since microservices run in separate processes, each can be deployed independently.
- Flexible Technology Choices: In a microservices architecture, technology selection is decentralized. Each team can freely choose the most suitable tech stack based on their service needs and industry trends.
- Fault Isolation: When a component fails, in a single-process traditional architecture, the fault is likely to spread within the process, causing global unavailability.
- Scalability: Monolithic applications can also scale horizontally, but it requires replicating the entire application to different nodes.
Advantages of Frontend Microservices:
- Controlled Complexity: Each UI business module is developed by an independent frontend team, preventing code bloat, maintaining fast compilation during development, and keeping complexity low for easy maintenance.
- Independent Deployment: Each module can be deployed independently, down to a single component’s UI, without affecting other modules.
- Flexible Technology Choices: The most attractive advantage — you can use any frontend tech stack available today, including future ones, within the same project.
- Fault Isolation: A single module failure does not affect the entire application.
- Scalability: Each service can be independently scaled horizontally to meet business needs without unnecessary resource consumption.
When Do We Need Frontend Microservices?
- The project’s tech stack is outdated, developers with relevant skills are scarce, feature expansion is difficult, and refactoring or maintenance costs are high.
- The project is too large, code compilation is slow, the development experience is poor, and a higher-level decoupling solution is needed.
- A single tech stack cannot meet your business requirements.
Problems and Challenges
We will face the following issues:
- How do we render multiple tech stacks on a single page?
- How do independent modules using different tech stacks communicate?
- How do we route to the correct module?
- How do we trigger routes correctly between different tech stacks?
- After splitting the codebase, how do we merge it back together?
- How should each module project be bundled?
- How should we write our code after adopting frontend microservices?
- How should independent teams collaborate?
In subsequent articles, I will address each of these questions and explore the potential of frontend microservices. Moving beyond concepts, real implementation in your projects.
Related Articles
- Micro Frontend Solution 1 - Thinking
- Micro Frontend Solution 2 - Single-SPA
- Micro Frontend Solution 3 - Module Loader
- Micro Frontend Solution 4 - Message Bus
- Micro Frontend Solution 5 - Route Distribution
- Micro Frontend Solution 6 - Build and Deploy
- Micro Frontend Solution 7 - Static Data Sharing
- Micro Frontend Solution 8 - Secondary Build
Demo
- Micro Frontend Demo
- Micro Frontend Module Loader
- Micro Frontend Base App Source
- Micro Frontend Submodule Demo Source