Moving from Cloudflare to Fastly

Colby SwandaleColby Swandale
5 min read

Content Warning: Suicide

Ruby API is an open-source project that aims to improve Ruby’s documentation by investing in search & UX to encourage discovery and giving users tools to find what they want quickly. For search, we utilize ElasticSearch, which allows us to compose advanced queries to generate search results that better match user expectations! Ruby API is a free service, and always will be, that aims to last long into the future, but this comes with a trade-off of needing to keep costs very low to keep Ruby API alive.

An advantage of hosting documentation for a programming language is that it’s straightforward to cache for long periods. We can generate a page for any given version of Ruby’s documentation and cache it forever (assuming no other dynamic content on the page). But like any other site, Ruby API is constantly getting new improvements and refinements. Secondly, the server that runs rubyapi.org lives in a single data center on America’s east coast. Users in New York will experience a reasonably snappy & responsive site, but users located in Africa or the Asia Pacific will have a vastly different experience.

Content Delivery Networks to the rescue

Content Delivery Networks are a fantastic service that distributes content using a vast network of globally distributed servers, saving developers the need to procure infrastructure—a vital goal for an open-source project with limited spending budgets.

When Ruby API was first published, I chose Cloudflare’s free tier service, which provides CDN and SSL features to keep pages snappy and secure. It was a great product that was part of Ruby API’s growth from a pet project into a service used by thousands of people in the Ruby community each month.

After a few months, I started to pay for the professional plan to take advantage of additional features to help further improve the user experience. I also migrated the domain to Cloudflare to streamline site & billing management.

When values no longer align

Ruby API was a satisfied paying customer of Cloudflare, but in August 2022, a site called Kiwi Farms launched a harassment campaign towards Twitch streamer Clara “Keffals” Sorrenti. The attack resulted in her being doxed multiple times, personal details being published online, and Clara ultimately fleeing her home for her safety. Kiwi Farms was also a customer of Cloudflare, which was taking advantage of Cloudflare's proxy capability to mask their origin server.

I was horrified after reading further about Kiwi Farm’s long history of targeted harassment, including the deaths of Chloe Sagal, Julie Terryberry & Near as a result of the targeted harassment from users of Kiwi Farms. I made the choice afterward that I could no longer in good conscience continue supporting Cloudflare, who refused responsibility for their part of enabling Kiwi Farms to operate. At the same time, Liz Fong-Jones had begun sharing the excellent #DropCloudflare series, which laid out steps people could take to move away from Cloudflare. In September 2022, Cloudflare finally dropped Kiwi farms as a customer, but I continued to feel that I could no longer support Cloudflare.

After considering several alternatives, such as CloudFront & CacheFly, I landed on Fastly as the replacement CDN & Google Domains for domain hosting. Fastly was the right choice for two reasons, first was their Values & Code of Ethics, which ensures sites like Kiwi Farms aren't enabled through Fastly's services. Second was Fastly's commitment to open-source and supporting projects with free services, which Ruby API does receive.

Moving Ruby API to Fastly with zero downtime

Ruby API was able to move from Cloudflare to Fastly with zero reported downtime! The plan and execution process took several weeks, which consisted of roughly:

  1. Firstly was moving Ruby API’s existing DNS (not including the domain) from Cloudflare to Google Domains. I could do this smoothly thanks to the tooling in Google Domains that allows importing existing DNS records from Cloudflare. After importing everything, I updated the domain name servers to use Google Domains.

  2. Secondly, was creating the Ruby API service inside Faslty and setting up the initial config. Fastly has a setup process that makes getting your website set up a breeze, with tons of documentation available to help if you get stuck. Ruby API has a reasonably simple config with only an endpoint and some basic caching rules, so we could get a basic version deployed with only a couple of clicks.

  3. After the initial config was set up in Fastly, we could start testing the Ruby API using the test endpoint before moving any live traffic over. Once satisfied with our tests, I updated Ruby API’s DNS to serve traffic via Fastly.

  4. Using the Real-Time Stats in Fastly, we could monitor the request & response status of requests for Ruby API coming through Fastly.

  5. Once Ruby API's traffic was fully migrated to Fastly, I began to update the Fastly config to start caching CSS, JS, and HTML pages using the Fastly Cache Control methods

  6. The last step was transferring the domain From Cloudflare to Google Domains. The process was relatively simple, and took a few minutes to submit the transfer request. After a few days, I received an email from Cloudflare that confirmed Google Domains was now the registrar for rubyapi.org.

Conclusion

Ruby API moved to Fastly at the end of 2022 and hasn’t experienced any recorded downtime. We also improved Ruby API’s caching strategy by using Faslty’s support for the Vary header to better cache pages for longer. Finally, I hope to continue enhancing Ruby API to enable the best UX for everyone worldwide.

0
Subscribe to my newsletter

Read articles from Colby Swandale directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Colby Swandale
Colby Swandale