Cloudinary Blog

A story about production systems, Rails, monitoring and off-hour notifications

by Nadav Soferman
Cloudinary's image management service is used by thousands of world-wide websites and mobile apps. For many of our clients, Cloudinary has become a central, mission-critical component used for managing image uploads, transformations and delivery.
 
This is why we've built Cloudinary from the ground up to be a very robust service. We put a lot of emphasis on availability, scalability and support and we take our users' confidence in us extremely seriously.
 
So far, we've been quite satisfied with our ability to keep Cloudinary at an average of > 99.99% uptime.
 
However, on April 4th, the Cloudinary service experienced outages for a few hours. We wanted to explain what happened, our conclusions and the steps we've taken to make sure this won’t happen again.
 

The upgrade

Cloudinary's core service is built with Ruby on Rails. The service is tested thoroughly and upgrades are handled with uttermost care. This is why we've preferred to stay with Rails v3.0 for a long time rather than rock the boat with an upgrade to the latest Rails 3.2.
 
A few weeks ago a security vulnerability was discovered in Rails. As always, we wanted to apply the security fix as soon as possible. However, the Rails team stopped releasing fixes for Rails 3.0. We had to upgrade to v3.2.
 
We've upgraded to Rails 3.2 in our lab and modified our code to support it (Rails upgrades tend to be non backward compatible and break code built with previous versions). We've tested our code extensively and verified that our thousands of unit tests passed correctly. We've successfully finished a thorough manual QA of the system in our staging environment. It all went quite smoothly.
 
We scheduled the upgrade for April 4th. As usual, we deployed the system gradually to all of our production servers. Deployment went smoothly as well. We performed additional sanity testing after the system was deployed and closely monitored the system during the working day.
 
We went to sleep happy and relaxed.
 

The issues

At about 1am at night things started to shake.
 
Apparently, Rails 3.2 changed the defaults of one simple configuration parameter - response caching was turned on by default when certain cache headers are returned.
 
As a result, after long hours of service requests, the local application disk for some of our servers became full due to the cached responses. This caused certain requests that required disk space to fail, depending on the exact request and the size of the response.
 
Annoyingly enough, the automatic monitoring service that regularly verifies our APIs, was performing a request that required very little disk space and continued to operate regularly. This service is configured to send notifications to our engineering team's mobile phones during the night. But since no errors were detected, no notification was sent.
 
Fortunately for us, our co-founder's toddler woke him up early in the morning. He naturally (?) checked his inbox, understood that something was very wrong. He quickly cleared the disk space and modified Rails 3.2 cache settings. The system was fully working again.
 
It's important to note that during these ~5 hours, all existing images and transformed images were delivered successfully to users through our delivery service and tens of thousands of worldwide CDN edges (Akamai + CloudFront). Still, part of the upload API calls did fail during this time and we are very sorry for this.
 

Going forward

Naturally, we've immediately started to improve our outage prevention mechanisms.
 
We've added additional disk space tests to our QA list and added abnormal disk usage monitoring to our urgent notification service. We're also adding a wider set of API requests to our automatic service monitoring.
 
We've integrated with Twilio to enhance our off-hour notifications. Specifically, our engineering team will now receive automatic voice calls to their mobile phones in addition to our previous notification methods.
 
To make sure we keep you in the know during outages, we've pushed up the priority of a public status page. This page will include automatic monitoring details as well as human written notes.
 

Summary & conclusions 

We are happy that Cloudinary had nearly zero availability issues in almost 2 years of operations. On the other hand, no online service is perfect and every service experienced or will experience outages. 
 
We will continue to enhance our service with additional image-related features. On the same time, we'll continue to work hard on having Cloudinary's uptime as close to 100% as possible.
 
Thank you for trusting us with your images!

Recent Blog Posts

Dynamic ZIP files generation with a single line of code

As a developer, you want to allow your users to download multiple files in a single click. An easy way to download multiple files and share them is to generate a ZIP file. When images are involved, you may also want to normalize the original images before including them in the ZIP file, by scaling them down to the same maximum resolution or converting them to the same format.

Read more
How mindbodygreen reduce costs & save development time

mindbodygreen is a digital media brand dedicated to health and wellness. The company’s website bring together leaders in the wellness world, best-selling authors, fitness experts, trusted healers, pioneering doctors, top chefs, celebrities and top-tier journalists to provide readers fresh, expert content and tools to help them live healthy, happy lives. The company was founded in 2009 and is headquartered in Brooklyn, N.Y. 
Read more

Why JPEG is like a photocopier

by Jon Sneyers
Why JPEG is like a photocopier (generation loss)

If you make a copy of a copy of a copy, the quality will deteriorate with every ‘generation’. This problem is called ‘generation loss’. It is not difficult to understand why this happens with actual copier machines. Scanning and printing are not perfect, being based on noisy sensors and physical paper and ink, and the resulting noise will tend to accumulate.

Read more
Apply conditions to dynamically manipulate images.

It's great to have the capability to manipulate images on the fly by using dynamic URLs to customize the images to fit the graphic design of your site or mobile application. However, what if you want to manipulate an image depending on a specific image characteristic (like its width or aspect ratio) or its contents (does it contain a face?). What you need is a way to apply a transformation to an image only if a specific condition is met. Take for example a situation where you have allocated space on your page for a user uploaded image with a width and height of 200 pixels. Furthermore, if the image contains a face you would like to zoom in and focus on the face itself, otherwise you would like to fit the entire image into the available space:

Read more
Moviepilot focus on core business and reduce costs
 
Moviepilot Inc. is a media company that hosts a website and social publishing platform designed to bring together movie and TV fans, and help studios trigger, fuel and amplify positive conversations about entertainment topics. The site invites fans to create content, such as writing articles and producing videos, which are then curated on the site and distributed to more than 30 million fans worldwide. The site boasts more than 20 million unique visitors per month, with 87 percent of visitors accessing the site on mobile devices. The company is headquartered in Venice Beach, Calif., and has an office Berlin, Germany, where it was originally founded.
Read more