Video in progress

Where should you draw a service boundary: by technical layer or by business capability?

By business capability: "orders", "payments", "delivery". Splitting by technical layer (a controller service, a DAO service) forces you to change every service together on each change.

📖 Answer

The wrong version often looks like this: api-service (controllers), logic-service, db-service. To add one new field you have to change all three services and deploy all three together. This split gives you nothing.

The right way is to look at the business question: "what does this part do, and who changes it?"

Service What it's responsible for
catalog products, prices, search
order the cart, order status
payment payments, refunds

Signs of a good boundary:

  • most changes stay inside one service;
  • the service owns its data and doesn't touch another's database;
  • there are few calls between services.

If two services call each other dozens of times on every request, they probably should be one service.