X (formerly Twitter) Dec 19, 2013

CocoaSPDY: SPDY For iOS and OS X

Article Summary

Twitter just made mobile apps 30% faster with a single line of code. Here's how they did it and why they're giving it away for free.

Twitter Engineering open sourced CocoaSPDY, bringing the SPDY protocol (HTTP's experimental successor) to iOS and OS X apps. The framework integrates with existing apps via a single line of code, leveraging Apple's NSURLProtocol interface.

Key Takeaways

Critical Insight

Twitter achieved 30% faster API requests on mobile by implementing SPDY, with the biggest wins coming from poor network conditions.

The performance charts reveal exactly where SPDY shines and why the 99th percentile tells a different story than the median.

About This Article

Problem

Mobile users on cellular networks were dealing with high latency. The problem came down to too many back-and-forth requests between client and server. HTTP's design, while human-readable, didn't leave much room for optimization on slower connections.

Solution

Twitter built CocoaSPDY, a binary protocol written in Objective-C. It swaps out HTTP for SPDY's multiplexing, and it works directly with NSURLConnection and NSURLSession without any friction.

Impact

SPDY cut latency across different network conditions. The biggest wins showed up at the 95th and 99th percentile of poor cellular connections, which is exactly where users were struggling the most.