Data¶
Decide who owns data, how consistent it must be, and how it changes over time.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
- 8 Designing Data-Intensive Applications (Martin Kleppmann): the reference book on storage, replication, partitioning, transactions and stream processing.
- 8 microservices.io data management patterns (Chris Richardson): database per service, saga, outbox, CQRS and API composition.
- 7 Consistency models (Jepsen): precise definitions of what each consistency level guarantees.
Key rules¶
- 9
DATA-1Give each service or module exclusive ownership of its data. Other parts of the system go through its API, not its tables. (microservices.io, Database per service) - 9
DATA-2Evolve database schemas through small, versioned migrations kept in source control. (Sadalage/Fowler, Evolutionary Database Design) - 9
DATA-8Set recovery point and recovery time objectives for each data store, back up to meet them with copies kept outside the primary system, and test restores regularly. A backup that has never been restored may fail when you need it. Platform examples:PG-11,PG-12,REDIS-12andAWS-6. (Google SRE book, Data Integrity) - 8
DATA-9Assume every message can arrive more than once: acknowledge it only after processing it, and make consumers idempotent, for example by recording the IDs of processed messages. Platform examples:KAFKA-7,RABBITMQ-2andRABBITMQ-3. (microservices.io, Idempotent Consumer, Enterprise Integration Patterns, Idempotent Receiver) - 7
DATA-3Keep data consistent across services with sagas, not distributed transactions. (microservices.io, Saga, Azure, Saga pattern) - 7
DATA-4Publish events atomically with state changes using a transactional outbox. (microservices.io, Transactional outbox) - 7
DATA-5Choose the consistency level per use case and make eventual consistency visible in the design. (Vogels, Eventually Consistent, Jepsen, Consistency models) - 7
DATA-10Load the related data that an operation needs in one query or one batched request, not with a query per item (the N+1 problem), and check how many queries each operation makes when you test or profile it. Object-relational mappers can hide the problem by fetching child records one at a time. Platform examples:LARAVEL-11,SPRING-10andGQL-13. (Azure Architecture Center, Chatty I/O antipattern, How to detect the problem) - 6
DATA-6Choose storage technology per need, but count the operational cost of every extra datastore. (Fowler, Polyglot Persistence) - 3
DATA-7At organisational scale, treat analytical data as a product owned by domain teams (data mesh). (Dehghani, Data Mesh Principles)
Tutorials and further reading¶
- 8 Designing Data-Intensive Applications: the book's site, with resources.