Consistency Model (Karat)

Difficulty: EASYCategory: HLDFrequency: 1Asked On 2025-05-01

Problem Statement

Which consistency model is more appropriate for each of these applications: strong or eventual consistency? Why?

1.An API call that needs to respond within 20 milliseconds, used to retrieve meta video stream. The metadata includes things like the author name, rating, and view
2.A web analytics platform recording every single click on a popular web page.
3.A banking system that makes deposits and payments to checking accounts.


Solution

1. API call retrieving video stream metadata (e.g., author name, rating, view count)

📌 Recommended Consistency: Eventual Consistency

Why:

•The data (like view count or author name) is not critical to be absolutely up-to-date within milliseconds.
•Prioritizing low-latency (under 20ms) favors a distributed system with eventual consistency, where stale but fast reads are acceptable.
•Real-time accuracy is less important than speed and availability.


2. Web analytics platform tracking every click

📌 Recommended Consistency: Eventual Consistency

Why:

•High write throughput is required, and losing a few milliseconds of delay in data propagation is acceptable.
•Aggregate trends matter more than exact timing or order of each event.
•Eventual consistency allows for batch processing and delayed updates, improving scalability and performance.


3. Banking system handling deposits and payments

📌 Recommended Consistency: Strong Consistency

Why:

•Financial transactions demand immediate accuracy and correctness.
•Account balances must reflect exact, current state after each operation.
•Race conditions or stale data can lead to duplicate charges or overdrafts, which are unacceptable.


Comments