In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to configure the timeout timeout setting in the nginx.conf file". Many people will encounter this dilemma in the operation of the actual case, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Description of timeout configuration commonly used in nginx
Client_header_timeout
Syntax client_header_timeout time
Default value 60s
Context http server (meaning it can be placed in http blocks and server blocks)
Specifies the timeout for waiting for client to send a request header (for example: GET / HTTP/1.1). It is counted as a timeout only if no request header is received in a read. If client does not send anything within the timeout, nginx returns HTTP status code 408 ("Request timed out")
Client_body_timeout
Syntax client_body_timeout time
Default value 60s
Context http server location
This instruction sets the read timeout of the request body (request body). It is set to time out only if the request body is not obtained in one readstep. After timeout, nginx returns HTTP status code 408 ("Request timed out")
Keepalive_timeout (persistent connection type)
Syntax keepalive_timeout timeout [header_timeout]
Default value 75s
Context http server location
Indicates that the first parameter specifies the keep-alive connection timeout to client. The server will close the connection after this time. The optional second parameter specifies the time value in the response header Keep-Alive: timeout=time. This header allows some browsers to actively close the connection, so that the server does not have to close the connection. Without this parameter, nginx will not send a Keep-Alive response header (although this header does not determine whether the connection is "keep-alive") (when the server returns data to the user, the keepalive field 75s will be added to the header header file, after which the browser can actively close the connection.)
The values of the two parameters are not the same
Notice how different browsers handle the "keep-alive" header
MSIE and Opera ignored "Keep-Alive: timeout=" header.
MSIE stays connected for about 60-65 seconds, then sends TCP RST
Opera permanently maintains a long connection
Mozilla keeps the connection alive for N plus about 1-10 seconds.
Konqueror maintains a long connection for N seconds
Lingering_timeout
Syntax lingering_timeout time
Default value 5s
Context http server location
Indicates that after lingering_close takes effect, before closing the connection, it will detect whether any data sent by the user has reached the server. If there is no data to read after the lingering_timeout time, the connection will be closed directly; otherwise, the connection will not be closed until the data in the connection buffer has been read and discarded.
Resolver_timeout
Syntax resolver_timeout time
Default value 30s
Context http server location
Indicates that this instruction sets the DNS parsing timeout
Timeout setting for proxy forwarding module:
Proxy_connect_timeout
Syntax proxy_connect_timeout time
Default value 60s
Context http server location
Indicates that this instruction sets the connection timeout to upstream server. It is important to remember that this timeout cannot exceed 75 seconds.
This is not the time to wait for the back end to return the page, that is declared by proxy_read_timeout. If your upstream server is up, but the hanging resides (for example, there are not enough threads to process the request, so put your request in the request pool for later processing), then this declaration is useless because a connection to the upstream server has been established.
This directive assigns a timeout for the connection to the proxyserver. This is not the time until the server returns the pages, this is the proxy_read_timeout statement. If your proxyserver is up, but hanging (e.g. It does not have enough threads to process your request so it puts you in the pool of connections to deal with later), then this statement will not help as the connection to the server has been made. It is necessary to keep in mind that this time out cannot be more than 75 seconds.
Proxy_read_timeout
Syntax proxy_read_timeout time
Default value 60s
Context http server location
Indicates that the directive sets the read timeout with the proxy server. It determines how long nginx will wait to get a response to the request. This time is not the time to get the entire response, but the time to perform two reading operations. (? What is the time of two reading operations)
This directive sets the read timeout for the response of the proxied server. It determines how long NGINX will wait to get the response to a request. The timeout is established not for entire response, but only between two operations of reading.
In contrast to proxy_connect_timeout, this timeout will catch a server that puts you in it's connection pool but does not respond to you with anything beyond that. Be careful though not to set this too low, as your proxy server might take a longer time to respond to requests on purpose (e.g. When serving you a report page that takes some time to compute). You are able though to have a different setting per location, which enables you to have a higher proxy_read_timeout for the report page's location.
If the proxied server nothing will communicate after this time, then nginx is shut connection.
Proxy_send_timeout
Syntax proxy_send_timeout time
Default value 60s
Context http server location
Indicates that this specification sets the timeout for sending requests to the upstream server. The timeout is not set for the entire sending period, but during two write operations. If upstream does not receive new data after the timeout, nginx closes the connection
Proxy_upstream_fail_timeout (fail_timeout)
Syntax server address [fail_timeout=30s]
Default value 10s
Context upstream
Indicates the parameters of the server instruction under the Upstream module. After a certain upstream backend fails a specified number of times (max_fails), the inoperable time of the backend is 10 seconds by default.
Two parameters for load balancer configuration: fail_timeout and max_fails
These two parameters work together to control how nginx thinks that a server in upstream is invalid. When a server connection fails max_fails times in the time of fail_timeout, nginx will think that the server is not working. At the same time, during the following fail_timeout time, nginx no longer distributes requests to invalid server.
Personally, I think that nginx should not control these two times with the same parameter fail_timeout. It would be better if another fail_time can be added to control how long it will take to stop using the server dropped by down.
If you do not set these two parameters, fail_ timeout defaults to 10s _ maxim _ fails and defaults to 1. That is, as long as a server fails once, the request will not be sent to the server within the next 10 seconds.
Send_timeout
Default: send_timeout 60
Send_timeout specifies the response timeout for the client. This setting is not used for the entire transponder, but between two client read operations. If the client does not read any data during that time, nginx closes the connection.
Directive assigns response timeout to client. Timeout is established not on entire transfer of answer, but only between two operations of reading, if after this time client will take nothing, then nginx is shutting down the connection.
Another reference: 504 Gateway Time-out problem
It is common on websites that use nginx as a server for web server
I encountered this problem when upgrading the discuz forum.
Generally speaking, this situation may be due to the fact that the response buffer of nginx's default fastcgi process is too small, which will cause the fastcgi process to be suspended. If your fastcgi service does not handle this suspension well, it is very likely to lead to 504 Gateway Time-out in the end.
Today's websites, especially those in some forums, have a lot of responses and a lot of content, and a page even has hundreds of kilograms.
The default buffer for fastcgi process response is 8K, which we can set to a larger point.
In nginx.conf, add:
Fastcgi_buffers 8 128k
This means that the fastcgi buffer is set to 8 × 128k
Of course, if you are performing an immediate operation, you may need to increase the timeout parameter of nginx, for example, to 60 seconds:
Send_timeout 60
After adjusting these two parameters, the result is that the timeout is not displayed again, which can be said to be good, but it may also be due to other reasons. At present, there is not much information about nginx, and many things need long-term experience to accumulate results.
Proxy_redirect off
Proxy_set_header Host $host
Proxy_set_header X-Real-IP $remote_addr
Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
Client_max_body_size 10m
Client_body_buffer_size 128k
Proxy_connect_timeout 90
Proxy_send_timeout 90
Proxy_read_timeout 90
Proxy_buffer_size 4k
Proxy_buffers 32 4k
Proxy_busy_buffers_size 64k
This is the end of the content of "how to configure timeout timeout settings in nginx.conf file". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.