How to Avoid the Next AWS S3 Outage with a Failover Scenario
It was a big shock when Amazon’s S3 storage service went down for four hours in its North Virginia data center last Tuesday. The problem was in the end caused by human error but there is another lesson the world has learned: things like this happen. When the whole internet basically relies on only a few providers, an outage of one of these feels like a massive disaster. In this article, we want to talk about a backup solution for your critical infrastructure. We will use AWS S3 as a primary storage solution and Microsoft Azure (or some other providers) as a failover.
Why Not Just Rely on a Single Provider?
The recent S3 outage has shown that while a cloud solution removes the headache of running an infrastructure on your own, it doesn’t mean it can’t fail. Of course you could use different availability zones or even locations to reduce the chance of an outage but in the end, human error could even kill an entire provider. So our goal is to mirror the data across completely different providers.
Use S3 and Azure as Fallback
In this case, we will demonstrate how to use Amazon S3 with Microsoft Azure as a fallback solution realized in Node.js. This of course also works for providers like Google Cloud, Rackspace or Backblaze but let’s start with Azure. You will find an advanced case with all providers further below in this article.
Since all providers have different APIs, it would normally be pretty complicated to realize this scenario. That’s why we use our own CloudRail solution to get a unified API which works the same across all providers.
We initialize a list with two (later all five) different backend cloud storage providers we have accounts with. We assume that a bucket already exists (that is the typical case) but it would also be easy to create a new one with CloudRail. The “storeFile” function tries to upload a local file to the first service in that list, tries the next service if it fails and so on until there are either no more services to try or it succeeds.
This is a very simple example to realize a cross provider upload case in Node.js. Check out our documentation for Node.js, Java, Objective-C, Swift and Android to learn about different platforms and how to perform methods like download, delete or others.
Do a Failover with Google Cloud, Rackspace or Backblaze
The example above also works with providers like Google Cloud, Rackspace or Backblaze. Simply replace the initialization part with the providers of your choice. Here is a quick example how to do it:
With CloudRail, the technical implementation of a failover is easy. Yet a potential drawback of all failover solutions is increased cost since storage contingents on multiple services need to be paid for. At the end of the day everyone has to make this cost vs. data safety decision on a case by case basis.
When realizing implementations that access cloud storage services, it is also important to think about the different data consistency models of the services. If you are not aware of them, application-breaking bugs can arise in your applications. This article gives you a quick overview about the topic and potential solutions.