Flattening the DNS Curve with Cloudflare

Image of Reclaim Hosting's main website

Notice the wwww.reclaimhosting.com

I feel like I could write a book about just last week at Reclaim Hosting, so many awesome things happening and the work we’re doing to build a sense of team internally and community more generally is really starting to gel. I’ll save that post for another day, but right now I just want to capture some of the work we have done over the last couple of weeks to move our main website to Reclaim Cloud using a multiregion setup. What multi-region denotes is that there are two (or more) servers in two (or more) regions that are serving the content. For this to work the files and databases need to be syncing instantly across the two regions, and thanks to Virtuozzo’s WordPress Multiregion setup we can do that. I already have the bava.blog setup with mutliregion, so it was time to do the same with the main Reclaim Hosting website. We started with spinning up a dev instance to export everything from the Digital Ocean droplet hosting our site over to Reclaim Cloud. I setup the multiregion instance and did the migration (mostly) while Chris Blankenship led the way with the Cloudflare setup. This dev space allowed Lauren to troubleshoot a couple of pesky plugins, make sure everything was syncing cleanly between the regions, and ensure there were no major flags with this setup for the main site.

In AWS the CNAME record is pointed to a Cloudflare address in order to flatten that record

All was good, so we created another multiregion for the production instance using two regions and rsynced files and imported the database from the dev site. After that, we had to point our www CNAME record from AWS to Cloudflare, and this is worth talking about for a moment. Given AWS’s DNS service Route 53 does not allow us to flatten the top-level domain of reclaimhosting.com* we had to point just part of our DNS to Cloudflare, a.k.a. a partial DNS setup.  We pointed www.reclaimhosting.com, which allowed us to then create two A records for www in Cloudflare’s DNS management panel. And that’s when it occurred to me, this is what we need to do for all of our infrastructure going forward. We need an enterprise license through Cloudflare that allows us to point records for our own infrastructure (and for that of schools that want to point part of their DNS at us, such as subdomains like domains.stateu.edu) so that we can manage the records that point to a server’s IP behind the scenes. This is useful because in the event a server needs to be migrated (which often means an IP address change) there is never an interruption of service. The client never needs to worry about that, and while it took me 8 years to grok it, I now understand how Cloudflare’s introduction of CNAME flattening in 2014 changes the game in so many ways for us. In fact, it was during yesterday’s move of the Reclaim’s main site that it hit me like a diamond through the forehead.

Image of AWS CNAEM record pointed to Cloudflare to flatten that subdomain

WWW A records for two servers

By flattening the CNAME record for www from the original DNS provider (in our case AWS’s Route 53) we are able to proxy that record in Cloudflare so that it can have multiple A records pointing to the server IP addresses for our multiregion setup. Then, and this is the second piece that fell into place for me conceptually, we can run the load balancer for that server not in the container on Reclaim Cloud, but abstracted out to Cloudflare’s load balancing service. So the management of DNS is fully isolated from a physical machine allowing for immediate failover and traffic re-direction in the event of an emergency.

Image of Load Balancer through Cloudflare

Load Balancer through Cloudflare

What’s more, there is monitoring built-into the load balancing so should there be an issue with any of the regions you will be immediately notified. In fact, you can control how traffic is steered to these regional pools, whether based on proximity (closest server) by geo-locating IPs, or randomly using speed and latency checks. What’s more, at the point any of the servers is having issues the load balancer knows to re-direct all traffic to the healthy origin. It is pretty awesome, and Reclaim Hosting is leveraging the power of not only multiregion and load balancing, but also all the other benefits of Cloudflare like DDoS protection, a huge CDN, the potential for zero trust networks, and much more.

Details of CLoudflare load balancer using two different pools

Details of Cloudflare load balancer using two different pools

In fact, as I was testing out www.reclaimhosting.com yesterday before we redirected all traffic from reclaimhosting.com –> www.reclaimhosting.com we realized that all images were not synced to the region two server. So while Taylor Jadin stepped in and saved my butt by rsyncing all media files to the production server from dev server we were able to steer all traffic to the fully functioning server in region 1 with the click of a button. Literally micro-seconds for the change to propagate. It was eye-opening as to the power of such immediate shifts that ensure your site is enterprise-ready. Cloudflare is no joke, and I am a big fan!


*We would need to point that main record (reclaimhosting.com) to Cloudflare without interrupting thousands of records for the various servers and services we run off that namespace. So this was not nothing….

This entry was posted in reclaim, Reclaim Cloud and tagged , , , , . Bookmark the permalink.

2 Responses to Flattening the DNS Curve with Cloudflare

  1. Frank says:

    Hi there,

    I have some questions:

    1-How do you keep all files (wp-uploads, plugins, and so) synced?
    2-Are you using a unique database?


    • Reverend says:

      Hi Frank,

      Thanks for commenting, we are using our cloud platform Virtuozzo that that allows use to setup a mutliregion setup that syncs files database updates between the two (or more) instances immediately using Gallera db clustering and lsyncd is a light-weight, live mirror solution used to synchronize app servers. Does that help?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.