Home Backend Development PHP Tutorial listen queue of socket fd: 3 Error analysis

listen queue of socket fd: 3 Error analysis

Jul 29, 2016 am 09:15 AM
listen socket uwsgi

Nowadays, Django applications are basically deployed using uwsgi. An error similar to the following listen queue of socket "127.0.0.1:9001" (fd: 3) has occurred twice. Let’s talk about these two errors below. the solution process.

Error scenario

  • centos 6.6
  • uwsgi2.0
  • nginx1.6

Error log interception

<code><span>Tue</span><span>Jun</span><span>2</span><span>17</span>:<span>33</span>:<span>27</span><span>2015</span> - *** <span>uWSGI</span><span>listen</span><span>queue</span><span>of</span><span>socket</span><span>"127.0.0.1:9001"</span> (<span>fd</span>: <span>3</span>) <span>full</span><span>!</span><span>!</span><span>!</span> (<span>101</span>/<span>100</span>) ***
<span>Tue</span><span>Jun</span><span>2</span><span>17</span>:<span>33</span>:<span>28</span><span>2015</span> - *** <span>uWSGI</span><span>listen</span><span>queue</span><span>of</span><span>socket</span><span>"127.0.0.1:9001"</span> (<span>fd</span>: <span>3</span>) <span>full</span><span>!</span><span>!</span><span>!</span> (<span>101</span>/<span>100</span>) ***</code>
Copy after login
  • The first time was because the firewall of China Unicom computer room was misconfigured, which restricted the server output, that is There is no problem in sending external packages to the server, but when the server returns the package to the outside, it is very slow and almost unavailable. At this time, a large number of errors appear in the uwsgi log

  • The second time is after the concurrency volume increased sharply, the active link remained Around 6000, this error appeared in large numbers.

Analysis

Based on this error, we searched for relevant information. It should be a problem with system-level parameters. For details, please refer to linux man page listen(2).

lzzNote: A simple understanding is that each listener For sockets, before there is an accept, the length of the socket waiting for processing is 128 by default in Linux (at least in centos6.6), and the default is 100 in my compiled uwsgi, which means that before adjusting the system parameters, The highest is 128. So how can we adjust the length of the

queue

? * System parameters must be adjusted to make it effective * You must adjust the uwsgi configuration and then restart the application

Operation

Modify the system parameters

The configuration file is modified directly here, and it will still be valid after restarting.

Modify the /etc/sysctl.conf file, add or modify these parameter values ​​

<code><span>#对于一个经常处理新连接的高负载 web服务环境来说,默认的 128 太小了</span>
net<span>.core</span><span>.somaxconn</span> = <span>262144</span>
?<span>#表示SYN<strong>队列</strong>的长度,默认为1024,加大<strong>队列</strong>长度为8192,可以容纳更多等待连接的网络连接数</span>
net<span>.ipv</span>4<span>.tcp</span>_max_syn_backlog = <span>8192</span><span>#网卡设备将请求放入<strong>队列</strong>的长度</span>
net<span>.core</span><span>.netdev</span>_max_backlog = <span>65536</span></code>
Copy after login

After the modification is completed, remember to

sysctl -p

Reload the parameters uwsgi adjustment

Whether it is configuration or adding one on the command line options, for example, add the following configuration to the .ini file

<code><span>listen</span>=<span>1024</span></code>
Copy after login

, then restart the application and reload the configuration.

Summary

By modifying the configuration, this error has almost never occurred, and the system throughput and concurrency have been greatly improved. So system characteristics and tuning are very important to improve the overall service quality.

Reference

somaxconn - That pesky limit.
  • listen(2) - Linux man page
Copyright statement: This article is an original article by orangleliu (http://blog.csdn.net/orangleliu/), article Please declare if reprinted.

The above has introduced the listen queue of socket fd: 3 error analysis, including the relevant aspects. 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)

