Tom Mango

Custom Error Pages, AWS's ELB, and Route 53 Failover

There has been a thread on the AWS support forums since July 25th, 2011, calling for AWS to add customizable error pages to their ELB (Elastic Load Balancer) product.

AWS recently added health check and failover features to their Route 53 (DNS) product, and now some people are wondering whether or not this removes the need for custom error pages on Elastic Load Balancers:

Nalog wrote: What about using DNS Failover on ELB?

Short answer, no, it doesn't.

Long Answer:

Using Route 53's DNS failover, while similar, is unfortunately not the same thing. With a DNS failover setup, clients would wait the TTL (probably 60 seconds in this case) before re-requesting DNS entries for the request (thus getting a failover IP address). However, Route 53 won't failover until some amount of time passes and it believes that the ELB should be failed over from. So you may be in the 2 minute range at this point.

During this 2 minute or so range, blank pages are being served to clients from the ELB. Additionally, clients (browsers) aren't always great about handling transitions between the blank pages from ELB requests and some failover, say a static site being hosted out of S3. Even with no-cache headers, and updated DNS entries because of the failover, browsers will often cache the results and not show updated pages (due to a failover or recovery) by simply clicking the refresh button. Restarting the browser generally forces a refresh of the page, but end users aren't going to expect to have to do that, nor should they have to.

If ELB was able to serve a custom error page, rather than a blank response, when no instance responded to a request, this would solve all of the above issues. Clients wouldn't need to wait for new DNS records, nor would they be affected by cached pages. They would simply receive the error page as the response of their intended request. If they refresh and the ELB can return a real response, they'd display the real response.

If AWS ever adds the ability to have an ELB respond with a custom error page when no instance responds to a request, it will most likely work like a standard HAProxy setup. With HAProxy, you can configure a "backup" instance. For example, you can configure a backend like:

In this scenario, you configure HAProxy with a backend that has 2 real instances and then you also run Apache on port 8000 on the same instance running HAProxy. If neither real instance can respond to a request, HAProxy automatically routes the request to 127.0.0.1:8000 and you would configure Apache to rewrite every request and respond with your error page.

Route 53's DNS failover is useful for some things, such as your ELB completely going away, but it isn't a substitute for ELBs being able to actually serve error pages, rather than blank responses, when your instances don't respond.