// 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.
14 rules of 70 · Clear filters
Security
- Every caller is authenticated
The design says how the service knows who is calling, for users and for other services.
CriticalChecked automatically
- Secrets live in a secret store
Credentials and keys are read from a secret manager at run time, never from the repository or plain configuration.
CriticalChecked automatically
- Access is authorized per resource
The design says how the service decides what an authenticated caller may do, down to the individual resource.
HighChecked automatically
- Input is validated at the service boundary
Every request and message is checked against a schema before any logic runs, whoever sent it.
HighChecked by hand
- Personal data handling is documented
For the personal data it holds, the service states what it keeps, why, for how long and how it is erased.
HighChecked by hand
- Personal data stays out of logs and traces
Logs, traces, metrics and error reports carry ids, not names, emails, addresses, tokens or card data.
HighChecked by hand
- Service-to-service calls are authenticated
A call from another service proves who is calling, with mTLS or a signed token. Being inside the network is not proof.
HighChecked by hand
- The gateway states how it authenticates callers
Every API gateway in front of the service names its authentication method, so nobody assumes the other side is doing it.
HighChecked automatically
- Callers are rate limited
Each caller has a request quota, enforced at the gateway or in the service, so one client cannot exhaust it for everyone.
MediumChecked by hand
- Dependencies and images are scanned for known vulnerabilities
Every build checks libraries and the base image against vulnerability databases, and someone owns fixing what is found.
MediumChecked by hand
- Scopes or permissions are declared
The service lists the scopes or permissions its API checks, so callers know what to ask for and reviewers know what is protected.
MediumChecked automatically
- Secrets can be rotated without a release
Every secret the service uses can be replaced on a schedule, or within the hour after a leak, without a code change.
MediumChecked by hand
- Sensitive actions leave an audit trail
The service records who did what to what, and when, for actions that matter in a dispute or an investigation.
MediumChecked by hand
- The database account has only the rights it needs
The service connects to its data store with an account limited to its own schema and to the operations it performs.
MediumChecked by hand