0
0
LLDsystem_design~10 mins

Availability checking in LLD - Interactive Code Practice

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

Complete the code to check if a service is available by pinging it.

LLD
def is_service_available(url):
    response = ping(url)
    return response.status_code == [1]
Drag options to blanks, or click blank then click option'
A500
B404
C302
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means not found
Using 500 which means server error
2fill in blank
medium

Complete the code to retry checking availability if the first ping fails.

LLD
def check_with_retry(url, retries):
    for _ in range(retries):
        if is_service_available(url):
            return True
    return [1]
Drag options to blanks, or click blank then click option'
ANone
BTrue
CFalse
DException
Attempts:
3 left
💡 Hint
Common Mistakes
Returning True even if service is down
Returning None which is ambiguous
3fill in blank
hard

Fix the error in the code to handle timeout exceptions during availability check.

LLD
def safe_check(url):
    try:
        return is_service_available(url)
    except [1]:
        return False
Drag options to blanks, or click blank then click option'
ATimeoutError
BValueError
CKeyError
DIndexError
Attempts:
3 left
💡 Hint
Common Mistakes
Catching ValueError which is unrelated
Catching KeyError which is for dicts
4fill in blank
hard

Fill both blanks to implement exponential backoff in retry logic.

LLD
def retry_with_backoff(url, retries):
    delay = 1
    for _ in range(retries):
        if is_service_available(url):
            return True
        time.sleep([1])
        delay = delay [2] 2
    return False
Drag options to blanks, or click blank then click option'
Adelay
Bdelay + 2
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 2 instead of multiplying
Using a fixed delay without change
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps service names to their availability status.

LLD
services_status = [1]: safe_check([2]) for [3] in services_list}
Drag options to blanks, or click blank then click option'
A{service
Bservice
Cservice_name
Dservice}
Attempts:
3 left
💡 Hint
Common Mistakes
Missing curly brace
Using wrong variable names