Basada en Servicios

Servicios de grano grueso

Escrito por Darjus Kazakevic · revisado el

A few coarse services, often over one shared database.

Service-based architecture splits a system into a few coarse services, typically 4 to 12. Each one covers a whole business area, such as orders or billing, and deploys on its own. Unlike microservices, the services often share one database, so you keep local transactions and joins.

It is a common next step after a modular monolith: the same module boundaries, now as separate deployables. The shared database is the main cost. All services share its capacity, and a careless schema change can break several of them. One schema per service keeps the ownership clear.

En esencia — Deploy each business area on its own but keep one database, with a schema per service, so you get separate releases without sagas.

Cuándo recurrir a él

Recurre a él cuando

  • Teams wait on one release, but dozens of services would be too much
  • You want separate deploys but still local transactions and joins
  • You are moving out of a modular monolith, one business area at a time

Reconsidéralo cuando

  • One team ships fine from one deployable; a modular monolith is cheaper
  • One service's load must never slow the others, even at the database
  • Each team needs its own data store and tech stack (that is microservices)

How it is built

Domain services
Each service covers a whole business area: orders, catalogue, billing. It is coarse enough that most requests stay inside one service and one transaction.
Shared database, separate schemas
Services often share one database instance. Each service owns its own schema (a named group of tables) and never touches another service's tables.
Independent deploys
Each service has its own build and release. A billing fix ships without redeploying orders. This is the main gain over a monolith.
Optional API layer
A thin gateway or reverse proxy, such as NGINX, routes client requests to the right service and handles shared concerns like authentication in one place.

Keeping it simple

Give each service its own schema
One database instance is fine; shared tables are not. A service writes only its own schema and asks other services for the rest over their API.
Keep the services coarse
Split along whole business areas, so a normal write stays inside one service and one transaction. If one action needs two services, the boundary is probably wrong.
Change service APIs only by adding
Add fields; never rename or remove one in place. Then services can deploy in any order, which is the whole point of splitting them.
Watch the shared database
Every service shares its CPU and connections, so one heavy report can slow all of them. Move heavy reads to a read replica, or give a service its own database when it needs one.

Errores habituales

  • Services that read each other's tables, so every schema change needs every team
  • Splitting too fine, so one user action calls five services and needs a saga
  • Breaking a service API, which forces all callers to deploy at the same time
  • One reporting query that locks tables and slows every service at once