tags: #publish links: [[Software Architecture]] created: 2021-07-09 Fri --- # Single Source Of Truth (SSOT) When working with persistent datastores, pick one location which is the authoritative state. ## What to do Make writes against the source of truth. Make reads against it *if* you actually need that level of consistency. Things which absolutely need the current state - e.g. atomic transactions - need to use the source of truth, or be designed in a way that either guarantees consistency with it or copes with inconsistency. Things which don't actually need the current state - well, you can offload those interactions from the source-of-truth store. Cache things temporarily when consistency is flexible. ## What not to do Make writes somewhere else. Don't, for example, have a downstream system that populates a local store based on info from an upstream system and just assume you'll never need to reconcile. Without consistency guarantees, this will gradually get into an inconsistent mess where downstream doesn't match upstream, and you'll then find that [[Event-based systems with datastores need reconciliation or rebootstrapping]].