// RULES
Microservice rules
Best practices for microservices, one rule per page: why it matters, how to apply it and an example. They are grouped into checklists you can apply to a service.
6 rules of 70 · Clear filters
Data
- Backups exist and a restore has been tested
The data store is backed up automatically, and the team has restored from a backup recently enough to trust it.
HighChecked by hand
- Each saga has compensating steps
For every step of a saga that can be followed by a failure, there is a defined action that undoes it.
HighChecked automatically
- No transaction spans services
A business operation that changes several services is a sequence of local transactions with compensation, not a two-phase commit.
HighChecked by hand
- Other services' data is reached through their API or events
The service never reads another service's tables, files or cache. It calls the owner or keeps its own copy built from the owner's events.
HighChecked by hand
- Schema changes are backward compatible
A database migration never breaks the version of the service that is running: expand first, migrate, contract later.
HighChecked by hand
- The service owns its data and says what it holds
Each data store belongs to this service alone, and the design says what is kept in it.
HighChecked automatically