IO multiplexing of PHP+Socket series and implementation of web server IO multiplexing of PHP+Socket series and implementation of web server Feb 02, 2023 pm 01:43 PM

This article brings you relevant knowledge about php+socket, which mainly introduces IO multiplexing and how php+socket implements web server? Friends who are interested can take a look below. I hope it will be helpful to everyone.

Comparing the performance of Gunicorn and uWSGI for Flask application deployment Comparing the performance of Gunicorn and uWSGI for Flask application deployment Jan 17, 2024 am 08:52 AM

Flask application deployment: Comparison of Gunicorn vs suWSGI Introduction: Flask, as a lightweight Python Web framework, is loved by many developers. When deploying a Flask application to a production environment, choosing the appropriate Server Gateway Interface (SGI) is a crucial decision. Gunicorn and uWSGI are two common SGI servers. This article will describe them in detail.

How to use Python's socket and socketserver How to use Python's socket and socketserver May 28, 2023 pm 08:10 PM

1. Socket programming based on TCP protocol 1. The socket workflow starts with the server side. The server first initializes the Socket, then binds to the port, listens to the port, calls accept to block, and waits for the client to connect. At this time, if a client initializes a Socket and then connects to the server (connect), if the connection is successful, the connection between the client and the server is established. The client sends a data request, the server receives the request and processes the request, then sends the response data to the client, the client reads the data, and finally closes the connection. An interaction ends. Use the following Python code to implement it: importso

How to use Spring Boot+Vue to implement Socket notification push How to use Spring Boot+Vue to implement Socket notification push May 27, 2023 am 08:47 AM

The first step on the SpringBoot side is to introduce dependencies. First we need to introduce the dependencies required for WebSocket, as well as the dependencies for processing the output format com.alibabafastjson1.2.73org.springframework.bootspring-boot-starter-websocket. The second step is to create the WebSocket configuration class importorg. springframework.context.annotation.Bean;importorg.springframework.context.annotation.Config

Common network communication and security problems and solutions in C# Common network communication and security problems and solutions in C# Oct 09, 2023 pm 09:21 PM

Common network communication and security problems and solutions in C# In today's Internet era, network communication has become an indispensable part of software development. In C#, we usually encounter some network communication problems, such as data transmission security, network connection stability, etc. This article will discuss in detail common network communication and security issues in C# and provide corresponding solutions and code examples. 1. Network communication problems Network connection interruption: During the network communication process, the network connection may be interrupted, which may cause

What to do if php socket cannot connect What to do if php socket cannot connect Nov 09, 2022 am 10:34 AM

Solution to the problem that the php socket cannot be connected: 1. Check whether the socket extension is enabled in php; 2. Open the php.ini file and check whether "php_sockets.dll" is loaded; 3. Uncomment "php_sockets.dll".

How to deploy centos+nginx+uwsgi to launch django project How to deploy centos+nginx+uwsgi to launch django project May 15, 2023 am 08:13 AM

My Django project is called yunwei. The main apps are rabc and web. The entire project is placed under /opt/ as follows: [root@test-codeopt]#lsdjango_virtnginxredisredis-6.2.6yunwei[root@test-codeopt]#lsyunwei/manage.pyrbacstatictemplatesuwsgiwebyunwei[root @test-codeopt]#lsyunwei/uwsgi/cut_log.shloguwsgi.iniuwsgi.loguwsgi.p

Methods and techniques for implementing Socket communication in PHP Methods and techniques for implementing Socket communication in PHP Mar 07, 2024 pm 02:06 PM

PHP is a commonly used development language that can be used to develop various web applications. In addition to common HTTP requests and responses, PHP also supports network communication through Sockets to achieve more flexible and efficient data interaction. This article will introduce the methods and techniques of how to implement Socket communication in PHP, and attach specific code examples. What is Socket Communication Socket is a method of communication in a network that can transfer data between different computers. by S

See all articles