Home Backend Development PHP Tutorial nginx spdy protocol

nginx spdy protocol

Aug 08, 2016 am 09:31 AM
apache chrome google http

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.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
How to set the cgi directory in apache How to set the cgi directory in apache Apr 13, 2025 pm 01:18 PM

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

How to connect to the database of apache How to connect to the database of apache Apr 13, 2025 pm 01:03 PM

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

How to view your apache version How to view your apache version Apr 13, 2025 pm 01:15 PM

There are 3 ways to view the version on the Apache server: via the command line (apachectl -v or apache2ctl -v), check the server status page (http://<server IP or domain name>/server-status), or view the Apache configuration file (ServerVersion: Apache/<version number>).

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to view the apache version How to view the apache version Apr 13, 2025 pm 01:00 PM

How to view the Apache version? Start the Apache server: Use sudo service apache2 start to start the server. View version number: Use one of the following methods to view version: Command line: Run the apache2 -v command. Server Status Page: Access the default port of the Apache server (usually 80) in a web browser, and the version information is displayed at the bottom of the page.

How to configure zend for apache How to configure zend for apache Apr 13, 2025 pm 12:57 PM

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

How to solve the problem that apache cannot be started How to solve the problem that apache cannot be started Apr 13, 2025 pm 01:21 PM

Apache cannot start because the following reasons may be: Configuration file syntax error. Conflict with other application ports. Permissions issue. Out of memory. Process deadlock. Daemon failure. SELinux permissions issues. Firewall problem. Software conflict.

How to delete more than server names of apache How to delete more than server names of apache Apr 13, 2025 pm 01:09 PM

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.

See all articles