SPDY is an application layer protocol based on Transmission Control Protocol (TCP) developed by Google. The development team is promoting SPDY to become a formal standard (now an Internet draft). SPDY The protocol is designed to improve web page load times and improve security through compression, multiplexing, and prioritization. (SPDY is the nickname of Speedy, which means faster)
The relationship between SPDY and HTTP
The SPDY protocol only greatly optimizes HTTP in terms of performance. Its core idea is to minimize the number of connections. , and the semantics of HTTP have not been significantly modified. Specifically, SPDY It uses HTTP methods and headers, but deletes some headers and rewrites the parts of HTTP that manage connections and data transfer formats, so it is basically compatible with HTTP.
Google stated in the SPDY white paper that it will penetrate into the protocol stack and replace the transport layer protocol (TCP), but because this is currently very difficult to deploy and implement, so Google plans to improve the application layer protocol HTTP first, first adding a session layer on top of SSL to implement the SPDY protocol, while the GET and POST message formats of HTTP remain unchanged, that is, all existing server applications do not need to be modified. .
So at present, the purpose of SPDY is to strengthen HTTP and provide a better implementation and support for HTTP. As for whether SPDY will be replaced by a civet cat for a prince after it is widely used in the future. It's Google's job to revolutionize HTTP and revolutionize the entire Internet.
Why build a new SPDY?
It has been more than ten years since Tim Berners-Lee, the father of the World Wide Web, invented and promoted HTTP to become the most popular protocol on the Internet today (the current HTTP 1.1 specification has also been stagnant for 13 years), as now With the rapid development of WEB technology, especially the continuous evolution of HTML5, including the emergence of the WebSockets protocol and changes in the current network environment and changes in transmission content, the original HTTP specification has gradually been unable to meet people's needs. HTTP needs further development, so HTTPbis work A group has been formed and authorized to consider HTTP 2.0, hoping to address many of the limitations currently imposed by HTTP. SPDY is a protocol launched by Google when HTTP is about to cross from 1.1 to 2.0 in an attempt to become the next generation of Internet communications. It has long been considered the only viable option for HTTP 2.0.
Disadvantages of HTTP protocol
1. Single-way connection request is inefficient
The biggest disadvantage of HTTP protocol is that each TCP connection can only correspond to one HTTP request, that is, each HTTP connection only requests one resource. , the browser can only solve it by establishing multiple connections. In addition Requests in HTTP are strictly first-in, first-out (FIFO). If a request in the middle takes a long time to process, subsequent requests will be blocked.
(Note: Although HTTP pipelining has improved connection requests, the complexity has increased greatly and has not been popularized)
2. HTTP only allows requests to be actively initiated by the client
The server only Being able to wait for the client to send a request is a constraint in meeting the current status of preloading.
3. HTTP header redundancy
HTTP headers are sent repeatedly in the same session, and redundant information in the middle, such as User-Agent, Host and other information that does not need to be sent repeatedly, are also sent repeatedly. Waste of bandwidth and resources.
Advantages of SPDY protocol
1. Multiplexing request optimization
SPDY stipulates that there can be unlimited parallel requests within a SPDY connection, which allows multiple concurrent HTTP requests to share a TCP session. This way SPDY is multiplexed in a single TCP Multiple requests on the connection, instead of opening a separate connection for each request, so that only one TCP connection can be established to transfer all resources on the web page, which not only reduces the round-trip time for message interaction but also avoids the delay caused by creating a new connection. Make TCP more efficient.
In addition, SPDY's multiplexing can set priorities. Unlike traditional HTTP, which strictly processes requests one by one according to first-in-first-out, it will selectively transmit more important resources such as CSS first and then transmit them. Less important resources such as website icons can avoid the problem of non-critical resources occupying network channels and improve TCP performance.
2. Support server push technology
The server can actively initiate communication to the client and push data to the client. This preloading can keep users on a fast network.
3. SPDY compresses HTTP headers
discards unnecessary header information. After compression, it can save the waiting time and bandwidth caused by redundant data transmission.
4. Mandatory use of SSL transmission protocol
Google believes that the future development direction of the Web must be secure network connections. After all requests for SSL encryption, information transmission will be more secure.
The meaning of SPDY protocol
According to Google, SPDY was created for the sole purpose of making the Web faster (strive to make the whole web fast), and its name SPDY (Speedy) also seems to be hinting at this. So what is the significance of SPDY?
1. Ordinary users:
For users, there is no difference between SPDY hidden under the browser and HTTP, but we can feel that Google services are extremely fast under Chrome. This is Credit goes to SPDY. In addition, after website information transmission is encrypted, there is no need to worry about information being intercepted, etc., which greatly increases security and confidentiality.
2. Front-end staff:
For front-end engineers, improving page efficiency is a very important thing. Currently, most methods like CSS Sprites are used to optimize the website. Because each page is loaded when the page is loaded, pictures, icons They all request one connection and even reference different images on different pages to reduce the number of image requests on one page. Now with SPDY's request optimization, the order of requests can be rearranged, which can largely alleviate the impact of image requests when the page is loaded. For example, if there are too many registered users on the registration page of Geek Park, such as the 2012 Innovation Conference of Geek Park or the 27th Great Wall Conference of Geek Park, it can be clearly felt that the request for avatars will slow down the overall page loading or even slow it down. I believe that those who often go to Taobao or Weibo will have a deep understanding of this. Once the Internet speed is slightly slower, page loading abnormalities will occur. There are also products like the Apple App Store (excluding server delays due to regions). Application icons on application distribution platforms such as Doujia are slow to refresh, as shown in the video below.
3. Operation and maintenance personnel:
While reducing the number of connections, SPDY also reduces the resources occupied by each client on the server, thus freeing up more memory and CPU. In addition, SPDY combined can double browsing speeds and improve page loading latency by up to 64%.
SPDY protocol supported by everyone
If you are using the Chrome browser and Google network services such as Gmail, you are actually no longer accessing these services through HTTP. Open in browser chrome://net-internals/#spdy will find that you are already using the SPDY protocol. (In addition to Google's own Gmail, Google Plus and other Google services, other public sites such as Twitter and Webtide have also supported this protocol. In China, Wandoujia 2.0 based on WebKit has also stated that it will introduce Chrome's SPDY technology to further improve Speed.
The implementation of SPDY requires support from both the browser client and the web server. Needless to say, Google’s own Chrome and Chromium series already support SPDY on the client browser; Mozilla's Firefox also supports SPDY by default since Firefox 13. Amazon's Silk's use of SPDY is actually no worse than Google's own Chrome and Firefox.
In terms of web servers, including the most popular and widespread Apache, Netty, Jeety, Varnish, Erlang and Hightide application servers and Node.js servers have also announced support for SPDY. (Nginx also said it will support SPDY)
How to deploy SPDY?
Recently, Google has officially released the plug-in mod_spdy for the most popular web server Apache. After downloading and installing it, your Apache server can use it. The SPDY protocol communicates with browsers that are compatible with the SPDY protocol, such as Chrome, FireFox, etc. As mentioned before, SPDY runs over HTTPS, and non-HTTPS traffic will not be affected by mod_spdy.
SPDY deployment requirements:
1. Apache 2.2 (≥2.2.4)
2. mod_ssl module enabled
SPDY deployment steps:
1. Download mod_spdy module
Go to the download page to download the installation package for the corresponding system
2. Install the mod_spdy module
Run the following command line in the system terminal
dpkg -i mod-spdy-*. deb
apt-get -f install
-The system is Debian/Ubuntu
------------------------ ----------------------------------
yum install at (if you do not already have ' at' installed)
rpm -U mod-spdy-*.rpm
-The system is CentOS/Fedora
3. Restart the server (Apache)
sudo /etc/init.d /apache2 restart (Debian/Ubuntu)
4. Confirm whether it is enabled or not
Open the Chrome browser, enter and go to the chrome://net-internals/#spdy page, and check whether the host name appears in the identification bar middle. If it appears, it means the deployment has been completed. If it does not appear, check the server error log (error.log).
The above introduces the spdy protocol of nginx, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.