SPDY on Rails

At Bugsnag we use SPDY on our production rails application. For our users who run modern browsers, this can make the site feel much faster and more responsive. Want to get SPDY working on your production rails app? Read on.

What is SPDY?

SPDY is a modern networking protocol for the web which has been designed from the ground up to reduce page load times and latency, as well as improve security. The SPDY protocol was developed byGoogle, and is a candidate to be used as the basis for HTTP/2.0.

Is SPDY Ready for Production Use?

Major sites, including Google and Twitter are using SPDY right now, andFacebook are currently in the process of implementing SPDY.

The latest stable versions of modern web browsers, including Chrome andFirefox, already support SPDY. In fact, if you are using Google Chrome and you head to a SPDY-enabled website, your browser will automatically use SPDY, falling back to HTTP if SPDY is not supported.

Adding SPDY Support to Your Rails App (Nginx+Passenger)

I’m going to discuss Bugsnag’s production setup, as it is one of the most common production configurations for rails apps, and it is very easy to addSPDY support.

Bugsnag uses Nginx with the Phusion Passenger module to serve our rails app.Since Passenger is implemented as an Nginx module, by adding SPDY support to Nginx, you will automatically get SPDY support on your rails apps.

To add SPDY support to Nginx, you’ll have to apply the Nginx SPDY patch to a development version (1.3.x) of Nginx. Both the Nginx development branch and the SPDY patch are considered experimental, but we have been using them both in production for months with no issues.

The following script automatically builds Nginx with Passenger and SPDY support:

Configuring Nginx to Use SPDY

Most browsers with SPDY support require that SPDY uses SSL. If your production site is not already SSL compatible (or even SSL-only) you will first have to obtain an SSL certificate and configure Nginx to use SSL.

Monitoring SPDY in Production

Since SPDY-compatible browsers should automatically fall back to HTTPS whenSPDY is not available, you can continue to use your current production site monitoring systems such as Monit or Pingdom.

If you would like to have SPDY specific monitoring, consider writing a Monit monitoring script which uses the spdycat tool from spdylay. Pingdom does not currently support monitoring the SPDY protocol.

SPDY on Rails Without Nginx

If you are using Apache, check out mod_spdy. It doesn’t look like Unicorn supports SPDY right now, but it might be possible to use a SPDY proxy.

Conclusion

SPDY is ready to use right now

It is easy to get your Rails apps using spdy with nginx + spdy patch + passenger