More Architecture Styles and How to Choose One
Besides the monolith, the modular monolith and microservices, there are other well-known styles: layered, pipeline, microkernel, service-based, event-driven, space-based and orchestration-driven. Each one is good at a few characteristics and bad at others. Choose by starting from measurable scenarios and limits, compare two or three real candidates, test the riskiest guess, and write an ADR with a review date.
Author: bezzad
Contents
The problem: “Monolith or microservices?” is too small a question
In the lesson on architecture styles we compared the monolith, the modular monolith and microservices. In real projects, you will meet more styles. Some parts of our online shop do not fit any of those three well:
- A nightly job imports 2 million prices from suppliers.
- Checkout must calculate tax differently in each country, and we add countries every year.
- A flash sale sends 200 times the normal traffic for ten minutes.
Each of these has a style that fits it better. A good architect knows the main styles, knows what each one is good and bad at, and chooses with evidence.
Two big families
- One deploy unit (monolithic). One app, one release. Simple to build, test, debug and run. But it scales and releases as one piece.
- Many deploy units (distributed). Several apps that talk over the network. Parts can scale and release alone. But every call can be slow or fail, and data is harder to keep consistent.
One more axis: how is the code split?
- Technical partitioning. The top-level split is by technical role: UI, business logic, data access. Easy to understand for developers. But a business change (“add gift wrap”) usually touches every layer.
- Domain partitioning. The top-level split is by business area: Catalog, Order, Payment. A business change usually stays in one part. Inside each part, you can still have layers.
Most modern styles prefer domain partitioning at the top. Keep this axis in mind for every style below.
The styles, one by one
Layered
Code is in horizontal layers: presentation, business, persistence, database. A request goes down through the layers and back up.
- Good at: simplicity, low cost, a familiar structure for new developers. A fine start for small apps.
- Bad at: scale (it scales as one piece), deployability (one change, full release), and business changes that cross all layers.
- Watch for the “sinkhole”. If most requests only pass through layers without doing any work, the layers cost more than they give.
Modular monolith
One deploy unit, split by business area into modules with clear contracts. We studied it in the architecture styles lesson. It is often the best default for a new product and a small or medium team.
Pipeline (pipes and filters)
Data flows through a line of small steps. Each step (filter) does one job and passes its output to the next through a pipe.
- Step types: a producer starts the flow, a tester checks and maybe drops data, a transformer changes it, a consumer ends it.
- Good at: one-way data processing: imports, exports, reports, compilers, shell commands, ETL jobs. Steps are easy to test and reuse.
- Bad at: interactive work with many back-and-forth steps; it is usually one deploy unit, so it scales as one.
- In our shop: the nightly price import.
Microkernel (plug-in)
A small, stable core plus plug-ins that add or change behavior. The core knows how to find plug-ins (a registry) and talks to them through a fixed contract.
- Good at: products that many customers adapt: IDEs, browsers, tax or insurance rules that differ by country or customer.
- Bad at: very high scale, and plug-ins that need to talk to each other a lot.
- In our shop: checkout with one tax plug-in per country. A new country is a new plug-in; the core does not change.
Service-based
A middle step between a monolith and microservices: a few big services (often 4 to 12), each covering a large business area, usually with one user interface and often one shared database.
- Good at: independent releases of big areas, without the full cost of microservices. Transactions inside one service are still easy.
- Bad at: fine-grained scaling; a shared database still couples the services through its tables.
- When: a monolith that needs some independence, by a company not ready for dozens of services.
Event-driven
Parts react to events (“order placed”) instead of calling each other directly. There are two common shapes:
- Broker (choreography). Each part listens and reacts; nobody controls the whole flow. Very decoupled and fast, but the whole flow is hard to see and errors are hard to handle.
- Mediator (orchestration). One mediator knows the steps and sends work to each part. Easier to follow and to handle errors, but the mediator is coupled to every step.
- Good at: responsiveness, scale, and adding new reactions without changing the sender.
- Bad at: testing, debugging, and keeping data consistent at every moment.
Space-based
Built for huge and sudden peaks. Many processing units each keep the data they need in memory. The copies are kept in sync between units, and data is written to the database later, in the background. The database is no longer the bottleneck.
- Good at: extreme elastic scale: ticket sales, flash sales, online auctions.
- Bad at: simplicity and cost. Data in memory must be synced, and the database is a little behind. Testing real peak load is expensive.
- In our shop: maybe only the flash-sale part, not the whole shop.
Orchestration-driven (classic SOA)
A style from the 2000s: services are split by technical role (business services, enterprise services, infrastructure), and a central enterprise service bus orchestrates flows and translates messages. The goal was maximum reuse.
- Lesson learned: reuse across the whole company created huge coupling. Every change needed the central team and touched many services. It is rare in new systems, but you may meet it in old ones.
Microservices
Many small services, each owning one business area and its own data, released alone. We studied it in the microservices lesson. Great team independence and fine-grained scale; the highest cost in operations, data consistency and debugging.
A rough comparison
These are typical tendencies, not laws. A well-built system can do better or worse than its style.
| Style | Simplicity and cost | Scale and elasticity | Independent releases | Fault tolerance |
|---|---|---|---|---|
| Layered | High | Low | Low | Low |
| Modular monolith | High | Low | Low to medium | Low |
| Pipeline | High | Low | Low | Low |
| Microkernel | High | Low | Medium (plug-ins) | Low |
| Service-based | Medium | Medium | Medium | Medium |
| Event-driven | Low | High | High | High |
| Space-based | Low | Very high | Medium | High |
| Orchestration (SOA) | Low | Medium | Low | Medium |
| Microservices | Low | High | Very high | High |
Notice the pattern: what you gain in scale and independence, you pay for in simplicity and cost.
How to choose
- Write the scenarios. The real situations with numbers: the lunch peak, a flash sale, a server failure, how often each team must release, a law about where data lives. (See the lesson on architecture characteristics.)
- List the limits. Team size and skills, budget, the platform you already run, deadlines.
- Compare two or three real candidates. For each scenario, write how the style meets it, and what it costs. If a style needs a mechanism you cannot run (for example, a data grid nobody knows), that is a cost too.
- Prototype the riskiest guess. Build a small spike for the part you are least sure about, and measure. Do not guess about the most expensive risk.
- Decide and write an ADR, with the alternatives, the trade-offs and a review date. Prefer choices you can undo: clear contracts between parts, and a pilot on one slice before the whole system.
Different parts can use different styles. Our shop can be a modular monolith overall, with a pipeline for the nightly import, a microkernel for tax rules, and a separate, elastic deploy unit for the flash sale.
When to move to another style
Watch for signals, not for fashion:
- Teams wait for each other’s releases more and more.
- One part needs a very different scale or availability than the rest.
- Changes keep crossing the same borders (the borders may be wrong).
- The quality goals of the business change, for example a new market or a big partner.
Common mistakes
| Mistake | Result | The right way |
|---|---|---|
| Choosing the style you want on your CV | High cost, no real need. | Start from scenarios and limits. |
| Distributing too early | All the network costs, before any benefit. | A modular monolith until there is a real reason. |
| One style for every part | Pay for the hardest part everywhere. | Different styles for parts with different needs. |
| Ignoring the data | A nice service diagram that cannot be consistent. | Decide data ownership with the style. |
| A decision with no review date | An old choice nobody dares to question. | ADR with alternatives and a review date. |
Summary in six lines
- Styles come in two families: one deploy unit, or many deploy units.
- Split the top level by business area when you can; layers can live inside each part.
- Pipeline fits one-way data flows; microkernel fits products with many custom rules.
- Service-based is a middle step; space-based is for huge sudden peaks; classic SOA taught us that company-wide reuse couples everything.
- More scale and independence usually means less simplicity and more cost.
- Choose from scenarios and limits, compare 2 or 3 candidates, prototype the riskiest part, and write an ADR with a review date.