0
0
HLDsystem_design~10 mins

Health check endpoints 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 basic health check endpoint that returns a 200 status.

HLD
GET /health [1] 200 OK
Drag options to blanks, or click blank then click option'
Aresponds with
Breturns
Csends
Doutputs
Attempts:
3 left
💡 Hint
Common Mistakes
Using verbs that don't fit HTTP response context like 'responds with' instead of 'returns'.
Not returning any status code.
2fill in blank
medium

Complete the code to add a readiness check endpoint that verifies database connectivity.

HLD
if database.[1]():
    return 200
else:
    return 503
Drag options to blanks, or click blank then click option'
Aping
Bis_connected
Cconnect
Dcheck
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'connect' which attempts a new connection instead of checking existing connectivity.
Using generic names like 'check' without clear meaning.
3fill in blank
hard

Fix the error in the health check response code to correctly indicate service health.

HLD
def health_check():
    return 'Service is healthy', [1]
Drag options to blanks, or click blank then click option'
A200
B500
C404
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Returning error codes like 404 or 500 which indicate problems.
Using redirect codes like 301 which are not appropriate here.
4fill in blank
hard

Fill both blanks to create a health check that returns JSON with status.

HLD
def health_check():
    return [1], [2]
Drag options to blanks, or click blank then click option'
A{"status": "ok"}
B200
C{'timestamp': time.time()}
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Returning 404 status code which means not found.
Returning only timestamp without status.
5fill in blank
hard

Fill all three blanks to implement a readiness check that returns 200 if cache and DB are healthy, else 503.

HLD
def readiness_check():
    if cache.[1]() and db.[2]():
        return [3]
    else:
        return 503
Drag options to blanks, or click blank then click option'
Aping
Bis_alive
C200
Dconnect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'connect' which may attempt new connections instead of health checks.
Returning 503 when services are healthy.