- Fastly Status
Health checks tutorial
Last updated April 03, 2017
In this tutorial we show you how to create health checks that periodically contacts your origin servers to make sure they're still working.
We assume that you're already accustomed to editing and deploying configurations using the web interface. If you're not familiar with basic editing using the web interface, see our Help Guides to learn more before you continue.
Health checks, while simple in principle, are more involved than most other configuration objects. Let's run through the options you have when creating a health check so you have a place to start when working through the tutorial.
- Name - A human-readable identifier for the health check (e.g.,
West Coast Origin Check).
- Request - An HTTP method and path to visit on your origin servers when performing the check. Use a unique path, for example, use
- Host header - The HTTP Host Header to set when making the request (e.g.
- Expected response - The HTTP status code the origin servers must respond with for the check to pass (usually
- Check frequency - How often the origin server is checked with additional parameters that determine if the origin server is up or down. For more information about the additional parameters, see our guide on Health check frequency.
- Threshold & Window - The number of successes per total number health checks. For example, specifying
1/2means 1 out of 2 checks must pass to be reported as healthy.
- Initial - The number of requests to assume as passing on deploy.
- Interval & Timeout (ms) - Interval represents the period of time for the requests to run. Timeout represents the wait time until request is considered failed. Both times are specified in milliseconds.
Fastly will periodically check your origin server based on the options chosen. Pay special attention to the HTTP host header. A common mistake is setting the wrong host. If the origin server does not receive a host it expects, it may issue a 301 or 302 redirect causing the health check to fail. Also, Varnish requires the origin server receiving the health check requests to close the connection for each request. If the origin server does not close the connection, health checks will time out and fail.
If an origin server is marked unhealthy due to health checks, Fastly will stop attempting to send requests to it. If all origin servers are marked unhealthy, Fastly will attempt to serve stale. If no stale object is available, a 503 will be returned to the client.
Creating a health check
- Log in to the Fastly web interface and click the Configure link.
- From the service menu, select the appropriate service.
- Click the Configuration button and then select Clone active. The service version page appears.
Click the Origins tab. The Origins page appears.
Click the Create health check button. The Create a health check page appears.
- Fill out the Create a health check fields. For more information, review the field descriptions in the Overview section.
- Click the Create button. Your new health check now appears in the list of checks.
Assigning a health check
Health checks do nothing on their own, but they can be added as a special parameter to an origin server in your configuration.
- Edit one of your existing origin servers by clicking the origin server's name. The Edit this host page appears.
From the Health checks menu, select the health check you just created.
- Click Update.
Fastly will now use the health check to monitor the selected origin server.Back to Top