What a 200 OK Check Catches and What It Misses
Every five minutes, Apphold sends an HTTP GET to each active observer’s URL, follows any redirects, and waits up to ten seconds. If the final answer is 200 OK, the site is up. Anything else is a problem.
That rule is deliberately narrow. It is worth knowing exactly where its edges are, so you can choose URLs that make it useful instead of discovering its limits during an outage.
What It Catches Well
The server is gone. The host is off, the container crashed, the load balancer has no healthy backends. The request never completes, and Apphold records a connection error with the reason it got.
The web server is up but the application is not. A PHP-FPM pool that has died behind Nginx usually produces a 502. An application that throws on boot produces a 500. Both are recorded as a site down incident with the status code attached.
The page has moved somewhere broken. Apphold follows redirects, so a 301 to a working page is fine. A redirect that lands on a 404 is not, and you will hear about it.
DNS and certificates. A domain that has lapsed, a DNS record that was deleted by mistake, a TLS certificate that expired overnight. None of these return a status code at all. They show up as connection errors with the underlying message, which usually tells you which of the three it was.
Pages that hang. If a page takes longer than ten seconds, the request is abandoned and counted as a failure. For a visitor, a page that takes eleven seconds is broken anyway.
Together that covers most of the outages a small team actually has.
What It Cannot See
An error page served with 200. Some applications catch every exception and render a friendly “Something went wrong” page with a 200 status. To Apphold, that page is healthy. This is the most common blind spot, and the fix belongs in the application: errors should return error codes.
A page that loads but is wrong. A homepage with a missing stylesheet, an empty product list, or yesterday’s prices still returns 200. Apphold checks that the server answers, not what the answer says.
Problems behind the page. A homepage can be served from a cache while the database behind it is down. The homepage passes; checkout fails. The check only knows about the URL you gave it.
Short outages between runs. Checks run every five minutes. A site that is down for ninety seconds between two runs will not produce an incident. For most sites that is an acceptable trade. If it is not for yours, you need a different tool alongside Apphold.
What one location sees. The request comes from the server Apphold runs on. If a problem only affects visitors in one region or on one network, it may not be visible from there.
Pick URLs That Fail Honestly
The way to get more out of a simple check is to aim it at a URL that fails when the thing you care about fails.
A static homepage behind a CDN is a poor choice. It can stay up for hours while everything else is broken. A page that has to touch the database to render is a better one. Better still is a small URL built for the purpose, one that checks the database connection and returns 500 if it cannot reach it. We cover that in designing a health check URL.
A few practical rules from our own setups:
- Watch at least one URL per moving part: the marketing site, the application, the API.
- Prefer a URL that is not cached at the edge.
- If a page needs a login, watch the login page instead. It still proves the application is answering.
- Avoid URLs that are expensive to render. They are requested 288 times a day.
Make Errors Look Like Errors
Since the check reads only the status code, the single most useful change is often in your own application. Make sure that:
- Unhandled exceptions return
500, not a styled page with200. - Maintenance mode returns
503. - Missing records return
404, not a redirect to the homepage.
Frameworks such as Laravel, Django and Rails do this by default. Custom error handlers are where it tends to go wrong. Check yours once with curl -I and you will know whether Apphold can see your failures.
Simple on Purpose
A check that only looks at the status code is easy to reason about. When an incident opens, you know exactly what happened: the URL did not return 200 within ten seconds, and the incident tells you what it got instead. There are no thresholds to tune and no rules to misread at three in the morning.
If you want to see the full loop from request to email, Under the Hood: How Apphold Checks If Your Websites Are Up walks through it step by step.
Need Professional Help?
Get custom development, managed hosting, data migration, and technical support, directly from the creators of Apphold.
Explore Premium