mirror of
				https://github.com/donnemartin/system-design-primer.git
				synced 2025-11-04 02:02:31 +03:00 
			
		
		
		
	Add Availability vs consistency section
This commit is contained in:
		
							
								
								
									
										34
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								README.md
									
									
									
									
									
								
							@@ -557,3 +557,37 @@ Generally, you should aim for **maximal throughput** with **acceptable latency**
 | 
			
		||||
### Source(s) and further reading
 | 
			
		||||
 | 
			
		||||
* [Understanding latency vs throughput](https://community.cadence.com/cadence_blogs_8/b/sd/archive/2010/09/13/understanding-latency-vs-throughput)
 | 
			
		||||
 | 
			
		||||
## Availability vs consistency
 | 
			
		||||
 | 
			
		||||
### CAP theorem
 | 
			
		||||
 | 
			
		||||
<p align="center">
 | 
			
		||||
  <img src="http://i.imgur.com/bgLMI2u.png">
 | 
			
		||||
  <br/>
 | 
			
		||||
  <i><a href=http://robertgreiner.com/2014/08/cap-theorem-revisited>Source: CAP theorem revisited</a></i>
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
In a distributed computer system, you can only support two of the following guarantees:
 | 
			
		||||
 | 
			
		||||
* **Consistency** - Every read receives the most recent write or an error
 | 
			
		||||
* **Availability** - Every request receives a response, without guarantee that it contains the most recent version of the information
 | 
			
		||||
* **Partition Tolerance** - The system continues to operate despite arbitrary partitioning due to network failures
 | 
			
		||||
 | 
			
		||||
*Networks aren't reliable, so you'll need to support partition tolerance.  You'll need to make a software tradeoff between consistency and availability.*
 | 
			
		||||
 | 
			
		||||
#### CP - consistency and partition tolerance
 | 
			
		||||
 | 
			
		||||
Waiting for a response from the partitioned node might result in a timeout error.  CP is a good choice if your business needs require atomic reads and writes.
 | 
			
		||||
 | 
			
		||||
#### AP - availability and partition tolerance
 | 
			
		||||
 | 
			
		||||
Responses return the most recent version of the data, which might not be the latest.  Writes might take some time to propagate when the partition is resolved.
 | 
			
		||||
 | 
			
		||||
AP is a good choice if the business needs allow for [eventual consistency](#eventual-consistency) or when the system needs to continue working despite external errors.
 | 
			
		||||
 | 
			
		||||
### Source(s) and further reading
 | 
			
		||||
 | 
			
		||||
* [CAP theorem revisited](http://robertgreiner.com/2014/08/cap-theorem-revisited/)
 | 
			
		||||
* [A plain english introduction to CAP theorem](http://ksat.me/a-plain-english-introduction-to-cap-theorem/)
 | 
			
		||||
* [CAP FAQ](https://github.com/henryr/cap-faq)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user