Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of a health check in a containerized microservice?
A health check verifies if a containerized microservice is running correctly and ready to serve requests. It helps orchestrators decide if the container should keep running or be restarted.
Click to reveal answer
beginner
Name the two common types of health checks used in containers.
Liveness check: Determines if the container is alive or stuck. Readiness check: Determines if the container is ready to accept traffic.
Click to reveal answer
intermediate
Why should readiness checks be separate from liveness checks?
Readiness checks control traffic routing and prevent sending requests to containers not ready yet. Liveness checks detect if a container is broken and needs restart. Separating them avoids unnecessary restarts.
Click to reveal answer
beginner
What happens if a liveness check fails in a container orchestrator like Kubernetes?
The orchestrator considers the container unhealthy and restarts it to recover from failure or stuck state.
Click to reveal answer
beginner
Give an example of a simple readiness check for a web service container.
A readiness check can be an HTTP GET request to an endpoint like /health or /ready that returns status 200 if the service is ready to accept requests.
Click to reveal answer
Which health check type ensures a container is ready to receive traffic?
AReadiness check
BLiveness check
CStartup check
DPerformance check
✗ Incorrect
Readiness checks confirm if the container is ready to accept requests, controlling traffic routing.
What action does Kubernetes take when a liveness check fails?
ARestarts the container
BRoutes traffic away from the container
CScales up the service
DIgnores the failure
✗ Incorrect
Kubernetes restarts containers that fail liveness checks to recover from unhealthy states.
Why is it important to have separate readiness and liveness checks?
ATo reduce network traffic
BTo avoid restarting containers unnecessarily
CTo improve logging
DTo speed up container startup
✗ Incorrect
Separating checks prevents restarting containers that are alive but not ready to serve traffic.
Which of these is a common method for implementing a readiness check?
AChecking CPU usage
BMonitoring memory leaks
CSending an HTTP GET request to a health endpoint
DVerifying disk space
✗ Incorrect
Readiness checks often use HTTP requests to specific endpoints that return status indicating readiness.
If a container is alive but not ready, what should happen?
AIt should be deleted
BIt should receive traffic normally
CIt should be restarted immediately
DTraffic should be withheld until ready
✗ Incorrect
Traffic should be withheld until the container signals readiness to avoid errors.
Explain the difference between liveness and readiness health checks in containers.
Think about when a container should be restarted versus when it should receive traffic.
You got /4 concepts.
Describe how health checks improve reliability in a microservices architecture using containers.
Consider what happens when a service fails or is not ready.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of health checks in containers?
easy
A. To log all container network traffic
B. To increase the container's memory allocation
C. To update the container's software automatically
D. To verify if the container is running and responsive
Solution
Step 1: Understand container health checks
Health checks are used to confirm if a container is alive and working properly.
Step 2: Identify the main goal
The main goal is to detect if the container is responsive and healthy, so it can be restarted if needed.
Final Answer:
To verify if the container is running and responsive -> Option D
Quick Check:
Health checks = verify container health [OK]
Hint: Health checks confirm container responsiveness [OK]
Common Mistakes:
Confusing health checks with resource allocation
Thinking health checks update software
Assuming health checks log network data
2. Which of the following is the correct syntax to define a simple HTTP health check in a Docker container?
easy
A. HEALTHCHECK EXECUTE curl -f http://localhost/
B. HEALTHCHECK RUN curl http://localhost/
C. HEALTHCHECK CMD curl -f http://localhost/ || exit 1
D. HEALTHCHECK CHECK curl http://localhost/
Solution
Step 1: Recall Docker health check syntax
The correct Dockerfile syntax uses HEALTHCHECK CMD followed by a command that returns 0 on success.
Step 2: Identify the correct command
HEALTHCHECK CMD curl -f http://localhost/ || exit 1 uses 'curl -f' which fails on HTTP errors and 'exit 1' on failure, matching best practice.