0
0
HLDsystem_design~10 mins

Consistency models (strong, eventual) in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a consistency model where all reads see the latest write.

HLD
consistency_model = "[1]"  # Ensures all reads see the latest write
Drag options to blanks, or click blank then click option'
Acausal
Beventual
Cstrong
Dweak
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing eventual consistency which allows delays in visibility.
2fill in blank
medium

Complete the code to define a consistency model where updates propagate over time.

HLD
consistency_model = "[1]"  # Updates may not be immediately visible
Drag options to blanks, or click blank then click option'
Astrong
Bsequential
Clinearizable
Deventual
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing with strong consistency which requires immediate visibility.
3fill in blank
hard

Fix the error in the code to correctly represent a strong consistency check.

HLD
if read_value == [1]:  # Check if read matches latest write
Drag options to blanks, or click blank then click option'
Aold_value
Blatest_write
Cany_value
Dstale_value
Attempts:
3 left
💡 Hint
Common Mistakes
Using old or stale values instead of the latest write.
4fill in blank
hard

Fill both blanks to complete the description of eventual consistency behavior.

HLD
while not [1]:  # Wait until [2] is visible to all nodes
    sleep(1)
Drag options to blanks, or click blank then click option'
Aall_nodes_updated
Blatest_update
Cany_node_updated
Dstale_data
Attempts:
3 left
💡 Hint
Common Mistakes
Waiting for only any node to update instead of all nodes.
5fill in blank
hard

Fill all three blanks to complete the code snippet illustrating consistency model selection.

HLD
def select_consistency_model(require_strong):
    if require_strong:
        return "[1]"
    else:
        return "[2]"  # [3] consistency allows delays
Drag options to blanks, or click blank then click option'
Astrong
Beventual
CEventual
DStrong
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing case sensitivity or confusing the models.