This article is a mirror article of machine translation, please click here to jump to the original article.

View: 6864|Reply: 4

Practical Optimization of Nginx HTTP Request Concurrency

[Copy link]
Posted on 1/16/2022 1:46:40 PM | | | |
The website program is developed by asp.net core, the browser requests a page, and the server needs to go through the nginx reverse proxy to the .NET program to process, and during the stress test, it will report a 503 error:

503 Service Temporarily Unavailable

503 is an HTTP status code due toTemporary server maintenance or overload, the server is currently unable to process requests。 This condition is temporary and will be restored after some time.

Generally speaking, the 503 error is mostly due to the large number of website visits, resulting in an error caused by excessive traffic or a large number of concurrency.

According to the analysis of the barrel principle, there are many factors that cause performance bottlenecks, first of all, the Linux tuning reference is as follows:

Linux (CentOS) ulimits server performance tuning
https://www.itsvse.com/thread-10134-1-1.html

Through professional pressure testing tools, the pressure test results are as follows:

.NET/C# Load Test NBomber Simple Tutorial
https://www.itsvse.com/thread-9993-1-1.html



Nginx tuning

worker_processes Set to Automatic, as follows:

Let nginx automatically adjust to your needs.

events settings are as follows:

Use epoll mode to increase the number of concurrent connections, increase the concurrent connection capacity of the nginx system, and set the maximum number of connections that can be opened by workers at the same time. Document Introduction:The hyperlink login is visible.

After tuning, the pressure test is performed, and there is no more 503 error, as shown in the figure below:


If you use an nginx reverse proxy to forward to php-fpm, you may get the following error:

2022/01/16 16:08:01 [crit] 968#0: *12955 open() "/alidata/www/itsvse_web/50x.html" failed (24: Too many open files), client: 100.116.153.2, server:www.itsvse.com, request: "GET /forum.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.itsvse.com"
2022/01/16 16:08:01 [alert] 968#0: *12956 socket() failed (24: Too many open files) while connecting to upstream, client: 100.116.153.109, server:www.itsvse.com, request: "GET /forum.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.itsvse.com"
2022/01/16 16:08:01 [crit] 968#0: *12956 open() "/alidata/www/itsvse_web/50x.html" failed (24: Too many open files), client: 100.116.153.109, server:www.itsvse.com, request: "GET /forum.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.itsvse.com"



Set the worker_rlimit_nofile parameters as follows:



Documentation:The hyperlink login is visible.

(End)





Previous:The difference and connection between Ubuntu, CentOS, and RedHat
Next:OceanBase Database Management Tool Download
Posted on 1/16/2022 9:02:14 PM |
Come and learn again
Posted on 1/24/2022 11:18:47 AM |
I learned it, thank you
 Landlord| Posted on 3/30/2023 10:01:36 AM |
Nginx:413 Request Entity Too Large
https://www.itsvse.com/thread-10545-1-1.html
 Landlord| Posted on 3/30/2023 10:01:45 AM |
Nginx adds HTTP/2 protocol enabled
https://www.itsvse.com/thread-10307-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com