Software Architecture Patterns Overview
Mario Cardoso
Senior Software Engineer | Data Engineer | ETL | Terraform associate | Python | Java
Introduction
Imagine millions of users relying on a single application. How do you ensure it runs smoothly and scales effectively? Software architecture patterns provide some of the answers! The article's targets are software developers, software engineers, architects, and anyone interested in building or understanding complex software systems
Here, you will see a high-level overview of software architecture and system design patterns, exploring their strengths, weaknesses, best practices, and real-world applications. It also explains the difference between system design, software architecture, and software design.
This article focuses on software architecture patterns, which include system design patterns. You will find lots of documentation around the web mixing or separating these categories. I choose to aggregate since it's an overview and there's a very subtle and not well-documented line between them. Let's see, first, what Martin C Robert, in the first chapter of the Clean Architecture book, says about the difference:
... For starters, I’ll assert that there is no difference between them. None at all. The word “architecture” is often used in the context of something at a high level that is divorced from the lower-level details, whereas “design” more often seems to imply structures and decisions at a lower level. But this usage is nonsensical when you look at what a real architect does.
In a very resumed explanation, we can consider that design = detailed, so both system design and software design have a detailed approach:
Suppose you want to learn more about System Design. In that case, you can read my article explaining system design from a requirements perspective or my other article demystifying common jargon of system design.
I will skip the software design patterns overview since it's very well-documented and vast. Now, let's depict software architecture patterns. By understanding these patterns, you can equip yourself to make informed decisions when designing and building complex systems.
Monolithic Architecture
In software development, a monolithic architecture represents a traditional approach where the entire application is built as a single, self-contained unit. Imagine it like a well-oiled machine, where all the components work together seamlessly.
It may be the simpler architectural pattern but I can grant you that it can resolve most of the common system necessities without technical debts
Here's a breakdown of its pros and cons to help you decide if it's the right fit for your project:
Pros
Cons
Best Practices
Real-World Example
A simple blog with few functionalities, like Stackoverflow, but smaller. It's good to point out that most of the StackOverflow codebase is still a monolith
Three Tier Architecture
Three-tier architecture is a popular software design pattern that separates a system into three horizontal layers, each with a specific responsibility. Although it might look the same as the MVC pattern, it's different. In the MVC pattern, the View and the Controller are in the Presentation tier, and the Model is in the Business tier. Here are the tiers in a three-tier architecture:
Pros
Cons
Real-World Example
A three-tier architecture is well-suited for most small-medium size e-commerce applications. The separation bellow allows for independent scaling of the user interface during peak shopping seasons while ensuring smooth order processing through the application tier:
Microservices Architecture
A microservices architecture decomposes an application into small, independent services, each with its own functionality, database, and deployment lifecycle.
Pros
Cons
Best Practices
领英推荐
Real-World Example
Netflix, Amazon, and Spotify all leverage microservices architectures in their system, along with other architectural patterns for big data.
Event-Driven Architecture (EDA)
An event-driven architecture uses events to trigger actions and interactions between services. Services publish events to a message broker, and other services interested in those events subscribe to them. This promotes loose coupling and asynchronous communication.
Pros
Cons
Best Practices
Real-World Example
Many messaging applications and real-time analytics platforms use EDA.
Batch Processing
It's probably the only pattern that Isn't an architectural one in this article, but a data processing one, although is here due to it's importance in overall software systems. Batch processing handles large datasets in bulk, often overnight, for historical analysis. This approach is cost-effective but not suitable for real-time needs.
Pros
Cons
Saga Pattern
The Saga pattern is a transactional messaging pattern for managing long-running business processes that flow through multiple microservices. It coordinates a sequence of local transactions across services to ensure data consistency in case of failures. Each service is responsible for rolling back what it has done in case of failure in any service related to it in the flow of a given operation.
Although I'm categorizing it as a Database pattern, it's not limited to database transactions. As you can see in the image, the SAGA Pattern can end in a refund to a client if some error appears during the buying process.
Pros
Cons
Best Practices
Real-World Example
Let's explain the image above:
CQRS
Command Query Responsibility Segregation
CQRS is a software architecture pattern that separates read (queries) and write (commands) operations into different models and databases. This improves scalability, performance, and maintainability for applications with high read traffic.
Pros
Cons
Best Practices
Real-World Example
E-commerce applications with a high volume of product searches (reads) and a lower volume of order placements (writes) can benefit from CQRS. The product catalog can be a read model optimized for fast searches, while the order processing system can be a separate write model.