Networks aren't reliable, so you'll need to support partition tolerance. You'll need to make a software tradeoff between consistency and availability.

AP is a good choice if the business needs to allow for eventual consistency or when the system needs to continue working despite external errors.

CP is a good choice if your business needs require atomic reads and writes.

image.png

Consistency Pattern

  1. Weak consistent :

    After a write, reads may or may not see it. A best effort approach is taken.

    This approach is seen in systems such as memcached.

    Eg: Video Player, phone call, Live gaming

  2. Eventual Consistency

    After a write, reads will eventually see it (typically within milliseconds). Data is replicated asynchronously.

    This approach is seen in systems such as DNS and email. Eventual consistency works well in highly available systems.

  3. Strong Consistency:

    After a write, reads will see it. Data is replicated synchronously.

    This approach is seen in file systems and RDBMSes. Strong consistency works well in systems that need transactions.

Availablity Pattern

Fail Over

  1. Active Passive

  2. Active-active

    In active-active, both servers are managing traffic, spreading the load between them.

Disadvantages

Replication

  1. Master-slave

    The master serves reads and writes, replicating writes to one or more slaves, which serve only reads. Slaves can also replicate to additional slaves in a tree-like fashion. If the master goes offline, the system can continue to operate in read-only mode until a slave is promoted to a master or a new master is provisioned.