Leer en español · Lire en français · Auf Deutsch lesen
Section 6.2 of 6.8 · Intermediate · 22 min read
Service-based architecture and service-oriented architecture
Video lesson
6 min · narrated, with captionsListen only (audio)
Read the transcript
Many real systems sit between one monolith and many microservices. In this lesson you'll meet service-based architecture, the pragmatic middle ground, and the older service-oriented architecture it's often confused with.
Think of a hospital that outgrows one building. It could split into hundreds of tiny clinics, each with its own reception and records office. Or it could move into five departments in separate wings: maternity, surgery, outpatients, pharmacy, and accident and emergency. Each wing has its own staff, and can be refurbished without closing the others. But they still share one central records office. That's service-based architecture: a few big, separate parts, each looking after a whole area of the business, often still sharing one database.
Service-based architecture splits a system into a few separately deployed, coarse-grained domain services, typically between four and twelve. Each covers a whole business area, such as ordering or payments. Two things follow. Most workflows run inside one service, so they can use an ordinary local database transaction, with full ACID guarantees: atomic, consistent, isolated and durable. And the services rarely call each other, which keeps synchronous chains short.
Here's a food-delivery platform built this way. At the top are four user interfaces: the customer app, the restaurant tablet, the courier app and an operations portal. They call an optional API layer, a reverse proxy or gateway, which handles routing, authentication and rate limits. Behind it are five domain services. Each is coarse-grained, with everything its domain needs, from the API to the data access, and each is owned by one team. Four of them share one PostgreSQL database, with a schema each, and each service may touch only its own. Sharing makes the style cheap and simple, but it's also its main weakness, because schema changes must be coordinated. Payments keeps its own database, because card data gives it a strong reason, so it can be audited alone. Giving a service its own store only when that's justified is one way to tame the shared database.
Why choose this? Imagine the company has grown to five teams, about thirty five engineers. Its monolith is well organised, but releases have become a queue, and a fault in courier tracking took down checkout twice. With five domain services, placing an order runs inside the ordering service in one local transaction, then makes one call to payments. The other services learn about the order from a message, not a chain of calls. It buys five separate release pipelines. A tracking fault no longer stops checkout, and each team releases when it's ready. It costs five sets of deployments and dashboards, timeouts and idempotency on the calls to payments, and schema changes that still need coordinating. The step is modest on purpose.
Service-based architecture is often confused with the older service-oriented architecture, or SOA. Its central idea was sound: business capabilities exposed as services with explicit contracts. But what most enterprises built was arranged in technical layers. At the top, business services describe processes, such as place order or open account. At the centre sat an enterprise service bus, or ESB. It routed messages, transformed them between formats and, through an orchestration engine, ran the business processes itself. Below it, shared enterprise services, such as customer and pricing, were meant to be reused everywhere, and they in turn wrapped existing systems. And every message was translated to and from one canonical data model: a single enterprise-wide definition of each business entity.
Many SOA programmes disappointed. First, reuse created coupling. A shared customer service used by forty applications couldn't change without forty consumers agreeing. Second, the bus became the bottleneck. Almost every business change needed the one team that owned it, and it became a single point of failure. Third, the canonical model was too big. One definition of a customer that suits sales, billing, support and logistics is either enormous or wrong for most of them. And the web-service standards were complex, with expensive tooling. Microservices keep explicit contracts but reverse most of those choices: smart endpoints and dumb pipes, with all the logic in the services and each service owning its data.
So when is service-based architecture the right choice? When the system has a few clear business domains, and two to perhaps eight teams need to release independently. When most workflows stay inside one domain, and strong consistency within a domain is valuable. It's also an excellent step out of a monolith: far less risky than leaping to fifty microservices, and often good enough to stop there. Plan to move beyond it when parts need very different scaling, when the shared database limits writes, or when services keep calling each other for ordinary requests. That's a sign the boundaries are wrong.
The full section compares service-based architecture, SOA and microservices side by side. Next, in Section six point three, we look at microservices. See you there.
What you need to know
- Service-based architecture (named by Richards and Ford) splits a system into a few separately deployed, coarse-grained domain services, typically 4 to 12, usually sharing one database and often behind an API layer.
- Because most workflows stay inside one domain service, they can use local ACID transactions, and services rarely call each other, which keeps synchronous chains short.
- A shared database couples schema changes and binds the services into one quantum; per-service schemas, small per-domain entity libraries and separate databases where justified reduce that coupling.
- Classic orchestration-driven SOA arranged services in technical layers around an enterprise service bus, with a canonical data model and WS-* standards, aiming at enterprise-wide reuse.
- SOA disappointed because reuse created coupling, the bus became a bottleneck owned by one team, canonical models fitted nobody and the standards were heavy.
- Microservices keep explicit service contracts but put the logic in the services (smart endpoints, dumb pipes), organise by business capability and give each service its own data.
- Service-based architecture is a pragmatic middle ground for a few domains and teams, and a low-risk step out of a monolith.
Between the monolith and microservices
Much of the industry conversation presents a choice between one monolith and many microservices. In practice a large share of real systems sit in between: a handful of separately deployed services, each covering a whole business area, often still sharing one database. Mark Richards and Neal Ford named this style service-based architecture in Fundamentals of Software Architecture and argue that it is one of the most pragmatic distributed styles available. This section describes it, contrasts it with the older service-oriented architecture (SOA) that it is often confused with, and shows where microservices differ from both.
Service-based architecture: the topology
A service-based system has three parts. One or more user interfaces call a set of separately deployed domain services, each covering a large, coherent business area such as ordering or payments. Richards and Ford observe that such systems usually have between 4 and 12 domain services, about 7 on average. The services usually share a database, and an optional API layer (a reverse proxy or gateway) may sit between the user interfaces and the services to handle routing, authentication and rate limiting.
Each domain service is coarse-grained: it contains everything needed for its domain, from the API to the business logic to the data access, and it is internally structured like a small monolith, often in layers or in modules (Chapter 5). A service is typically deployed as a few instances behind a load balancer.
Two consequences follow. First, most business workflows run entirely inside one service, so they can use an ordinary local database transaction with full ACID guarantees (Chapter 0). Second, domain services rarely need to call each other: a request from the user interface goes to the one service that owns the domain. This keeps synchronous chains short, which matters for the reasons calculated in Section 6.1.
The shared database and how to tame it
Sharing a database is what makes service-based architecture cheap and simple: no data synchronisation between services, no eventual consistency, reporting by ordinary SQL. It is also its main weakness. If every service reads and writes the same tables, a change to one table's columns may break several services, all of which must then be tested and redeployed together. Chapter 5's definition applies: services sharing a database are bound into one architecture quantum, so they share one level of availability and one schema release cadence.
Practitioners use three techniques to reduce the coupling. The first is logical partitioning: give each service its own schema (or set of tables) and forbid it to touch anyone else's, enforced by database permissions as well as by convention. The second is to keep the shared database's entity classes in small, per-domain libraries rather than one large shared library, so that a change to restaurant tables only affects the services that use them. The third is to give a service its own database when it has a strong reason, such as security scope, a very different load pattern or a different kind of data store. Teams that apply these consistently find that a later move to separate databases, if it ever becomes necessary, is much easier.
The food-delivery platform as five domain services
Worked example
Worked example: the food-delivery platform as five domain services
A food-delivery company has grown from one team to five, about 35 engineers. Its Django monolith is well modularised, but releases have become a queue and a fault in courier tracking took down checkout twice last quarter. The architect proposes a service-based architecture with five domain services, one per existing module and team.
| Ordering | Basket, checkout, order lifecycle and status. Owns the ordering schema. Busy at meal times; runs 6 to 20 instances. |
|---|---|
| Restaurant | Menus, prices, opening hours, restaurant onboarding. Read-heavy; menus are cached at the API layer. Runs 3 instances. |
| Delivery | Courier dispatch, route estimates, live tracking. Receives location updates every few seconds from every active courier, so it is scaled separately from everything else. |
| Payments | Card authorisation through the payment provider, refunds, restaurant and courier payouts. Has its own database so that the scope of the PCI DSS assessment is one small service rather than the whole platform. |
| Customer | Accounts, addresses, support tickets, reviews. Low load, but holds most personal data, so access and retention rules are concentrated here. |
| How a workflow runs | Place order runs inside Ordering in one local transaction (create order, reserve the restaurant's slot), then makes one call to Payments. Restaurant and Delivery learn about the order from a message, not a chain of calls. |
| What is shared | One PostgreSQL server with a schema per service. Each service may only read and write its own schema; a few read-only views (restaurant names, for example) are published for the others. |
| What it buys | Five deployment pipelines instead of one; a fault in tracking no longer stops checkout; payments can be audited alone; each team releases when ready. |
| What it costs | Five deployables and dashboards instead of one; network calls between Ordering and Payments that need timeouts and idempotency; schema changes still coordinated through the shared database server. |
The step is modest on purpose. It moves from one quantum to roughly two (Payments with its own data, and the four services sharing the database), and it gives each team its own release, which was the main pain.
If Delivery's location stream later outgrows the shared database, that one service can be given its own store and split further; the rest can stay as they are.
The architect writes the boundary rules down as architecture tests: no service may query another's schema, and services may call each other only through published APIs.
Classic service-oriented architecture
Service-oriented architecture is older and broader. The term entered the industry through a 1996 Gartner report by Roy Schulte and Yefim Natis, and from the early 2000s it became the dominant model for enterprise integration. Its central idea was sound: expose business capabilities as services with explicit, technology-neutral contracts, so that applications across a large organisation can be assembled from them instead of being rebuilt or integrated point to point.
What most enterprises actually built, however, was what Richards and Ford call orchestration-driven SOA. Services were arranged in technical layers: business services describing processes (place order, open account), shared enterprise services providing reusable capabilities (customer, pricing, invoice), and application and infrastructure services wrapping existing systems and technical concerns. At the centre sat an enterprise service bus (ESB): middleware that routed messages, transformed them between formats, mediated between protocols and, through an orchestration engine, ran the business processes themselves.
Two further ideas completed the picture. A canonical data model defined one enterprise-wide representation of each business entity (one Customer, one Order), and every message was translated to and from it in the bus. And a family of web-service standards, usually called WS-*, defined how services described and called each other: SOAP for messages, WSDL for interface descriptions, UDDI for registries, WS-Security, WS-ReliableMessaging and WS-AtomicTransaction for qualities, and WS-BPEL (version 2.0 approved by OASIS in 2007) for executable process definitions.
Orchestration-driven SOA
Why classic SOA fell out of favour
By the late 2000s many SOA programmes had disappointed. Anne Thomas Manes of the Burton Group captured the mood in a widely read January 2009 post titled SOA is Dead; Long Live Services: the label had become toxic, but the idea of services survived. The reasons are worth knowing, because each is a trap that modern architectures can fall into again.
Reuse created coupling. A shared enterprise Customer service used by forty applications could not change without forty consumers agreeing; reuse, the main goal, turned every change into a negotiation. The bus became the bottleneck. Putting routing, transformation and process logic into a central ESB, usually owned by one integration team, meant that almost every business change needed that team, and the bus became a single point of failure and of delay. The canonical model was too big. One definition of Customer that satisfies sales, billing, support and logistics is either enormous or wrong for most of them; Chapter 5's bounded contexts explain why a term legitimately means different things in different parts of a business. The standards were heavy. WS-* specifications were complex, tooling was expensive, and distributed transactions across services proved fragile. Technical partitioning meant a simple feature crossed several layers of services owned by different groups.
The lasting lessons are the ones microservices were built on: explicit service contracts, services owned by the people who build them, logic in the services rather than in the middleware, and data owned by one service rather than shared across the enterprise.
How microservices differ
Microservices, covered in depth in the next section, keep SOA's idea of services with explicit contracts and reverse most of its implementation choices. James Lewis and Martin Fowler summarised one reversal as smart endpoints and dumb pipes: the network only transports messages, and all logic lives in the services. Services are organised around business capabilities rather than technical layers, reuse is deliberately secondary to independence, each service owns its data, and governance is decentralised.
Compared with service-based architecture, microservices are finer-grained, far more numerous, and insist on separate data. That buys more independence, more targeted scaling and more fault isolation, and it costs much more in operations, consistency and coordination. Service-based architecture can be seen as the point on the spectrum where most of the deployment and team benefits arrive for a fraction of the cost.
Service-based architecture, classic SOA and microservices compared
| Aspect | Service-based | Classic (orchestration-driven) SOA | Microservices |
|---|---|---|---|
| Main goal | Pragmatic modularity and independent deployment of a few domain areas | Enterprise-wide reuse of shared services | Independent change and deployment by many autonomous teams |
| Partitioning | Domain: one service per large business area | Technical: business, enterprise, application and infrastructure layers | Domain: one service per bounded context or smaller |
| Typical number | About 4 to 12 per system | Dozens to hundreds across an enterprise | Tens to hundreds per system |
| Granularity | Coarse: a whole domain, for example all of ordering | Mixed; shared enterprise services are often fine-grained | Fine to medium: one cohesive capability |
| Data | Often one shared database, ideally partitioned by schema | Shared systems of record behind enterprise services | Each service owns its data; no shared tables |
| Communication | Mostly from the user interface to one service; few calls between services | Through the enterprise service bus, usually SOAP or XML messaging | Lightweight HTTP, gRPC or messaging; smart endpoints, dumb pipes |
| Where the logic lives | Inside the domain services | Much of it in the bus: routing, transformation, orchestration | Inside the services; the network only transports |
| Transactions | Local ACID transactions within a domain service | Distributed transactions attempted (WS-AtomicTransaction, XA) | No distributed transactions; sagas and eventual consistency |
| Governance | Light; one architecture team is enough | Central and heavy: canonical model, service registry, standards board | Decentralised; shared platform and paved roads |
| Operational cost | Moderate | High, plus expensive middleware licences | High: many deployables, pipelines and on-call rotas |
Characteristics of service-based architecture
| Characteristic | Rating | Reason |
|---|---|---|
| Deployability | Medium to high | Each domain service is deployed on its own, so a change to menus does not redeploy payments; a shared schema change still needs coordination. |
| Fault tolerance | Medium to high | A crash in the delivery service leaves ordering and payments running; a shared database is still a common point of failure. |
| Scalability | Medium | Services scale separately, but each is coarse, and the shared database limits how far writes can scale. |
| Elasticity | Low to medium | Large services start slowly and scale in big steps, so sudden spikes are absorbed less gracefully than with small services. |
| Data consistency | High | Most business workflows stay inside one service, where an ordinary database transaction keeps data consistent. |
| Simplicity | Medium | Far fewer moving parts than microservices; still a distributed system with network calls, deployment pipelines and monitoring per service. |
| Overall cost | Medium (moderate) | A handful of services and one database are cheap to run compared with dozens of services and databases. |
| Testability | Medium to high | Each service has a smaller scope than the monolith and can be tested on its own against its schema. |
| Evolvability | Medium | Domain partitioning keeps typical changes inside one service, but the shared database couples schema evolution. |
When service-based architecture is the pragmatic middle ground
Choose it when the system has a few clear business domains, when two to perhaps eight teams need to release independently, when most workflows naturally stay inside one domain, and when strong consistency within a domain is valuable. It is also an excellent migration step out of a monolith: carving a well-modularised monolith into a handful of domain services is far less risky than leaping to fifty microservices, and the result is often good enough to stop there.
Avoid it, or plan to move beyond it, when parts of a domain need very different scalability or availability (they belong in separate quanta), when dozens of teams need autonomy, when the shared database has become the bottleneck for writes, or when the domain services keep calling each other to complete ordinary requests, which is a sign that the boundaries are wrong.
Check your understanding
Why can most workflows in a service-based architecture use an ordinary database transaction?
Because each domain service covers a whole business area and the workflow usually stays inside it, touching only data in that service's own schema in one database.
What made the enterprise service bus a bottleneck in many SOA programmes?
Routing, transformation and process logic lived in the bus, typically owned by one central team, so most business changes needed that team and the bus was a shared point of failure.
Name two techniques that reduce the coupling caused by a shared database.
Giving each service its own schema and forbidding access to others (enforced by permissions), and splitting entity classes into small per-domain libraries; also giving a service its own database where justified.
What does 'smart endpoints and dumb pipes' reverse compared with classic SOA?
It moves logic out of the middleware (the ESB) and into the services, leaving the network to transport messages only.
Sources and further reading
- James Lewis and Martin Fowler: Microservices (2014), on smart endpoints and dumb pipes
- OASIS: Reference Model for Service Oriented Architecture 1.0
- W3C: Web Services Architecture (Working Group Note)
- OASIS: Web Services Business Process Execution Language Version 2.0
- Enterprise Integration Patterns: messaging patterns catalogue
Have a question about this section? ArchitectBot, the course’s AI study assistant, answers from the course first.
Ask: “We have a modular monolith and four teams. Should we move to service-based architecture or straight to microservices, and what should we do about the shared database?”