Systems Design Flashcards
CAP Theorem
No distributed system is safe from network failures, thus network partitioning generally has to be tolerated.
In the presence of a partition, one is then left with two options: consistency or availability.
When choosing consistency over availability, the system will return an error or a time out if particular information cannot be guaranteed to be up to date due to network partitioning.
Consistency
reads are always up to date, which means any client making a request to the database will get the same view of data
Availability
database requests always receive a response (when valid)
Meaning of CAP Theorem
Consistency – that reads are always up to date, which means any client making a request to the database will get the same view of data.
Availability – database requests always receive a response (when valid).
Partition tolerance – that a network fault doesn’t prevent messaging between nodes.
In the context of distributed (NoSQL) databases, this means there is always going to be a trade-off between consistency and availability. This is because distributed systems are always necessarily partition tolerant (ie. it simply wouldn’t be a distributed database if it wasn’t partition tolerant.)
Long Polling vs Short Polling
In almost all cases, Amazon SQS long polling is preferable to short polling. Long-polling requests let your queue consumers receive messages as soon as they arrive in your queue while reducing the number of empty ReceiveMessageResponse instances returned.