How to Set Up and Manage Health Checks

App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.


Health checks in App Platform serve as readiness probes to determine when an application is ready to start handling traffic. When you a deploy an app, App Platform uses a set of parameters to determine when health checks should begin, how often they should run, and how many times they must fail before considering the app unhealthy and sending an email to the account’s email address.

App Platform has default health check settings that work for most apps, but you can customize them for your specific app’s needs. For example, if you know your app takes longer to deploy than the default time before health checks start, you may want to increase that value.

To customize your app’s health check settings, edit the app’s spec and add the health_check object to your service component, like this:

    
        
            
health_check:
  initial_delay_seconds: 30
  period_seconds: 10
  timeout_seconds: 5
  success_threshold: 1
  failure_threshold: 5
  http_path: /api
  port: 8080

        
    

Each field in the health_check object has the following meaning:

  • initial_delay_seconds: The number of seconds before the App Platform begins initiating health checks after a deployment.
  • period_seconds: The number of seconds (interval) between health checks.
  • timeout_seconds: The number of seconds before a health check is considered failed.
  • success_threshold: The number of consecutive successful health checks required before the app is considered healthy.
  • failure_threshold: The number of consecutive failed health checks required before the app is considered unhealthy.
  • http_path: The HTTP path on which to perform health checks. If not set, App Platform disables the HTTP health check and a TCP health check used instead.
  • port: The port on which to perform health checks. If not set, App Platform performs the health check on the component’s http_port.

Once you add the health_check object to your app spec, upload the spec to your app’s repo or deploy it directly using the control panel.