They are cases when you need to disable some endpoints of a website as fast as possible. For example, in the case were an issue on an endpoint is causing all of your website to go down. Or because you need to limit the traffic load quickly by sacrificing parts of the API, instead of losing everything.
Sure you could create a redirect within your application but:
This requires a full deployment which is usually far from quick. Trying to speed it up may lead to side effects, so it isn’t a good idea.
What if it’s the load balancer that has pain handling the traffic? Then changing the routing at the application layer is useless.
Here is the solution we have at Hunter to stop parts of the traffic in seconds.
Of course, this doesn’t fix the issue, and it’s far for being pretty. But when all hell breaks loose, this will give you some much needed time.
First, create a nice maintenance subdomain
All the users accessing the disabled resource will be sent to this subdomain. It’s important to be as helpful as possible on this page. Giving easy access to your status page as well as your support team is great. The user should also be able to go back to your website to avoid getting stuck there.
The maintenance page we use at Hunter
Of course, don’t store this page on the same hosting as your main website; it might be down in the first place. The solution we have in place is to use Github Pages to host this page. Just create the repository, add the index.html (as well as the resources) and activate Github Pages. Your subdomain is now online! At Hunter, we also have Cloudflare sitting in front to both add the HTTPS and cache the page.
Creating a good maintenance page is, of course, better, but if you’re in a rush, you can skip this page and redirect to a wrong domain.
Redirect the traffic to the maintenance page
To redirect the traffic we use Cloudflare. Alternatives exist, they just need to be external to your system to work.
On Cloudflare a simple page rule can take care of redirecting an entire endpoint:
The advantage is that it takes effect a few seconds later and works even if your service is offline. You then have some time to fix everything!