SPDY (Speedy) is a protocol developed by Google under its initiative "Let's make the web faster." SPDY was designed to reduce latency in web pages by addressing limitations in the existing HTTP protocol. SPDY enhances the performance of web communication by improving how data is transferred between clients (browsers) and servers.
HTTP Versions and Their Limitations
- HTTP 0.9 (1991): The first version, which supported basic GET requests.
- HTTP 1.0 (1996): Introduced status codes, headers, and improved request/response mechanisms.
- HTTP 1.1 (1999): Brought persistent connections and chunked transfers, but after this version, there were no significant updates for a long time.
Over the years, web pages grew significantly larger, with an average page size increasing nearly 20 times since the 1990s. For example:
- 1996 Yahoo homepage: 34 KB
- 2012 average page size: 1059 KB
This large increase in page size, along with the growing complexity of modern web pages, exposed the limitations of HTTP 1.1. SPDY was created to address these issues and improve performance.
What SPDY Can Do:
Header Compression:
- SPDY compresses request and response headers, saving bandwidth and reducing latency.
Multiplexed Requests:
- SPDY allows multiple requests to be sent in parallel over a single connection, significantly reducing the round-trip time between the client and server.
Server Push:
- SPDY allows the server to actively push resources (like JavaScript or CSS files) to the client, even without the client explicitly requesting them.
Goals of SPDY:
- 50% decrease in page load time.
- Minimized deployment complexity: Can be deployed with existing network infrastructure.
- No need to modify web content: Web authors don’t need to change their content for SPDY to be effective.
- Efficient handling of multiple HTTP requests in a single TCP connection.
- Header compression to reduce network bandwidth usage.
- Built on SSL/TLS to ensure secure communication, which may introduce some latency overhead but is beneficial for the long-term security of web connections.
- Push from server to client: The server can send data to the client proactively.
SPDY Features:
Basic Features:
Multiplexed Streams:
- Requests are interleaved on a single channel, improving TCP efficiency.
Request Prioritization:
- Clients can assign priority to requests, ensuring more critical requests are handled first, avoiding delays for non-critical resources.
HTTP Header Compression:
- Compresses HTTP headers to reduce overhead.
Advanced Features:
- Server Push:
- The server can push resources to the client proactively without waiting for a request, reducing the time spent waiting for resources.
- Server Hint:
- Instead of pushing resources automatically, the server can suggest resources the client may need using the
X-Subresources
header. This allows the server to inform the client in advance, and the client can decide whether to request the resource.
- Instead of pushing resources automatically, the server can suggest resources the client may need using the
Performance Comparison: SPDY vs HTTP
The following table compares the average page load times and the speedup achieved using SPDY under various configurations:
Setup | Average Load Time (ms) | Speedup |
---|---|---|
HTTP | 3111.916 | 0% |
SPDY (basic multi-domain, TCP) | 2242.756 | 27.93% |
SPDY (basic single-domain, TCP) | 1695.72 | 45.51% |
SPDY (single-domain + server push, TCP) | 1671.28 | 46.29% |
SPDY (single-domain + server hint, TCP) | 1608.928 | 48.30% |
SPDY (basic single-domain, SSL) | 1899.744 | 38.95% |
SPDY (single-domain + client prefetch, SSL) | 1781.864 | 42.74% |
As shown, SPDY achieves significant performance improvements over HTTP. The single-domain + server push configuration provides a 46.29% speedup, and even with SSL encryption, SPDY still offers notable improvements.
Differences Between HTTP Pipelining and SPDY
HTTP Pipelining:
- HTTP pipelining allows multiple requests to be sent over a single TCP connection. However, it still uses a single stream. Any delay in that stream affects the entire sequence of requests.
- The deployment of HTTP pipelining has proven to be complex, and it is disabled by default in most major browsers due to its limitations and issues with error handling.
SPDY:
- SPDY improves upon pipelining by allowing multiplexing, meaning requests are sent over multiple streams within a single connection. This reduces the risk of delays propagating across all requests, making it more efficient.
- SPDY also avoids the limitations of HTTP pipelining, providing better scalability and performance.
Conclusion
SPDY is a more efficient and modern web protocol designed to address the limitations of HTTP/1.1, including handling high-concurrency environments, reducing latency, and improving overall page load times. While HTTP pipelining made some strides in this direction, SPDY offers superior features, such as multiplexing, request prioritization, server push, and better handling of header compression. As of now, HTTP/2 has largely adopted SPDY's concepts, further cementing its legacy in modern web performance improvements.