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
- 30% latency reduction for API requests over SPDY versus HTTP in production
- One-line integration using NSURLConnection or NSURLSession protocols
- Performance gains increase as network conditions worsen (cellular long tail)
- Written in Objective-C with zero external dependencies, Apache 2.0 licensed
Twitter achieved 30% faster API requests on mobile by implementing SPDY, with the biggest wins coming from poor network conditions.
About This Article
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.
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.
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.