Architecture Styles
- Describe eight architecture styles and draw each one from memory
- Compare styles on deployability, scalability, fault isolation, consistency, cost and team fit
- Choose a style for a given bank or e-commerce context and defend the choice
- Argue both sides of "monolith first" and explain why a modular monolith is often the right starting point
TL;DR
- A style is a named, reusable set of structural decisions: how code is partitioned, how parts communicate, and how they are deployed.
- Layered and modular monolith are a single deployable; they give you simple transactions and cheap refactoring. The modular monolith adds enforced module boundaries, which is what most "microservices" projects actually wanted.
- Microservices buy independent deployment and scaling per business capability at the price of distributed-systems complexity. They are an organizational scaling tool first.
- SOA/ESB is still everywhere in banks: a central bus that routes, transforms and orchestrates calls to the core. Modernization usually means shrinking the bus, not deleting it overnight.
- Event-driven, serverless, space-based and cell-based solve specific problems: decoupling and fan-out, spiky low-ops workloads, extreme burst throughput, and blast-radius limitation respectively.
- Monolith first (Fowler): you rarely know the right boundaries at the start, and wrong service boundaries are far more expensive than wrong module boundaries.
Why it matters
Interviewers love "Would you use microservices for this?" because there is no textbook answer — only good and bad reasoning. A bank with 400 engineers, a vendor core banking system and a 20-year-old ESB is in a completely different position from a 30-person e-commerce startup. The style you pick sets your team structure, deployment pipeline, failure modes, data consistency story and cloud bill for years. Choosing microservices for a team of eight is a common and expensive mistake; staying with a big-ball-of-mud monolith while 15 teams step on each other is the opposite one.
Core concepts
Layered (n-tier)
Code is split by technical concern: presentation, business logic, persistence. Each layer calls only the one below (closed layers) or may skip (open layers).
- Good for: small teams, CRUD-heavy back-office apps, internal tools, the first version of anything.
- Weakness: a single feature ("add a refund reason") touches every layer, so change cuts across the structure. Over time, business logic leaks into controllers and SQL, and the layers become a big ball of mud.
- Bank example: an internal limit-management back-office. E-commerce example: an admin panel for merchandisers.
Modular monolith
One deployable, but internally partitioned by business capability, with enforced boundaries.
Rules that make it "modular" rather than "monolith with folders":
- Each module exposes a small public API (interfaces, DTOs); internals are private (in Go, an
internal/directory enforces this at compile time). - Each module owns its tables (schema per module); no cross-module joins, no reading another module's tables.
- Modules communicate through in-process calls or an in-process event bus — designed as if they could become network calls later.
- Boundaries are checked in CI (dependency rules, architecture tests).
You get single-process transactions where you need them, one deployment pipeline, one thing to monitor, and an easy path to extract a module later. Shopify has written publicly about investing in a modular monolith rather than splitting into microservices.
Microservices
Independently deployable services, each owning a business capability and its data, communicating over the network (HTTP/gRPC, messaging). The defining property is independent deployability: if you must release five services together, you have a distributed monolith. Patterns are covered in Microservices Patterns.
- Buys: team autonomy, per-service scaling and technology choice, fault isolation (if done well), smaller blast radius per deploy.
- Costs: network failures, distributed transactions (Saga), eventual consistency, observability tooling, platform team, much harder local development and testing.
- Rule of thumb: microservices pay off when the number of teams, not the amount of traffic, makes the monolith painful.
SOA and the Enterprise Service Bus
Service-Oriented Architecture (2000s) exposed enterprise capabilities as services, typically wired through an ESB that does routing, protocol mediation (SOAP, MQ, ISO 8583, fixed-width files), message transformation to a canonical data model, and sometimes long-running orchestration.
Why banks still have it: dozens of vendor systems that speak different protocols, a core that cannot be changed, and a need for central security and audit. The ESB is "smart pipes"; microservices famously prefer "smart endpoints and dumb pipes" (Lewis & Fowler, 2014).
Problems at scale: the ESB team becomes a bottleneck for every change; business logic hides inside transformation flows; the bus is a single point of failure and a performance ceiling on salary day. Modern bank architectures typically keep a thin integration layer for legacy protocols, move channel-facing APIs to an API gateway plus domain services, and use event streaming (Kafka, often fed by CDC from the core) for data distribution. See Legacy Modernization & Migration.
Event-driven architecture
Components communicate by publishing events ("PaymentSettled") to a broker; consumers react independently. The producer does not know who listens.
- Buys: loose coupling, easy fan-out (fraud, notifications, analytics, loyalty all consume the same event), buffering of load spikes, natural audit trail.
- Costs: eventual consistency, harder debugging ("who reacted to this and why?"), ordering and duplicate-delivery handling, schema evolution.
- Deep dive: Event-Driven Architecture, CQRS & Event Sourcing.
Serverless
Functions (AWS Lambda, Google Cloud Functions/Cloud Run functions, Azure Functions) and managed services (queues, DB, API gateway) with no servers to manage; you pay per invocation and duration.
- Good for: spiky or low-volume workloads, glue code, file processing (e.g. daily settlement file reconciliation), scheduled jobs, webhooks from payment providers.
- Weaknesses: cold starts (varies by runtime and provider), execution time limits, vendor lock-in, hard-to-predict cost at sustained high throughput, limited control over networking (a concern for bank network segmentation), harder local testing.
- Cost note: at steady high load, always-on containers are often cheaper than per-invocation pricing. Amazon Prime Video published a 2023 case where moving one monitoring workload from a serverless/step-function design to a single service reportedly cut its cost substantially.
Space-based architecture
Designed for extreme, unpredictable concurrent load where the database would be the bottleneck. Described in detail by Richards & Ford.
Processing units hold the working data set in a replicated in-memory data grid (e.g. Hazelcast, Apache Ignite); writes reach the database asynchronously via data pumps and writers. The database is removed from the synchronous path.
- Good for: ticketing, auctions, flash-sale reservation bursts where the hot data set is small.
- Weaknesses: data collisions between replicas, complex consistency, high memory cost, hard to test; not appropriate as the system of record for money.
Cell-based architecture
Partition the whole stack into independent copies (cells), each serving a subset of customers. A thin router sends each request to its cell.
- Buys: a bad deploy, poison message or overloaded DB affects one cell's customers, not everyone; cells have a known, tested maximum size, so scaling means adding cells; deployments roll out cell by cell.
- Costs: a routing layer that must be extremely reliable; cross-cell operations (a transfer between customers in different cells) need careful design; migrating customers between cells; more infrastructure overhead.
- AWS publishes guidance on cell-based architecture in its Well-Architected material, and companies such as Slack have described moving to cellular designs. Banks use similar ideas when they partition by region or customer segment.
Trade-offs
| Style | Deployability | Scalability | Fault isolation | Data consistency | Operational complexity | Team fit |
|---|---|---|---|---|---|---|
| Layered | One unit | Vertical / clone whole app | Low | Easy (local ACID) | Low | 1–2 teams |
| Modular monolith | One unit, modular code | Clone whole app | Low–medium | Easy within module, explicit across | Low | 2–8 teams |
| Microservices | Per service | Per service | High (if async and bulkheaded) | Hard (sagas, eventual) | High | Many autonomous teams |
| SOA / ESB | Per service, bus is shared | Bus can bottleneck | Medium; bus is SPOF | Orchestrated, often XA or compensations | High, centralized | Central integration team + vendors |
| Event-driven | Per consumer | High, buffered | High | Eventual | Medium–high | Teams that can own async flows |
| Serverless | Per function | Automatic, with limits | High per function | Eventual, managed DBs | Low infra, high distributed debugging | Small teams, spiky loads |
| Space-based | Per processing unit | Very high burst | Medium | Weak, async to DB | Very high | Specialist team |
| Cell-based | Per cell | Add cells | Very high (blast radius = 1 cell) | Strong within cell, hard across | High | Large platform orgs |
When each fits
| Context | Reasonable starting style |
|---|---|
| New digital bank product, 2 teams, unclear domain | Modular monolith on a managed Postgres, events via outbox |
| Large bank, vendor core, many channels | Keep a thin integration layer; domain services + API gateway; CDC/event streaming from core |
| E-commerce scale-up, 10+ teams, frequent conflicts in one codebase | Extract microservices along bounded contexts, starting with the most independent (catalog, search, notifications) |
| Settlement file processing, nightly or per-file | Serverless or batch jobs |
| Flash sale reservation for limited stock | Event-driven + in-memory reservation (space-based ideas) in front of the order system |
| Multi-tenant SaaS / very large user base needing blast-radius control | Cell-based |
The "monolith first" argument
Martin Fowler's MonolithFirst (2015) observes that most successful microservice systems started as monoliths that were later split, and that many systems built as microservices from scratch got into trouble. The reasoning:
- You do not know the boundaries yet. Bounded contexts become clear after months of real usage. Moving a function between modules is a refactor; moving it between services is a migration with data, contracts and deployments.
- Microservices have a fixed overhead (platform, CI/CD per service, tracing, contract testing, on-call) that a small team cannot amortize.
- Speed matters most early. A startup needs to find product–market fit, not to scale to millions of users on day one.
The counter-argument (e.g. Stefan Tilkov, Don't start with a monolith, 2015): once a monolith exists, its internal coupling makes clean splitting very hard, so if you do know the domain well (a rewrite of an existing system), start with coarse-grained services.
A practical synthesis: start with a modular monolith with strict boundaries and per-module data ownership, publish domain events via an outbox, and extract a module into a service only when you have a concrete driver — independent scaling, a separate team, a different release cadence, or a compliance boundary (e.g. isolating PCI scope).
In practice
Enforcing module boundaries in a Go modular monolith with internal/:
shop/
cmd/shop/main.go
ordering/
api.go // public: interfaces and DTOs other modules may use
internal/
app/ // use cases
store/ // Postgres repository for schema "ordering"
inventory/
api.go
internal/
app/
store/ // schema "inventory"
// Package inventory is a module of the shop monolith. Other modules may only
// depend on this file; inventory/internal/... is private by Go's import rules.
package inventory
import "context"
type Item struct {
SKU string
Quantity int
}
type Reservation struct {
ID string
OrderID string
Items []Item
}
// API is the module's public contract. If inventory is ever extracted into a
// service, this interface becomes a gRPC client with the same shape.
type API interface {
Reserve(ctx context.Context, orderID string, items []Item) (Reservation, error)
Release(ctx context.Context, reservationID string) error
}
Go refuses to compile an import of shop/inventory/internal/store from shop/ordering/..., so the boundary is enforced by the toolchain rather than by code review.
Numbers to keep in mind (rough): an in-process call costs nanoseconds to microseconds; a same-zone network call costs on the order of hundreds of microseconds to a few milliseconds including serialization; every synchronous hop also multiplies failure probability (see availability math).
Common pitfalls
- Microservices for a small team. Eight engineers, fifteen services, three on-call rotations. Symptom: most effort goes to CI pipelines and debugging the network.
- Distributed monolith. Services share a database or must deploy together. Symptom: a "simple" change needs a release train across five repos.
- Splitting by technical layer. A "database service", a "validation service". Symptom: every feature crosses every service.
- ESB as a business-logic dumping ground. Fee calculation lives in an XSLT transformation. Symptom: nobody can change fees without the integration vendor.
- Serverless for steady high throughput. Symptom: the monthly bill exceeds what a few containers would cost, and cold starts show in p99.
- Cells without a plan for cross-cell operations. Symptom: transfers between customers in different cells become a hand-rolled distributed transaction.
- Big-bang rewrites to a new style. Symptom: two years later, the new system has 60% of the features and the old one is still in production.
Interview angle
- When asked "monolith or microservices?", ask about team count, domain clarity, deployment frequency, scale profile and compliance boundaries before answering. A strong answer often lands on "modular monolith now, with explicit seams; extract X first because…".
- Be ready to draw any style in 30 seconds and name its two biggest failure modes.
- For a bank: show you understand ESBs and why they persist, and propose incremental modernization rather than "replace the ESB with Kafka".
- For e-commerce: discuss peak events — which parts need independent scaling (search, product pages, cart) and which do not (admin, reporting).
- Follow-ups: "How would you know it is time to split?", "What would you extract first?", "How do you handle a transaction spanning two services?"
- Red flags: "microservices are always more scalable"; ignoring data ownership; no mention of operational cost; treating serverless as free.
Self-check
1. What distinguishes a modular monolith from a layered monolith?
A layered monolith partitions by technical concern (controllers, services, repositories), so features cut across all layers. A modular monolith partitions by business capability, each module with a public API, private internals and its own tables, with boundaries enforced by tooling. It keeps single-deployable simplicity while preparing clean seams for later extraction.
2. Why do many banks still run an ESB, and what are its main problems?
They integrate many vendor systems (core, cards, CRM, switch gateways) that speak different protocols and formats, and they want central security, routing and audit. Problems: the bus team becomes a bottleneck, business logic hides in transformations, the bus is a shared failure point and performance ceiling, and changes require specialist skills or the vendor.
3. What is the single defining property of a microservice architecture, and how do you test whether you have it?
Independent deployability: each service can be changed and deployed without coordinating releases with others. Test it by asking whether the last ten production changes each touched only one service and deployed alone. If releases regularly require multiple services in lock-step, or services share a database schema, you have a distributed monolith.
4. Scenario: a 25-engineer e-commerce company has a Rails-style monolith; deploys take 2 hours and teams block each other. What do you recommend?
First modularize: identify bounded contexts (catalog, cart, ordering, payment, fulfilment), enforce module boundaries and per-module tables, and fix the deploy pipeline (tests, build caching) since slow deploys are often a pipeline problem. Then extract the module with the clearest independent driver — e.g. search/catalog for independent scaling, or payment for PCI scope isolation — using the strangler fig pattern. Avoid a big-bang split.
5. When is space-based architecture a good fit, and why is it a poor system of record for money?
It fits extreme, bursty concurrency on a small hot data set — ticket sales, auctions, flash-sale reservations — because it removes the database from the synchronous path using replicated in-memory grids. For money, asynchronous persistence and replica collisions mean you can lose or conflict on committed state, which violates the correctness and durability requirements of a ledger.
6. What does a cell-based architecture protect against, and what new problem does it introduce?
It limits the blast radius of failures — bad deploys, poison messages, overloaded databases — to the customers in one cell, and makes scaling a matter of adding tested, fixed-size cells. It introduces routing as a critical component and makes cross-cell operations (transfers between customers in different cells, global reporting) significantly harder.
7. Summarize the monolith-first argument and its strongest counter-argument.
Monolith first: boundaries are unknown at the start, wrong service boundaries are very expensive to fix, and microservice overhead slows small teams, so start simple and split later. Counter: monoliths accumulate coupling that makes later splitting hard; if the domain is well understood (e.g. a rewrite), coarse-grained services from the start can be reasonable. A modular monolith with strict boundaries addresses both concerns.
Exercise
You are the architect for a mid-size Vietnamese bank launching a new buy-now-pay-later (BNPL) product sold through e-commerce partners. Constraints: 3 teams initially, integration with the existing core banking system via the ESB, partner checkout traffic spikes 20× during 11.11.
- Choose a starting style and justify it against at least two alternatives in a trade-off table.
- Draw the container-level architecture in Mermaid, showing where the ESB stays and where you bypass it.
- Identify which component(s) need independent scaling for 11.11 and how you would provide it.
- Write the trigger conditions under which you would extract a module into its own service.
Done when: your design fits one page, every arrow has a protocol, and you can explain what fails first at 20× load.
Further reading
- Fundamentals of Software Architecture — Mark Richards & Neal Ford. Chapters on each style, including space-based.
- Software Architecture: The Hard Parts — Ford, Richards, Sadalage, Dehghani (2021). Decomposition and data trade-offs.
- Building Microservices (2nd ed., 2021) — Sam Newman.
- Martin Fowler, "MonolithFirst" (2015) and James Lewis & Martin Fowler, "Microservices" (2014), martinfowler.com.
- Stefan Tilkov, "Don't start with a monolith" (2015), martinfowler.com.
- AWS Well-Architected whitepaper, Reducing the Scope of Impact with Cell-Based Architecture.
- Shopify Engineering blog, "Deconstructing the Monolith".
Related
- Microservices Patterns — making microservices work if you choose them.
- Event-Driven Architecture, CQRS & Event Sourcing — the event-driven style in depth.
- Domain-Driven Design — finding module and service boundaries.
- Legacy Modernization & Migration — moving between styles safely.
- Project Layout & Clean Architecture in Go — structuring the code inside each module.
- E-commerce Platform Overview — where these styles show up in a real platform.
Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).