19 · Operations and deployment foundations / LESSON 94 OF 102
Logs, health, and performance
Understand failures and measure before optimizing.
Before this lesson: API documentation and consumer contracts
Understand the topic
Log useful context and request identifiers without passwords, tokens, or sensitive bodies. Actuator exposes health and metrics when configured. Restrict management access and avoid exposing internal health details publicly.
Measure endpoint latency and SQL query counts. Bound external timeouts and retry only safe operations. N+1 queries, connection pools, and cache invalidation matter more than arbitrary thread tuning. Graceful shutdown has a finite deadline.
EXAMPLE · PROPERTIES
application.properties · operational settings
management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=never
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=20s
logging.level.com.example.tasks=INFOWhat to expect
Only configured management endpoints are exposed. Shutdown allows bounded time for requests; completion is not guaranteed.
YOUR TURN
Put it into practice
- 01Stop the local database and inspect health/logs.
- 02Measure paginated reads with 1,000 test tasks.
- 03Add request IDs without logging credentials.
Pass a quiz or complete a lab to check today’s streak. Each lesson counts once per day, including when you review it later.
UNDER THE HOOD
Build the mental model
A production service must explain whether it is healthy, what failed, and how long operations take.
- 01Latency distributions matter: an average can hide slow tail requests. Track error rate, request volume, and resource saturation together.
- 02A liveness check asks whether the process can keep running; readiness asks whether it should receive traffic. A dependency outage may affect readiness without requiring endless restarts.
- 03Retries amplify load during outages. Bound attempts, use backoff, and retry only operations whose semantics make repetition safe.
A mistake worth avoiding
Avoid high-cardinality metric labels such as user IDs or raw request paths containing IDs.
DEBUGGING ROOM
Something broke. Where do you look?
An outage becomes worse after retries are enabled.
Before revealing the diagnosis, write down your first investigation step.
CHECK YOUR UNDERSTANDING
Which metric label is usually dangerous for cardinality?
BUILD IT YOURSELF
Create an operational runbook
- 1.Document startup, health, logs, and dependency checks.
- 2.Simulate a database outage locally.
- 3.Measure p50 and p95 latency for a bounded test workload.
Acceptance checklist
Lab completion is your self-report. Knowledge checks do not certify project quality.
RETRIEVE IT FROM MEMORY
What would distinguish a slow dependency from an overloaded application?
Revisit this lesson in three days after a successful check or lab.
Ready for the next step?
Identify a failing dependency and a measured bottleneck.
Reading is separate from passing a knowledge check or completing a lab.