Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 7

Architectural Styles: Monolith, SOA, and Microservices

Recommended resources

Hello! Welcome to your seventh lesson in the Foundations of System Architecture.

In our last lesson, we explored the principle of Separation of Concerns (SoC) and its role in achieving high cohesion and low coupling. We established that SoC is the fundamental tool architects use to manage complexity.

Today, we'll see this principle in action at the highest level of system design. We are going to compare and contrast monolithic, service-oriented, and microservice architectures. These three architectural styles are essentially different strategies for separating concerns across an entire application. Your goal for this lesson is to understand the structure, benefits, and drawbacks of each, so you can analyze the critical trade-offs involved in choosing one over the other.

This is a pivotal topic. As an aspiring architect, being able to articulate the "why" behind choosing a microservices approach over a monolith (or vice versa) is a core competency.

1. The Architectural Styles: An Overview

Let's start with a high-level visual comparison. These three styles represent a spectrum of granularity—from a single, coarse-grained unit to many fine-grained, independent units.

Comparison of Monolithic, SOA, and Microservices Architectures
This image provides a visual summary. A **monolith** is a single, large block. **Service-Oriented Architecture (SOA)** breaks the system into a few, larger services that might share some infrastructure. **Microservices** break the system into many small, independent services, each with its own dedicated components, including a database.

We will now unpack what this visual represents by following the logical evolution from one style to the next.


2. The Monolith: A Unified Beginning

A monolithic architecture builds and deploys an entire application as a single, indivisible unit. If you've worked on a traditional web application where the front-end, back-end logic, and data access layer are all in one codebase and deployed together, you've worked with a monolith.

To see how this works in practice—and to understand its limitations—we'll use a running example of an e-wallet application.

System Design: Monolithic vs SOA vs Microservice Architecture

This video from techwithshakul provides an excellent, practical walkthrough of an e-wallet application's architecture, starting with a monolithic design.

Please watch from the beginning until 06:08. Pay close attention to: The definition of a monolith as 'one big piece of rock'. How the e-wallet features (send, add, view) are implemented within a single codebase. The initial benefits: simplicity and ease of development. The key drawbacks that emerge: lack of code reusability, tight coupling, and challenges with deployment and scaling.

As the video demonstrates, the primary trade-off with a monolith is simplicity at the start versus complexity over time.

  • Advantages:

    • Simple to Develop: All code is in one place, making initial development straightforward.
    • Simple to Deploy: You have only one application to deploy and manage.
    • Simple to Test: You can launch the single application and test its functionality end-to-end.
    • Performance: Communication between components happens via in-process function calls, which are extremely fast.
  • Disadvantages:

    • Tight Coupling: As the codebase grows, modules become highly interdependent. A change in one part can have unintended consequences elsewhere. This is the opposite of the "low coupling" we aim for.
    • Difficult to Scale: You must scale the entire application, even if only one small feature is experiencing high load. If the "view transactions" feature is slow, you can't scale it independently of the "send money" feature.
    • Technology Lock-in: The entire application is committed to a single technology stack. Adopting a new language or framework requires a rewrite.
    • Slower Deployments: As the application grows, build and deployment times increase significantly. A single bug fix requires redeploying the entire system, increasing risk.

Given your background in IT infrastructure, you can see the operational pain points here. Scaling an entire large application just to handle load on a single component is highly inefficient in terms of resource utilization.


3. Service-Oriented Architecture (SOA): Introducing Modularity

The problems of the monolith led to the rise of Service-Oriented Architecture (SOA). SOA applies the Separation of Concerns principle by breaking the monolith down into a collection of distinct services that represent business functions (e.g., an "authentication service" or a "payment service").

Let's continue with the video to see how SOA attempts to solve the monolith's problems.

System Design: Monolithic vs SOA vs Microservice Architecture

The video now evolves the e-wallet into an SOA, addressing the issues of code reuse and tight coupling.

Watch from 06:08 to 08:46. Focus on how creating independent services solves the reusability problem. Crucially, pay attention to the major limitation it introduces: the shared database.

SOA was a significant step forward. Services are:

  • Reusable: A single Authorization service can be used by multiple other services.
  • Loosely Coupled: Teams can work on different services independently.
  • Independently Scalable (to an extent): You can deploy more instances of a high-traffic service.

However, classic SOA often had two main issues:

  1. The Shared Database: As the video highlights, multiple services accessing the same database re-introduces a form of coupling. The database becomes a central point of contention and a potential bottleneck. A change to the database schema for one service might break another.
  2. The Enterprise Service Bus (ESB): Many traditional SOA implementations used a centralized component called an ESB to handle communication, routing, and transformation between services. This ESB could become a complex, single point of failure itself.

A more modern, lightweight interpretation of this style is often called a Service-Based Architecture, which avoids the heavy ESB but may still involve some shared infrastructure, like a database.


4. Microservices: Radical Decoupling

The microservices architecture is a refinement of SOA that takes decoupling to its logical extreme. It advocates for breaking an application into a suite of small, completely autonomous services, each running in its own process and communicating via lightweight mechanisms like HTTP/REST APIs.

The most defining characteristic of a microservice is that it is fully independent: it owns its business capability and its own data.

System Design: Monolithic vs SOA vs Microservice Architecture

Finally, the video refactors the e-wallet into a microservices architecture, highlighting its key benefits and trade-offs.

Watch from 08:46 to the end. Observe how each microservice gets its own database, solving the SOA bottleneck. Note the resulting benefits (independent scaling, tech flexibility, parallel deployment) and the new challenges (network latency, operational complexity).

With microservices, you achieve the ultimate goal of high cohesion and low coupling:

  • High Cohesion: Each service is focused on a single business capability.
  • Low Coupling: Services are completely independent. They can be developed, deployed, and scaled without affecting any other service.

