Production Readiness: The Final Checklist

Production Readiness: The Final Checklist in Java: "It works on my machine" and "it survives production" are different bars.

Concept Explanation

"It works on my machine" and "it survives production" are different bars. Production adds concurrency, real data volumes, hostile input, and no debugger. This is the checklist that closes that gap.


Configuration

# Fail fast on a bad configuration rather than half-starting
spring.main.lazy-initialization=false

# Never expose internals in errors
server.error.include-stacktrace=never
server.error.include-message=never

# Bound the thread pool deliberately
server.tomcat.threads.max=200

# Graceful shutdown: finish in-flight requests before exiting
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=30s

Graceful shutdown matters more than it sounds — without it, every deploy drops the requests that were mid-flight.


Health Probes

Two different questions, two endpoints:

management.endpoint.health.probes.enabled=true
  • /actuator/health/liveness — is the process broken? If this fails, restart it.
  • /actuator/health/readiness — can it serve traffic? If this fails, stop routing to it but do not restart.

Confusing the two causes restart loops during a slow dependency outage.


Resource Limits

resources:
  requests:
    memory: "512Mi"
    cpu: "250m"
  limits:
    memory: "1Gi"
    cpu: "1000m"

With -XX:MaxRAMPercentage=75.0, the JVM heap sits inside the limit with room for metaspace, thread stacks, and native memory. Setting the heap equal to the container limit guarantees an eventual OOM kill.


Database Connections

spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.connection-timeout=3000
spring.datasource.hikari.leak-detection-threshold=20000

Bigger is not better: pool size × instance count must stay under the database's connection limit. Ten instances with a pool of 50 each will exhaust most database servers.


The Checklist

Configuration

  • [ ] No secrets in the repository; all injected at runtime
  • [ ] Profiles for each environment, with the app failing loudly if none is active

Reliability

  • [ ] Timeouts on every outbound call
  • [ ] Fallbacks or circuit breakers on every remote dependency
  • [ ] Graceful shutdown enabled
  • [ ] Liveness and readiness probes distinguished

Observability

  • [ ] Structured logs with a correlation id
  • [ ] Metrics exported; dashboards for latency, errors, saturation
  • [ ] Alerts on user-visible symptoms, not just CPU

Security

  • [ ] HTTPS enforced
  • [ ] Stack traces hidden from clients
  • [ ] Dependency scanning in CI
  • [ ] Non-root container user

Data

  • [ ] Migrations versioned (Flyway or Liquibase), never ddl-auto=update
  • [ ] Backups exist and a restore has been tested
  • [ ] Connection pool sized against the database's real limit

Common Mistakes

  1. No graceful shutdown: Every deploy becomes a small outage for whoever was mid-request.
  2. Heap set to the container limit: The JVM needs non-heap memory too; the kernel kills the process.
  3. Untested backups: A backup you have never restored is a hypothesis, not a safety net.
  4. ddl-auto=update in production: Hibernate silently altering the schema is how data disappears.
  5. Alerting on everything: Alert fatigue means the one real alert gets ignored.

Best Practices

  • Load test before launch, not after the first incident.
  • Deploy small and often: Small changes are easy to diagnose and roll back.
  • Keep a runbook: How to roll back, who to page, where the dashboards are.
  • Write a postmortem for every incident, focused on the system rather than the person.

Practice Exercises

  1. The Graceful Shutdown: Send a long-running request, then SIGTERM the app. Confirm the request completes with graceful shutdown enabled and is dropped without it.
  2. The Memory Math: Given a 1 GiB container limit, calculate a safe max heap and justify the headroom.
  3. The Runbook: Write a one-page runbook for an app you have built — rollback steps, key dashboards, and the three most likely failure modes.