## Notes [7 Distributed Systems Patterns](https://www.youtube.com/watch?v=nH4qjmP2KEE&list=PLCRMIe5FDPsd0gVs500xeOewfySTsmEjf&index=26) ## Ambassador Pattern Separate code that handles common functions such as - logging - monitoring - handling retries It - reduces latency - enhances security - improve overall architecture ## Circuit Breaker It's like shutting off a water main if there's a leak. It prevents cascading errors early, which would normally block request/response traffic. ## Command-Query Responsibility Segregation Separates reads from writes to a database. Good for when there's a big difference between number of reads and number of writes. Lots of reads can have their own replica, while lots of writes can provide eventual consistency to the read database. ## Event Sourcing Like Git for source control. ## Leader Election When the default leader fails, the existing nodes can elect a replacement. `etcd` and `Zookeeper` follow this pattern. ## Pub/Sub Kind of like using queues, publishers can write messages to a variety of message queues, and consumers will listen to those messages from those queues. Good for propagating changes or updates. ## Sharding Each shard contains a subset of the overall data and reduces load on any single node. ## Strangler Like the strangler tree, gradually wrap services around a monolith to migrate components of the system until it is entirely replaced.