This unlocks significant benefits:

  • Independent Scalability: Scale only the services that need it.
  • Technology Freedom: Each service can be written in the language best suited for its task.
  • Fault Isolation (Resilience): A failure in one service doesn't bring down the entire system (if designed correctly).
  • Team Autonomy: Small teams can own and operate their services independently, leading to faster development cycles.

However, this comes at a significant cost: operational complexity. You are no longer managing one application; you are managing a distributed system of dozens or hundreds of services. This requires mature DevOps practices, sophisticated monitoring, and strategies for handling network failures.

Test your understanding!

Based on the video and our discussion, what is the single most important structural difference between a typical Service-Oriented Architecture and a Microservices architecture?

Show answer

The most important difference is data ownership. In a classic SOA, services are often loosely coupled at the application level but remain tightly coupled at the data level by sharing a single database. In a microservices architecture, each service is fully autonomous and encapsulates its own data, typically by having its own private database. This complete decoupling is what enables true independent deployment and scaling.


5. Analyzing the Architectural Trade-offs

Choosing an architecture is about weighing trade-offs. A monolith offers low operational complexity but low flexibility. Microservices offer high flexibility but high operational complexity. Let's formalize this comparison.

The following resource provides a fantastic summary table and further definitions.

Monolithic vs Microservices vs SOA – Architecture ...

The article 'Monolithic vs Microservices vs SOA' from Design Gurus provides a concise summary of the key characteristics of each architecture.

Focus on the summary table at the beginning of the article. This is an excellent reference that directly compares the three styles across features like deployment, scalability, and complexity. Use it to solidify your understanding of the differences.

To dive deeper into the operational characteristics, let's watch one more expert analysis. This video contrasts a modern "Service-Based" architecture with Microservices and uses a star-rating system to evaluate them on different quality attributes.

Lesson 114 - Microservices vs. Service Based Architecture

Mark Richards, a renowned software architect, provides a detailed comparison of the operational characteristics of Service-Based and Microservices architectures. This will help you understand the practical consequences of each choice.

Watch from 00:32 to 09:14. Absorb the key structural differences he highlights first. Then, pay close attention to the star-rating comparison. You don't need to memorize the ratings, but understand the reasoning behind them. For example, why do microservices get 5 stars for elasticity but only 1 star for cost?

Here is a summary of the key trade-offs discussed in the video:

Characteristic Service-Based Architecture Microservices Architecture Rationale
Elasticity ★★★☆☆ ★★★★★ Microservices are fine-grained and start up very fast, making them ideal for handling sudden load spikes.
Scalability ★★★☆☆ ★★★★★ Microservices allow for fine-grained scaling of individual functions, which is more efficient.
Fault Tolerance ★★★☆☆ ★★★★★ The "blast radius" of a failure is much smaller in a microservices architecture.
Performance ★★★★☆ ★★☆☆☆ Service-Based architectures have fewer network calls, as related functionality is often in the same service. Microservices incur network latency for inter-service communication.
Cost ★★★★☆ ★☆☆☆☆ Microservices are very expensive due to operational overhead, infrastructure for many services, and the need for DevOps automation.
Simplicity ★★★★☆ ★☆☆☆☆ Microservices are extremely complex to design, manage, and debug due to their distributed nature.

6. When to Choose What?

There is no single "best" architecture. The right choice depends on your specific context.

Monolithic vs SOA vs Microservices Architecture - Ahmed Emara

This article by Ahmed Emara provides practical, scenario-based advice for when to choose each architecture, using a fintech startup as an example.

Skim through the article, but focus specifically on the 'When to Consider...' sections for each architectural style. This directly answers the pragmatic question of which architecture fits which scenario.

Here’s a simplified decision guide based on what we've learned:

  • Start with a Monolith when:

    • You are building a Minimum Viable Product (MVP) or a proof-of-concept.
    • Your team is small (e.g., 2-5 developers).
    • Your application domain is simple and not well understood yet.
    • Speed of initial development is the highest priority.
  • Consider a Service-Based or SOA style when:

    • You are evolving a monolith that has become too large.
    • You need to integrate with multiple other systems in a corporate environment.
    • Your team is growing, and you want to organize them around specific business capabilities.
    • You want better modularity than a monolith but are not ready for the full complexity of microservices.
  • Choose Microservices when:

    • You are building a large, complex system that needs to evolve rapidly.
    • You require extremely high scalability and resilience.
    • You have large development teams that can work independently.
    • You have a mature DevOps culture and robust automation for testing, deployment, and monitoring.

Conclusion

Today we journeyed through the evolution of system architecture styles, from the simplicity of the monolith to the radical decoupling of microservices. Each style is a different answer to the fundamental challenge of managing complexity through the Separation of Concerns.

Key Takeaways:

  • Monolithic Architecture: A single, unified application. Simple to start, but becomes tightly coupled and difficult to scale and maintain over time.
  • Service-Oriented Architecture (SOA): Decomposes an application into reusable services based on business function. It improves on the monolith but can suffer from bottlenecks like a shared database.
  • Microservice Architecture: An evolution of SOA where services are small, autonomous, and own their own data. This provides maximum flexibility, scalability, and resilience but introduces significant operational complexity.
  • The Choice is a Trade-off: The decision is not about "which is better" but "which is most appropriate for my context." It's a balance between development speed, scalability requirements, team structure, and operational maturity.

In our next lesson, we will zoom in from this high-level system structure to look at patterns used within applications and services. We'll describe common architectural patterns like the Layered and Event-Driven architectures, which you'll find are often associated with the styles we discussed today. For example, the Layered pattern is very common inside monoliths, while the Event-Driven pattern is a powerful tool for communication in microservices systems.