Java Data across services

Each service owning its data is the point of the architecture, and it removes the join and the transaction you used to rely on.

3 concepts · 9 interview questions

What this topic covers

Every concept in data across services, and the questions each one gets asked as. Where a question links, it has a full write-up.

Sagas and compensation

A business transaction spanning services becomes a sequence of local transactions, each with a compensating action for when a later step fails.

  • How do you handle a transaction that spans three services?
  • Choreography or orchestration?
  • What makes a good compensating action?

Consistency and CAP

During a partition a distributed system chooses between refusing requests and serving possibly stale data. Most systems choose availability and then have to explain staleness to users.

  • What does CAP actually say, and how is it usually misquoted?
  • What is eventual consistency, and how do you design a UI around it?
  • When do you genuinely need strong consistency?

Queries that used to be a join

With data split across services, a screen that used to be one SQL query becomes several calls or a maintained read model.

  • How do you build a screen that needs data from four services?
  • What is CQRS, and when is it worth the complexity?
  • Is a shared database between two services ever acceptable?

More in Microservices and APIs

See the whole reference map →