The time-out relationship between the school's official website and 504!

Source: Internet
Author: User
Tags vps

In the past few days, I have no idea how many students in our school can visit the official website, rather than visiting the educational administration network.

In normal cases, this is even the case. After all, there are not a few people logging on. Do you really want to see what you love?

However, the days that people on earth know are inaccessible, and they know how many students are involved in these days.

Do you know how many people are looking forward to the score of the final exam?

 

Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~ Haha ~~~~

 

The error "504-Gateway Time-out" is reported on the official website.

 

What does "504 Gateway Time-out" mean? And what is a gateway?

 

"504 Gateway Time-out" means Gateway Time-out.

 

Gateway is also known as the inter-network connector and Protocol converter. Gateway is the most complex network interconnection device on the transport layer to achieve network interconnection. It is only used for different network interconnection between two high-level protocols. The structure of the gateway is similar to that of the router. Gateways can be used for both Wan and LAN interconnection. A gateway is a computer system or device that acts as a conversion task. The gateway is a translator between two systems that use different communication protocols, data formats, languages, and even architectures. Different from the Net Bridge, the gateway simply transmits different information. The Gateway repacks the received information to meet the needs of the target system. The gateway can also provide filtering and security functions. Most gateways run on OSI
The top layer of the layer-7 Protocol-the application layer.

Everyone knows that a door is required to walk from one room to another. Similarly, the gateway must pass through a "Gateway" to send information from one network to another. As the name implies, a gateway is the "Gateway" that connects a network to another network ". There are also many types of gateways according to different categories. The Gateway in TCP/IP protocol is the most commonly used here. The "Gateway" we refer to here refers to the gateway under TCP/IP protocol. What is the gateway? In essence, the gateway is the IP address from the network to other networks.

For example, the IP address range of Network A and Network B Network A is "192.168.1.1 ~ 192. The subnet mask of 168.1.254 is 255.255.255.0. The IP address range of Network B is 192.168.2.1 ~ 192.168.2.254 "subnet mask is 255.255.255.0. Without a router, the two networks cannot communicate with each other through TCP/IP, even if the two networks are connected to the same vswitch (or hub) the TCP/IP protocol also determines that the hosts in the two networks are in different networks based on the subnet mask (255.255.255.0. To realize the communication between the two networks, you must use the gateway. If the host in Network A finds that the destination host of the data packet is not in the local network, it forwards the data packet to its own gateway, and then the gateway forwards the data packet to the gateway of Network B and then forwards the data packet to Network B. as shown in the figure below ). The process in which Network B forwards data packets to Network.
Therefore, only the IP address TCP/IP protocol of the gateway can implement mutual communication between different networks. So which machine is the IP address of this IP address? the IP address of the gateway is the IP address of a device with the routing function. A device with the routing function has a router and a server with the routing protocol enabled (essentially equivalent to a router ).), proxy server (also equivalent to a vro ).

In the context of interaction with Novell NetWare, the server information Block (SMB) protocol used in Windows networks and the NetWare Core Protocol (NCP) used by NetWare networks act as a bridge between the network and Novell NetWare. A gateway is also called an IP router.

 

Many colleagues have found a solution to this problem:

Solve the Problem of 504 Gateway Time-out in nginx:

The lnmp configuration in CentOS basically uses the same configuration file and has never encountered any problems. After installing the same environment on a vps recently, when the website is online for more than 10 people, the open speed is very slow. Several times, it has reached the maximum timeout of 300 seconds for the script set in nginx, as a result, nginx sends a 504
The error code of Gateway Time-out is analyzed and several configuration files are modified to avoid this situation.

From the error code, it can be basically determined that it has nothing to do with nginx, mainly because the request submitted to php-fpm fails to provide correct feedback. Generally, when submitting a dynamic request, nginx will directly forward the request to php-fpm, while php-fpm will distribute the php-cgi process to process the related requests, and then return them in sequence, finally, nginx sends the result to the client browser. However, my vps currently runs a pure php application. In fact, all users' requests are php requests, and some of them take a long time, the php-cgi process is always full, and the configuration file of php-fpm itself only opens 10 php-cgi processes, in this way, if there are a few online users, the requests will not be processed properly and errors will occur.

After analyzing the original cause, it is easier to do the following: First, modify the configuration of PHP-FPM:

Change max_children from the previous 10 to the current 30, so that sufficient PHP-CGI processes can be used;
Change request_terminate_timeout from the previous 0 s to 60 s, so that the timeout time for the PHP-CGI process to process the script is 60 seconds, which can prevent the process from being suspended and improve the utilization efficiency.

Then, modify several nginx configuration items to reduce the number of FastCGI requests and try to keep buffers unchanged:

Change fastcgi_buffers from 4 64 K to 2 256 K;
Fastcgi_buffer_size is changed from 64 K to 128 K;
Fastcgi_busy_buffers_size is changed from 128 K to 256 K;
Fastcgi_temp_file_write_size is changed from 128 K to 256 K.

Okay, reload the configuration of php-fpm and nginx, and test again. So far, No 504 Gateway Time-out has been found in two weeks.

In addition, the default static Processing Method of php-fpm will make the php-cgi process occupy the memory for a long time and cannot be released, which is also one of the causes of nginx errors, therefore, you can change the php-fpm Processing Method to the apache mode.
<Value name = "style"> apache-like </value>

Tests from the change to the present show that the above method is still very effective, and no Nginx502 bad gateway or 504 Gateway Time-out error was found. Of course, if your VPS or server performance is good enough, you do not need to make any necessary changes based on the actual situation.

 

We hope the school's official website will be rescued from the timeout relationship with 504 as soon as possible !! Amen !!

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.