DEV Community

Siddhant Khare
Siddhant Khare

Posted on

Consistency v/s Availability

Let's take the following example, where S and A desire to work together on an online document.

Always consistent but not always available

One method is to lock the document while one person is working on it to stop the other person from working on it concurrently. This method is adopted by WordPress.

The disadvantage of this is that only one person may work on the document at a time when it is locked, preventing anyone else from editing it.

This ensures that the document is consistently available but not always available.

Both WordPress & MSFT SharePoint adopt this strategy

Always available, but not always consistent

Another strategy is to let both sides collaborate on the paper simultaneously. This is how Google Docs operates.

Conflicts could arise, and occasionally someone's work might be overwritten, as a result of this system.

This method ensures that the document is constantly available but is not always consistent.

Conclusion

Due to the unpredictability of network stability, partition tolerance in distributed systems is non-negotiable. As a result, an application must decide between availability and consistency.

A service could:

  • high availability by returning data that may be stale or high consistency by blocking any requests (not available) to the data until they are addressed (not consistent)

  • Both strategies include trade-offs, and the best choice relies on what's crucial for your application.

For example, an Amazon Cart's high availability is more crucial. However, the balance of a bank account must always remain consistent.

Discussion (0)